[BUG] Context [Execution] truncated — Capsule Preview diff bloats prompt to 70KB+
Environment
- Evolver version: 1.86.0
- Node.js: v22.22.1
- Platform: Linux x64
Problem
The gep_prompt_Cycle_*.txt files generated by dispatch.js consistently have Context [Execution]: truncated to just ...[TRUNCATED]... (39 bytes). This means the subagent receives NO execution instructions.
Root Cause
The Context [Injection Hint] section is bloated to ~54KB due to:
- Capsule Preview
difffield — each capsule embeds a full git diff (~8.5KB), 3 capsules = 25KB of diffs not useful for strategy decisions - Gene Preview
learning_historyandanti_patternsfields — verbose text - Total prompt reaches 77KB, exceeding dispatch.js internal size limit → Execution truncated
Evidence
Context [Injection Hint]:: 54,850 bytes (74% of total)
Context [Execution]:: 39 bytes ← TRUNCATED
Total: 76,815 bytes
After stripping verbose fields: 35,971 bytes (53% reduction).
Suggested Fix
- Strip
difffrom Capsule Preview (or make opt-in) - Strip
learning_history/anti_patternsfrom Gene Preview - Or: increase/remove internal prompt size limit
Workaround
Post-processing script strips verbose fields. Reduces tokens but cannot restore already-truncated Execution section.
Thanks for the byte-accurate breakdown, @zhuyankarl — having the Hint vs Execution split called out in bytes pointed straight at the truncator math, and your strip-and-remeasure (54KB → 36KB, ~53% reduction) made the root cause unambiguous.
Confirmed in src/gep/prompt.js. There are two coupled defects here:
-
formatAssetPreviewcurrently inlines every field of every Capsule / Gene entry, including:capsule.diff(~8.5KB each)compact_diffexecution_tracegene.learning_historygene.evolution_historygene.anti_patternsfailed_attempts
With three capsules and a couple of genes,
Context [Injection Hint]alone can exceed ~54KB. -
The truncator computes allowed execution bytes with:
Math.max(0, maxChars - prefix.length - 100)
Once prefix.length exceeds maxChars (default 50_000), the expression goes negative, Math.max clamps to 0, and Context [Execution] is truncated to an empty string — exactly matching the 39-byte header + ...[TRUNCATED]... output you observed.
Internal patch is already in flight as a two-layer fix:
-
Introduce
PREVIEW_STRIP_FIELDSbeforeformatAssetPreview()runs, removing the bloated fields from preview rendering while preserving:- ids
- summaries
- scores
The resulting byte reduction matches your measurements.
-
Add an execution-context floor (
EXEC_FLOOR = 8000) in the truncator.If the prefix still exceeds the limit, the prefix is truncated instead of Execution. That's the safer trade-off:
- losing reference context is recoverable
- losing execution instructions breaks the cycle entirely
Regression coverage was added in test/prompt.test.js:
- a 9KB
HEAVY_DIFFmarker that must never appear in the rendered prompt - an
EXEC_MARKERthat must always survive truncation
Verified by surgically reverting only the src changes — all new assertions fail with the expected regression messages.
We’ll ship the patch through the normal release pipeline shortly and close this issue once the public mirror lands.
Fixed and shipped in v1.87.4 (@evomap/[email protected], latest on npm).
Two-layer fix in src/gep/prompt.js, along exactly the lines you measured:
PREVIEW_STRIP_FIELDSremoves the bloated preview fields (capsule.diff,compact_diff,execution_trace,gene.learning_history,gene.evolution_history,gene.anti_patterns,failed_attempts) beforeformatAssetPreview()runs, while preserving ids / summaries / scores.- An execution-context floor (
EXEC_FLOOR = 8000): if the prefix still exceeds the budget, the prefix is truncated instead of zeroing outContext [Execution].
Verified against the published 1.87.4 binary — the #552 regression suite runs green on the shipped prompt.js:
# test/prompt.test.js (public issue #552)
ok - keeps Context [Execution] non-empty under heavy preview bloat (#552 regression)
ok - floor protection truncates the prefix, not Execution, when maxChars is tight
# tests 11 # pass 11 # fail 0
Please upgrade and confirm Context [Execution] is no longer ...[TRUNCATED].... Closing as fixed — reopen if it recurs. Thanks @zhuyankarl for the byte-accurate breakdown; the Hint-vs-Execution split pointed straight at the truncator math.