Repository navigation
Stable prompt prefix for agents (fix for #16877): approach and split plan #17481
Shabonasar
started this conversation in
Feature Requests & Suggestions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Asking for approval of the approach before any further review: the fix for the prompt-cache regression in #16877 and for the other cache breakers below, designed and measured in #17102. The regression itself is one row of the table; the rest of the series removes the others.
Problem
Provider prompt caches (Anthropic, Bedrock, OpenAI, OpenRouter, vLLM/SGLang prefix caching) reuse a request only up to its first changed byte. Agent requests change early bytes on almost every turn, so the whole prompt is processed again:
tools, reorderedApproach
<context_update>in the user message.call_tooldispatcher.Changes to what the model sees sit behind
endpoints.agents.promptCache.stableContext(defaultfalse). Fixes that only make the restored history equal to the live one need no setting.Result
Uncached prompt tokens over three scenarios (plain chat, tools toggled, compaction): Anthropic -58%, OpenAI -61%, Kimi -45%, GLM -39%, self-hosted vLLM -27%. Plain chat goes from 0% cached to 80-88%. Details and the kit to repeat: #17102.
Plan
The open PRs are already reduced to these steps; each keeps its regression tests, full test matrices are in the measurement kit. Some of them are independent and can be reviewed in any order; the others build on them, which is why they form a series. One at a time is fine.
mainmaindevcall_tooldispatchermain; #17146dev, needs step 1Based directly on
main/dev: steps 1, 2, 3, 6 and LibreChat-AI/agents#614; step 6 is a no-op until step 1 is released. Ready-made builds of the whole series:integration/prompt-cachein both forks (see #17102).Questions
All reactions