Skip to content

feat(opencode): let tools opt into strict mode - #40216

Open
mayshwartz2 wants to merge 3 commits into
anomalyco:devfrom
mayshwartz2:tool-strict-mode
Open

feat(opencode): let tools opt into strict mode#40216
mayshwartz2 wants to merge 3 commits into
anomalyco:devfrom
mayshwartz2:tool-strict-mode

Conversation

@mayshwartz2

@mayshwartz2 mayshwartz2 commented Aug 3, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #40214

Type of change

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

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?: boolean is added to the tool definition and to the tool.definition plugin hook, and passed to the AI SDK Tool only when explicitly set. The strict: false injection from #33392 for @ai-sdk/openai, @ai-sdk/azure and @ai-sdk/amazon-bedrock/mantle is untouched and still wins, so nothing changes unless a tool opts in.

It reaches the model because strict?: boolean is a documented field on the AI SDK Tool type, @ai-sdk/amazon-bedrock@4.0.112 forwards it into toolSpec, 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:264 is a separate change.

How did you verify your code works?

  • Root bun run typecheck: 30/30 tasks pass.
  • bun test test/tool/ test/provider/: 872 pass. bun test test/session/ test/plugin/: 536 pass.
  • New tests: a custom .opencode/tool declaring strict: true reaches the registry with it set and doesn't leak onto other tools, and it survives LLMRequestPrep.prepare on @ai-sdk/amazon-bedrock while still being forced to false on mantle.
  • Checked against Bedrock directly (us.anthropic.claude-sonnet-4-6) that the flag does something: optional properties are fine, additionalProperties must be explicitly false, and minimum/maximum/maxItems are rejected.

Screenshots / recordings

Not a UI change.

Checklist

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

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Let tools opt into strict mode

1 participant