Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
This branch has not been deployed
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 #51141
Type of change
What does this PR do?
applyCachePolicypicks which part carries a cache breakpoint. When the targeted message has no text part it fell back tocontent.length - 1, and for an assistant turn that ends inreasoningthat position is the thinking block.ReasoningPartdeclares nocachefield, andMessageis a schema class that rebuilds each part, so a hint written there is dropped on construction: the breakpoint the policy asked for is silently never delivered. That is also the part Anthropic refuses withthinking.cache_control: Extra inputs are not permitted, which is what this issue ran into.markMessageAtnow walks back from the requested position to the last part that can hold a hint (text,tool-call,tool-result) instead of taking the last part whatever it is. When the message itself has no such part it keeps going into the preceding messages, so the policy still gets its breakpoint — one boundary earlier rather than not at all. I checked I could not reproduce the reported 400 on this branch, so this is the picker defect rather than a claim about the exact request the reporter sent.How did you verify your code works?
Three tests in
packages/llm/test/cache-policy.test.ts, all failing before the change and passing after: an assistant turn ending in reasoning steps back,{ tail: 1 }steps back past a reasoning-only turn, and a hint is never written onto a part that drops it.bun testinpackages/llmis 301 pass / 30 skip / 0 fail, andtsgo --noEmitplusoxlintare clean.Screenshots / recordings
Not a UI change.
Checklist