fix: skip Anthropic cache control for OAuth#18311
Open
jorgitin02 wants to merge 2 commits intoanomalyco:devfrom
Open
fix: skip Anthropic cache control for OAuth#18311jorgitin02 wants to merge 2 commits intoanomalyco:devfrom
jorgitin02 wants to merge 2 commits intoanomalyco:devfrom
Conversation
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
The actual root cause is missing A reference implementation is available at clewdr@a4e5df3. |
Contributor
Author
|
Updated this PR. It now does three things for Anthropic OAuth:
Local verification:
The earlier failing e2e checks were in the app workspace-routing suite, not this provider/session codepath, so those need to be re-evaluated on the refreshed branch checks. |
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 #17910
Type of change
What does this PR do?
Anthropic OAuth requests were still going through the normal Anthropic cache-control path, which adds
cache_control: { type: "ephemeral" }to recent prompt messages. That metadata is rejected on the OAuth path and causes the request to fail.This changes
ProviderTransform.message()to skip Anthropic cache-control injection when the resolved auth type isoauth, and updatesLLM.stream()to pass the resolved auth type into that transform. I also added regression coverage at two levels: one focused transform test for the cache-control behavior, and oneLLM.stream()test that exercises the Anthropic messages request path with OAuth auth present.The fix is narrow on purpose: it only changes Anthropic when auth is OAuth, and leaves the existing non-OAuth Anthropic caching behavior in place.
How did you verify your code works?
bun test test/session/llm.test.tsbun test test/provider/transform.test.tsbun typecheckbun testScreenshots / recordings
N/A
Checklist