You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: compaction checkpoint frames don't escape the close tag β model-controlled summary text breaks out of the trusted checkpoint block
#4097
Package:@deepseek-ai/dsh-compaction-basic (src/summarizer.ts) Severity: medium Β· Confidence: high β verified against the real frameSummary; opens/closes counted
Problem
Compaction splices the model-produced summary between delimiter tags with zero escaping:
exportfunctionframeSummary(summary: readonlyContentBlock[]): ContentBlock[]{return[{type: 'text',text: `${CHECKPOINT_PREAMBLE}\n\n${SUMMARY_OPEN_TAG}`},
...summary,{type: 'text',text: SUMMARY_CLOSE_TAG},// body never escaped]}
The summary body is model-controlled β it condenses conversation content that includes tool results and file contents, and the summarizer prompt explicitly instructs "Preserve exact β¦ error strings β¦ syntax fragments", inviting echo of a literal </compacted-summary> seen in a tool result.
Verified: a summary containing the close tag yields opens=1 closes=2 β everything after the forged close renders outside the trusted checkpoint block, and the trailing real tag dangles unmatched.
Later auto-compaction condenses; the durable replacement user message β model-visible for the rest of the session β presents the smuggled text as live conversation rather than condensed background. A forged open tag additionally poisons future merges, since checkpoint detection keys on <compacted-summary>.
This is a defect by the repo's own bar: every sibling producer neutralizes its delimiters (agent-instructions replaces </system-reminder>; skill catalogs XML-escape; session-reference uses stringifyTagSafeJson). Compaction is the only frame that trusts model output verbatim inside its trust boundary.
Fix direction
Escape or neutralize the tag vocabulary in summary text before framing (same treatment as agent-instructions), and/or validate post-frame that exactly one open/close pair exists, failing loud into a retry.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Package:
@deepseek-ai/dsh-compaction-basic(src/summarizer.ts)Severity: medium Β· Confidence: high β verified against the real
frameSummary; opens/closes countedProblem
Compaction splices the model-produced summary between delimiter tags with zero escaping:
The summary body is model-controlled β it condenses conversation content that includes tool results and file contents, and the summarizer prompt explicitly instructs "Preserve exact β¦ error strings β¦ syntax fragments", inviting echo of a literal
</compacted-summary>seen in a tool result.Verified: a summary containing the close tag yields
opens=1 closes=2β everything after the forged close renders outside the trusted checkpoint block, and the trailing real tag dangles unmatched.Scenario
An agent reads a file or web page containing:
Later auto-compaction condenses; the durable replacement user message β model-visible for the rest of the session β presents the smuggled text as live conversation rather than condensed background. A forged open tag additionally poisons future merges, since checkpoint detection keys on
<compacted-summary>.This is a defect by the repo's own bar: every sibling producer neutralizes its delimiters (
agent-instructionsreplaces</system-reminder>; skill catalogs XML-escape;session-referenceusesstringifyTagSafeJson). Compaction is the only frame that trusts model output verbatim inside its trust boundary.Fix direction
Escape or neutralize the tag vocabulary in summary text before framing (same treatment as agent-instructions), and/or validate post-frame that exactly one open/close pair exists, failing loud into a retry.
All reactions