Skip to content

[FEATURE]: External Tool Execution API #20697

Closed

Description

@sigmaSd

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before. (I tried but there are many issues I can't really tell)

Describe the enhancement you want to request

Problem

When using OpenCode (via sdk) as an AI backend via API, there's no way to:

  1. Disable OpenCode's built-in tool execution
  2. Execute tools locally
  3. Send tool results back to OpenCode so the model can see them

Currently, tools can be configured with action: "allow" (executes immediately) or action: "ask" (waits for permission response), but:

  • With "allow": OpenCode executes the tool itself
  • With "ask": The permission API responds successfully, but the tool never completes

Desired Flow

  1. App creates session with permission: [{ permission: "bash", pattern: "*", action: "deny" }] (or similar)
  2. OpenCode detects tool is needed but doesn't execute it
  3. App executes the tool locally
  4. App sends the tool result back to OpenCode via API
  5. OpenCode continues with the tool result in its context

Suggested API

Option A: A new endpoint to submit tool results:

POST /session/{id}/tool-result
{
  callID: "call_xxx",
  tool: "bash", 
  output: "...",
  status: "completed"
}

Option B: Support injecting tool results via a new message part type that OpenCode recognizes as a tool result rather than user input

Option C: Add a session configuration option like tool_execution: "external" that completely disables internal execution

Workaround

Currently we're using action: "allow" which works but means OpenCode executes the tools, not my app This loses the benefit of local execution (using user's environment, preserving context, etc.).

Environment

  • OpenCode version: 1.3.13
  • SDK: @opencode-ai/sdk

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Apr 2, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 2, 2026
  3. github-actions commented on Apr 2, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If you believe your issue is distinct, please clarify the differences.

  4. rodrigodmpa commented on Apr 3, 2026

    @rodrigodmpa

    Hi @thdxr, @sigmaSd — is this feature request actually completed? I’m trying to implement the same functionality in my application, but I haven’t been able to figure out how to achieve it.

  5. sigmaSd commented on Apr 3, 2026

    @sigmaSd
    Author

    No it's not but I closed because this feature request turns out to been asked multiple times and there is an open PE for it already

  6. illera88 commented on Apr 4, 2026

    @illera88

    Hi @sigmaSd can you point to the open PR you are referring to?

    Thanks

  7. sigmaSd commented on Apr 5, 2026

    @sigmaSd
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions