perf(prompt-caching): cache tool schemas without history loss - #37611
perf(prompt-caching): cache tool schemas without history loss#37611rodboev wants to merge 1 commit into
Conversation
28790e9 to
a0323b6
Compare
052bff1 to
f5ddc91
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for targeting a real prompt-cost gap. Current main still caches only api_messages at agent/conversation_loop.py:894-899, while agent/chat_completion_helpers.py:777-792 forwards agent.tools to the request.
Problems
- The current PR commit (
f5ddc911e10c) does not wire the new helper into that path: its onlyconversation_loop.pychange is an import, and itschat_completion_helpers.pychange only readsagent._tools_for_api. The complete PR diff contains no assignment to that attribute, soagent.toolsremains the transmitted list without a marker. - The new tests cover helper output but not request construction. They would not detect this missing invocation.
- The PR conflicts with main, and its
prompt_caching.pyhunk predates current_can_carry_markerfiltering atagent/prompt_caching.py:109-117; salvage should retain that newer protection.
Suggested changes
- Apply tool marking to a request-local tool list in the actual request-preparation path, reserve a breakpoint only when that list is sent, and add native-Anthropic plus OpenAI-compatible request-kwargs coverage.
Automated hermes-sweeper review.
f5ddc91 to
47b3e5f
Compare
107fff0 to
f562f52
Compare
|
Merged via #76032 — your commit was cherry-picked onto current main with authorship preserved (rebase merge), so it lands under your name:
Verified end-to-end before merge: budget invariant (<=4 markers) across adversarial message shapes, prefix stability across turns, byte-identical fallback behavior for non-native routes, and marker survival through the Anthropic wire conversion — plus 294 targeted tests green. Thanks for the contribution, and for the thorough rework after the sweeper round (the request-local plan + destination replanning design turned out very clean). |
Closes #20880
Summary
Validation
228 passed in 12.17s: cache plan, synchronous fallback, failover, MoA, policy, normal kwargs, and continuation compatibility tests.28 passed in 1.16s: direct and third-party Anthropic-wire fallback payloads, persistent MoA, and cache policy boundaries.Keeps the four-breakpoint budget from #27170 and incorporates @tbanetwork's current breakpoint-budget report.