Repository navigation
fix(ai): flatten xAI compaction requests like every step - #65726
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Looks correct. I copied the new test into the base checkout and it fails there: the /compact history calls the tool lookup, while the compiled step calls it crm_lookup. With this PR both use crm_lookup, and compaction.test.ts and effort-updates.test.ts pass (70/70). tsc --noEmit passes for packages/ai. Running flattenRequest before ResponsesCompaction.make matches what Protocol.make does for every step. Folding tool updates after flattening is safe, and OpenAI compaction is untouched.
Public API: unchanged (XAIResponses.compact keeps its CompactOperation type).
No blocking concerns.
6 of 10 tasks
1 task
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
No linked issue. Found in a prompt-cache audit of the changes since v2.3.2.
Type of change
What does this PR do?
Since #65621,
Protocol.makerunsflattenRequeston every step's request for protocols without native namespaces, so past calls to a namespaced tool go to xAI under the flat name (crm_lookup). xAI's/compactcall doesn't go throughProtocol.make:ResponsesCompaction.makeflattens only the tool list and lowers the history as it is, so the same past call goes out aslookup.The history then differs from the prefix the steps cached, so
/compactmisses the cache whenever the session has called a namespaced tool.XAIResponses.compactnow flattens the whole request first, asProtocol.makedoes. OpenAI's compaction is unaffected: its protocol keeps native namespaces on both paths.How did you verify your code works?
packages/ai/test/provider/compaction.test.ts: for a request with a namespaced tool and a past call to it, the/compactbody's tool and call names match the compiled step's (crm_lookup). It fails without the fix (lookup).compaction.test.tsandeffort-updates.test.tsinpackages/aipass;bun typecheckandbun run checkpass.Screenshots / recordings
N/A
Checklist