Repository navigation
Tool-result pruner silently truncates without marker; compaction never fires at default minContextRatio; no heredoc protection in pwsh tool #8153
Replies: 2 comments
|
A correction and an addition, checked against There is a marker in 0.2.0-rc.2. There is no recency exemption, which causes a re-read loop. Suggestion: exempt the N most recent tool results, or any result produced in the current step/turn, from pruning. That keeps the savings on old results and ends the loop. (Workaround: keep each read under |
|
A second ask on the pruner, with an implementation behind it: put an informative notice at the HEAD of a pruned result, not only a bare marker in the middle. Why the position matters. In 0.2.0-rc.2 the only evidence of a prune is What we run instead. A drop-in replacement for the The mid marker then names its own range (
The ask: emit a head notice of this kind from the shipped pruner (provenance from the |
Uh oh!
There was an error while loading. Please reload this page.
Tool-result pruner silently removes output middles without any marker; compaction never fires at default minContextRatio
Environment
cordis-cc(standard coding agent)Bug 1 — Tool-result pruner silently truncates without marking the cut
Config (from the default preset's
compaction-tool-result-pruner):What happens: any tool result over 8,192 characters is silently pruned to the first 4,096 + last 1,024 characters. The middle — up to 3,000+ characters — is removed with no marker, no ellipsis, no indication that anything was cut. The result looks like a continuous (but wrong) output.
Why this is dangerous: the model reads the pruned result as if it were the complete output. It cannot know the middle is missing. In our session, this caused:
Reproduction: run any command that produces >8,192 characters of output (e.g., a recursive directory listing, a Python script with 50+ lines of output). The model sees ~5,120 chars (4,096 head + 1,024 tail) and fills in the gap from context.
Suggested fix: insert a visible marker between the head and tail, e.g.:
This costs 1 line but tells the model the output is incomplete, preventing confabulation.
Bug 2 — compaction-basic minContextRatio 0.97 means compaction never runs
Config (code default, no preset override):
What happens: compaction only fires when the session reaches 97% of the model's context window. In practice, this means compaction never runs for most sessions — the tool-result pruner keeps individual results short enough that the context grows slowly, and the model finishes its task before reaching 97%.
Why this is dangerous: pruned tool results (from Bug 1) accumulate unboundedly in the context. Each one is a head+tail fragment that the model partially remembers and partially infers. Over hundreds of tool calls, the context becomes a collage of fragments that the model can't accurately attribute — leading to the model making claims about "what it saw" that don't match any real output.
Suggested fix: lower the default
minContextRatioto something like 0.80, or document prominently that the 0.97 default means "compaction will likely never fire."Bug 3 — PowerShell tool doesn't protect against heredocs/here-strings
What happens: the
pwshtool passes commands directly to PowerShell without checking for here-string (@'...'@) or heredoc (<<EOF) patterns. On Windows, PowerShell here-strings can contain arbitrary content including:Evidence: four independent traps documented and reproduced across multiple sessions on Windows 11 (details in the session tapes and the operator's memory notes). The machine-wide rule (in
AGENTS.md/CLAUDE.md) forbids heredocs for this reason.Existing protection: the project provides
no_heredoc.py(a PreToolUse blocker) andnop hook run --policy block(a heredoc detector). Both are registered in~/.claude/settings.jsonand work in Claude Code sessions.The gap: the default DSH preset does not mount the
dsh-hooks-claude-codebridge, so these hooks never fire in DSH sessions. A heredoc in a DSHpwshtool call executes without any check.Suggested fix (any of):
dsh-hooks-claude-codein the default preset withconfigPathpointing at~/.claude/settings.json(where the hooks are already registered)pwshtool itself (before execution), similar tokdp_precheckfor print interiorsWorkaround (applied)
All three were worked around in the operator's preset (
agent.cordis.yml):thresholdChars: 65536(up from 8,192)minContextRatio: 0.80(down from 0.97)hooks-claude-codebridge mounted withconfigPath: C:/Users/user/.claude/settings.jsonImpact
Without these fixes, long-running sessions on the default preset will: (1) silently lose the middle of long tool outputs, (2) accumulate pruned fragments that look like real data, and (3) execute heredocs that may corrupt file content — all three of which cause the model to produce confidently wrong results that are indistinguishable from hallucination.
All reactions