test(prompt-budget): lock cache-prefix byte budget#1320
Merged
Conversation
Every byte of the system prompt and tool spec list ships in every request — paid at full miss price the first time and ~10% on every subsequent cache hit. Recent PRs have grown both without anyone tracking the cumulative cost. Lock the current values: - CODE_SYSTEM_PROMPT.length ≤ 24_500 bytes - code-mode tool spec list ≤ 40_000 bytes - no single tool description > 8 KiB A failing assertion forces the PR author to either compress an equivalent section or raise the budget explicitly with a justification in the commit message — visible in code review.
This was referenced May 19, 2026
Merged
esengine
added a commit
that referenced
this pull request
May 19, 2026
…st) (#1323) The system prompt was 24,387 bytes (≈ 6,100 tokens) — much of it overlapping with the tool descriptions sitting right next to it in the cache prefix. Sections like "When to propose a plan", "When to ask the user to pick", and "When to track multi-step intent" each recited rules that the tool's own description already carried. Aggressive dedup pass: - Drop the redundant "you have these filesystem tools" opening sentence — the API ships the tool list separately. - Merge the three independent submit_plan / ask_choice / todo_write sections into one short "Picking the right tool" block. - Fold "Exploration", "Trust what you already know", and "When the user wants to switch project" into shorter equivalents — same rules, no narrative. - Collapse the foreground/background section. The full how-to lives in the run_command / run_background tool descriptions; the prompt only needs the picking rule. - Compress the audit-mode rails (#610) prose around the six rails themselves. Every rail's load-bearing phrase is preserved verbatim so tests/code-prompt.test.ts still asserts on them. Result: 24,387 → 11,956 bytes (-51%, ≈ 3,100 tokens per request). Combined with PR #1320 / #1321 the cache-prefix tax per request is now ~16k tokens instead of ~36k. Behaviour unchanged — every rail / gate / mode constraint is still asserted by the existing prompt tests. Co-authored-by: reasonix <reasonix@deepseek.com>
This was referenced May 19, 2026
ChasLui
pushed a commit
to ChasLui/DeepSeek-Reasonix
that referenced
this pull request
May 23, 2026
Every byte of the system prompt and tool spec list ships in every request — paid at full miss price the first time and ~10% on every subsequent cache hit. Recent PRs have grown both without anyone tracking the cumulative cost. Lock the current values: - CODE_SYSTEM_PROMPT.length ≤ 24_500 bytes - code-mode tool spec list ≤ 40_000 bytes - no single tool description > 8 KiB A failing assertion forces the PR author to either compress an equivalent section or raise the budget explicitly with a justification in the commit message — visible in code review. Co-authored-by: reasonix <reasonix@deepseek.com>
ChasLui
pushed a commit
to ChasLui/DeepSeek-Reasonix
that referenced
this pull request
May 23, 2026
…st) (esengine#1323) The system prompt was 24,387 bytes (≈ 6,100 tokens) — much of it overlapping with the tool descriptions sitting right next to it in the cache prefix. Sections like "When to propose a plan", "When to ask the user to pick", and "When to track multi-step intent" each recited rules that the tool's own description already carried. Aggressive dedup pass: - Drop the redundant "you have these filesystem tools" opening sentence — the API ships the tool list separately. - Merge the three independent submit_plan / ask_choice / todo_write sections into one short "Picking the right tool" block. - Fold "Exploration", "Trust what you already know", and "When the user wants to switch project" into shorter equivalents — same rules, no narrative. - Collapse the foreground/background section. The full how-to lives in the run_command / run_background tool descriptions; the prompt only needs the picking rule. - Compress the audit-mode rails (esengine#610) prose around the six rails themselves. Every rail's load-bearing phrase is preserved verbatim so tests/code-prompt.test.ts still asserts on them. Result: 24,387 → 11,956 bytes (-51%, ≈ 3,100 tokens per request). Combined with PR esengine#1320 / esengine#1321 the cache-prefix tax per request is now ~16k tokens instead of ~36k. Behaviour unchanged — every rail / gate / mode constraint is still asserted by the existing prompt tests. Co-authored-by: reasonix <reasonix@deepseek.com>
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.
Summary
Every byte of the system prompt and tool spec list ships in every request to DeepSeek — paid at full miss price the first time, ~10% on every subsequent cache hit. Recent PRs have grown both without anyone tracking the cumulative cost, and several users have reported higher token consumption since 0.46.0.
This PR adds
tests/prompt-budget.test.ts, a regression net that locks the current values:CODE_SYSTEM_PROMPT.length≤ 24,500 bytes (currently 24,387 — under cap)codeSystemPrompt(root)with built-in skills ≤ 26,500 bytes (currently 26,337 — under cap)A failing assertion forces the PR author to either compress an equivalent section, or raise the budget explicitly in the commit message — visible in code review.
This is PR #1 of a four-PR token-optimization series:
read_fileoutline threshold from 512 KiB → 64 KiB (recover the 0.46.0 regression)Test plan
npm run verify— all 231 test files / 3,241 tests passtests/prompt-budget.test.ts— 4 tests, all passnpm run lintcleannpm run typecheckclean