-
-
Notifications
You must be signed in to change notification settings - Fork 233
fix(anthropic): resolve issue with tool result caching #485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(anthropic): resolve issue with tool result caching #485
Conversation
5039197 to
f48bae1
Compare
4bb94bb to
c169f83
Compare
Apply tool_result_cache_type only to the last tool result message across all messages instead of applying it to each tool result during creation. This prevents cache accumulation when there are multiple tool call rounds.
c169f83 to
5084b26
Compare
Preview deployments for prism ⚡️
Commit: Deployment ID: Static site name: |
|
@ChrisB-TL can you take a look at this? |
|
I've been running this patch for the past week with pretty good results. But it wouldn't hurt for someone to do a once-over. |
|
@ChrisB-TL can you take a look at this? |
|
Will this not result in missing the last cache on subsequent calls, as the breakpoint is no longer there? I.e. you'll miss the cache until the last call, which will undermine the point of it? Anthropic does have a limit of four cache break points, so the current implementation will break eventually for chains with multiple tool calls. |
Actually, possibly not. From the docs: Would you be able to test out with real requests to confirm, and add a test that uses recorded fixtures? |
Summary
Changes
Text::handleToolCalls()andStream::addMessagesToRequest()MessageMap::map()to identify and cache only the last tool result messageTest plan
ToolResultCachingTest.phpwith 3 test cases