fix(core): repair truncation-severed spotlight wrapper in compaction prompt#6613
Merged
Conversation
bug-ops
enabled auto-merge (squash)
July 20, 2026 20:53
bug-ops
force-pushed
the
fix/6584-compaction-input-sanitizer
branch
from
July 20, 2026 20:54
5cd53ba to
864ad8e
Compare
…prompt build_compression_prompt truncates each message to 500 chars before handing it to the compression LLM. Untrusted tool-result content is already spotlight-wrapped (<tool-output>/<external-data>) at write time by sanitize_tool_output, but the blind truncation could sever the wrapper's closing tag for long content, leaving an opened-but-never- closed spotlight block in the prompt. A single message can bundle multiple concatenated wrappers of different kinds from a multi-tool- call turn, so the repair checks both wrapper kinds independently by open/close tag count rather than gating on the message's aggregate trust level.
bug-ops
force-pushed
the
fix/6584-compaction-input-sanitizer
branch
from
July 20, 2026 20:56
864ad8e to
e5bc0dd
Compare
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
build_compression_prompt(crates/zeph-core/src/agent/tool_execution/focus.rs) truncates each message to 500 chars before handing it to the compression LLM. Untrusted tool-result content is already spotlight-wrapped (<tool-output>/<external-data>) at write time bysanitize_tool_output— the sole sanitization point for tool output — so it is not raw/unfiltered as originally assumed by the issue.tier_loop.rsflattens every tool result of a turn into one message;build_tool_output_sourcemaps different tools to different wrapper kinds). The fix checks both wrapper kinds independently by open/close tag count — not by presence, and not gated on the message's aggregate trust level — so a mixed-kind batch gets repaired correctly regardless of which wrapper was severed.Closes #6584
Test plan
cargo +nightly fmt --checkcargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warningscargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins(14992 passed)RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features "desktop,ide,server,chat,pdf,scheduler"gitleaks protect --staged --no-banner --redactrepair_truncated_spotlight_wrapper: severed<tool-output>close, severed<external-data>close, mixed-batch with one balanced + one severed wrapper,trust_levelNone/Some(0)no-op, intact sub-500-char wrapper not double-appended