Skip to content

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

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

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 3 times, most recently from eb36a5e to 5f119e0 Compare July 5, 2026 20:56
@tobwen

tobwen commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

As the discussion appeared on Discord. This config setting is clearly defined under model section in config.json-specs:

image

From a semantic perspective, this is also the correct place. It is defined here that the model does not support tools, not that the user does not want to have tools in an agent.

@tobwen
tobwen force-pushed the fix-toolcall-false branch from 02e77d8 to 369bc9f Compare July 31, 2026 14:53
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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