fix(opencode): restore _noop tool injection for Bedrock-backed providers during compaction#34094
Open
sledigabel wants to merge 2 commits into
Open
fix(opencode): restore _noop tool injection for Bedrock-backed providers during compaction#34094sledigabel wants to merge 2 commits into
sledigabel wants to merge 2 commits into
Conversation
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>
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 #34089
Type of change
What does this PR do?
Bedrock requires
toolConfigwhenever messages containtoolUse/toolResultcontent blocks — even when no tools are active (e.g. during compaction). Without it, the request fails.A
_noopstub 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-copilotprovider ID guard, injecting_noopwhenever 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?
opencodeand checked by myself. Triggered a tool then compaction and it worked fine.Screenshots / recordings
If this is a UI change, please include a screenshot or recording.
Checklist
If you do not follow this template your PR will be automatically rejected.