feat(opencode): let tools opt into strict mode - #40216
Closed
mayshwartz2 wants to merge 2 commits into
Closed
Conversation
Tools can now declare strict: true, and the tool.definition plugin hook can set or override it. The flag is passed through to the AI SDK Tool, which providers that support structured outputs forward to the model. The existing hardcoded strict: false for @ai-sdk/openai, @ai-sdk/azure and @ai-sdk/amazon-bedrock/mantle is unchanged.
mayshwartz2
force-pushed
the
tool-strict-mode
branch
from
August 4, 2026 10:44
6323a78 to
6d2fd72
Compare
Contributor
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Contributor
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #40214
Type of change
What does this PR do?
Lets a tool ask for strict mode, instead of it being decided only by which provider you're on.
strict?: booleanis added to the tool definition and to thetool.definitionplugin hook, and passed to the AI SDKToolonly when explicitly set. Thestrict: falseinjection from #33392 for@ai-sdk/openai,@ai-sdk/azureand@ai-sdk/amazon-bedrock/mantleis untouched and still wins, so nothing changes unless a tool opts in.It reaches the model because
strict?: booleanis a documented field on the AI SDKTooltype,@ai-sdk/amazon-bedrock@4.0.112forwards it intotoolSpec, and Bedrock's Converse API enforces it.Five lines of production code, the rest is tests. AI SDK path only — the TODO at
packages/llm/src/protocols/openai-responses.ts:264is a separate change.How did you verify your code works?
bun run typecheck: 30/30 tasks pass.bun test test/tool/ test/provider/: 872 pass.bun test test/session/ test/plugin/: 536 pass..opencode/tooldeclaringstrict: truereaches the registry with it set and doesn't leak onto other tools, and it survivesLLMRequestPrep.prepareon@ai-sdk/amazon-bedrockwhile still being forced tofalseon mantle.us.anthropic.claude-sonnet-4-6) that the flag does something: optional properties are fine,additionalPropertiesmust be explicitlyfalse, andminimum/maximum/maxItemsare rejected.Screenshots / recordings
Not a UI change.
Checklist