Repository navigation
fix(ai): fold tool changes alongside context_management compaction on Responses - #65028
rekram1-node wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
The change looks sound. I checked it in packages/ai, since OpenCode core still folds every tool change and so can't trigger either path. Both new tests in test/tool-updates.test.ts fail on the base and pass with this change. The full packages/ai suite and tsc type-checking pass.
The final custom-tool map still decides tool_choice and how new calls are parsed. The other users of OpenAIFreeform.tools (xAI, Chat, the compaction endpoint) are not affected, because only OpenAI Responses changes tools in place. Folding when contextManagement is set follows the same rule as supportsEffortUpdates.
The public API is unchanged; everything touched is internal to packages/ai.
No concerns.
2476866 to
0ef0d4d
Compare
There was a problem hiding this comment.
The free-form part was dropped, so this is now only the context_management fold. The change looks sound. It applies the same rule supportsEffortUpdates already uses, and with compaction on, a tool change misses the prompt cache, as every tool change does today. The new test fails on the base and passes here. The full packages/ai suite and tsc type-checking pass.
The public API is unchanged; the change is internal to packages/ai.
No concerns.
On OpenAI Responses, tool changes now fold into top-level
toolswhen automaticcontext_managementcompaction is on, instead of going in place.A removal in place leaves the tool declared in an earlier
additional_toolsitem and adds a developer notice saying it's gone. Automatic compaction drops developer messages but keeps the declarations, so after it runs the model sees the tool with no notice:additional_tools: [weather] -developer: "These tools are no longer available. Do not call them: weather." ← dropped by compaction → the model keeps calling weather, and it's refused every stepI hit this live on gpt-6-astra with
compactThreshold: 9000while testing #64381: the model looped on the removed tool until the step limit, 2 of 2 runs. Folding sends the current tool list at the top, so a removed tool simply isn't declared. It's the same rulesupportsEffortUpdatesalready uses forcontext_management.The cost: with
context_managementon, a tool change misses the prompt cache, which is what every tool change does today.Verification
test/tool-updates.test.ts: withcontextManagementset, noadditional_toolsitem is sent and top-leveltoolsis the current set. It fails without the change.packages/aisuite,bun typecheckandbun run checkpass.