Skip to content

fix(opencode): stop sending tools when tool_call is false#35433

Open
tobwen wants to merge 1 commit into
anomalyco:devfrom
tobwen:fix-toolcall-false
Open

fix(opencode): stop sending tools when tool_call is false#35433
tobwen wants to merge 1 commit into
anomalyco:devfrom
tobwen:fix-toolcall-false

Conversation

@tobwen

@tobwen tobwen commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #19966
Closes #35432

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

tool_call: false in model config was stored in capabilities.toolcall but never checked in the prompt loop. SessionTools.resolve() ran unconditionally, tools were sent in every LLM request with tool_choice: "auto". Providers that do not support tool calling (e.g. local Ollama models, morphllm without special flags) returned 400.

Three changes in packages/opencode/src/session/prompt.ts:

  1. Guard SessionTools.resolve() behind model.capabilities.toolcall - skip tools entirely when false.
  2. Set toolChoice: "none" when toolcall is false (the default undefined becomes "auto" at the provider).
  3. When format.type === "json_schema" and toolcall is false, fail fast with a clear StructuredOutputError instead of pushing a misleading system prompt and making a doomed LLM call.

How did you verify your code works?

  • Read the AI SDK source: prepareToolsAndToolChoice drops both empty tools and toolChoice before the HTTP body is serialized, so no tools or tool_choice key reaches the provider when toolcalling is disabled.
  • bun typecheck passes.
  • Existing prompt tests pass. Added a regression test under noLLMServer.instance that verifies the loop does not crash with tool_call: false.
  • Built a single binary and ran the smoke test.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@tobwen tobwen force-pushed the fix-toolcall-false branch from 02d535b to eb36a5e Compare July 5, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config tool_call: false does not disable tools 在发送请求时检查 capabilities.toolcall,当为 false 时不发送 tools 参数。

1 participant