Skip to content

fix(opencode): restore _noop tool injection for Bedrock-backed providers during compaction#34094

Open
sledigabel wants to merge 2 commits into
anomalyco:devfrom
sledigabel:fix-toolConfig-provider
Open

fix(opencode): restore _noop tool injection for Bedrock-backed providers during compaction#34094
sledigabel wants to merge 2 commits into
anomalyco:devfrom
sledigabel:fix-toolConfig-provider

Conversation

@sledigabel

Copy link
Copy Markdown

Issue for this PR

Closes #34089

Type of change

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

What does this PR do?

Bedrock requires toolConfig whenever messages contain toolUse/toolResult content blocks — even when no tools are active (e.g. during compaction). Without it, the request fails.

A _noop stub tool was previously injected to satisfy this constraint. Commit 7f7eb2e (#26819) narrowed the injection to GitHub Copilot only, likely thinking it was a LiteLLM-specific bug. But this is also a Bedrock API requirement, not a LiteLLM bug — any proxy that forwards to Bedrock without injecting its own dummy tool (e.g. Portkey) still hits it.

The fix: remove the github-copilot provider ID guard, injecting _noop whenever tools is empty but messages contain tool blocks.

The injection is universal rather than Bedrock-specific — this was the original behaviour before #26819 and worked without issue.

How did you verify your code works?

  • New test: "injects _noop tool when messages contain tool calls but no tools are defined" — sends a compaction-like request through a non-Copilot provider and asserts the wire payload includes _noop in the tools array.
  • Tested locally: built opencode and checked by myself. Triggered a tool then compaction and it worked fine.
  • All 27 LLM tests pass.
  • bun typecheck clean.

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

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

If you do not follow this template your PR will be automatically rejected.

sledigabel and others added 2 commits June 26, 2026 17:12
The _noop stub tool injection was accidentally narrowed to only GitHub
Copilot in 7f7eb2e (anomalyco#26819). This left Bedrock-backed providers
(e.g. Portkey) failing during compaction because Bedrock requires a
toolConfig field whenever messages contain toolUse/toolResult blocks.

Make the injection universal: if tools is empty but messages contain
tool-call/tool-result content blocks, always inject the _noop stub.

Co-authored-by: OpenCode <noreply@opencode.ai>
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.

Compaction fails on Bedrock-backed providers: missing toolConfig

1 participant