Skip to content

SDK cannot handle question tool interaction (no way to respond to tool calls in serve mode) #19702

Description

@ZYT20001

Description

Problem

When using OpenCode via SDK (not CLI), there is no way to handle or respond to the question tool call triggered by the model.

In my setup, I built a custom frontend (web UI) and communicate with OpenCode through the SDK + backend service. However:

  • The model frequently triggers the question tool
  • The server enters a waiting state for user input
  • But the SDK does NOT expose any API to:
    • intercept the question tool call
    • provide the answer programmatically
    • continue the execution loop

This causes the request to hang indefinitely.


Expected Behavior

There should be a way in SDK / serve mode to:

  1. Detect when a question tool is triggered
  2. Retrieve the question payload (prompt, metadata, etc.)
  3. Send back the user's answer programmatically
  4. Resume the execution

Example (pseudo API):

client.onToolCall((tool) => {
  if (tool.name === "question") {
    return {
      answer: "user input from my UI"
    }
  }
})

### Plugins

_No response_

### OpenCode version

1.3.2

### Steps to reproduce

## CLI vs SDK Behavior

CLI:
- `question` is displayed
- user can input answer
- execution continues

SDK:
- `question` is triggered internally
- no way to respond
- execution hangs

This indicates the interaction layer exists in CLI but is not exposed in SDK.

### Screenshot and/or share link

_No response_

### Operating System

windows

### Terminal

_No response_

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions