refactor(prompt): compress codeSystemPrompt (-51%, ~3.1k tokens/request)#1323
Merged
Conversation
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.
This was referenced May 19, 2026
Merged
This was referenced May 19, 2026
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
The system prompt had grown to 24,387 bytes (≈ 6,100 tokens) — every byte paid on every request. Much of it overlapped with tool descriptions sitting right next to it in the cache prefix: "When to propose a plan", "When to ask the user to pick", and "When to track multi-step intent" each recited rules the tool's own description already carried.
Aggressive dedup pass:
tests/code-prompt.test.tsstill asserts on them.Result: 24,387 → 11,956 bytes (-51%, ≈ 3,100 tokens per request).
Combined with the regression net (#1320) and the tool-description compression (#1321), the cache-prefix tax is now roughly 16k tokens per request instead of ~36k.
What is preserved
Every test-asserted phrase:
Identity is fixed by this prompt,SOUL.md,not a sub-profileAuto-preview is for locating, not auditing,range:"A-B"runtime behavior, current architectural state,whether a plan doc is still accurateFlag → consumer trace,parallelSafe?: booleanFor inventory claims,grep the flag — don't enumerate from memoryNo fabricated percentages,40-60% tokensSchema cost is real,tighten prompt / existing toolMEMORY.md is part of the design spaceUser-facing ≠ model-facing ≠ library-facing,library exports (src/index.ts),Treating a library export as "dead code"# Project .gitignoreand# User System Appendblocks still compose after the base in the same order — the cache prefix shape is unchanged.This is PR #3 of a four-PR token-optimization series.
Test plan
npm run verify— all 230 test files / 3,237 tests passtests/code-prompt.test.ts— 26 tests, all green (every load-bearing phrase still matches)npm run lintcleannpm run typecheckclean