Skip to content

Show Claude /compact in the chat and reset the context ring - #802

Open
and-human wants to merge 1 commit into
zeronsh:mainfrom
and-human:claude-compact-feedback
Open

and-human wants to merge 1 commit into
zeronsh:mainfrom
and-human:claude-compact-feedback

Conversation

@and-human

@and-human and-human commented Oct 5, 2026 •

Copy link
Copy Markdown

Fixes #801.

Problem

In a Claude Code chat, /compact compacts the session, but Zeron shows nothing. The turn ends with no transcript content, and the context ring keeps the old size until the next reply. The Claude normalizer drops the compact_boundary system frame. A /compact turn also has no assistant frame, which is the only place the Claude adapter sets ContextUsage.tokens.

Change

On system / compact_boundary, the Claude normalizer now emits:

  • TextDelta("Context compacted."), then AssistantMessageCompleted, so the note is its own message and any text after an auto-compaction starts fresh. This matches Codex's contextCompaction note.
  • ContextUsage { tokens: compact_metadata.post_tokens } when the CLI sends it. This matches Pi's compaction_end.

No protocol or UI change. wire.rs gains an optional compact_metadata.post_tokens field.

Testing

  • New unit test compact_boundary_shows_a_note_and_resets_context, using frames captured from Claude Code 2.1.289. It also covers older CLIs that send no post_tokens: the note still shows and the ring is left alone.
  • cargo test -p zeron-harness --lib and --test claude pass.
  • Live check: a throwaway test, not included in this PR, sent /compact through ClaudeHarness::run to the real CLI on a resumed session. It produced TextDelta "Context compacted." → AssistantMessageCompleted → ContextUsage { tokens: Some(1266) } → Done Completed.

#800 also touches claude/normalize.rs. This change sits in the Frame::System arm, so any conflict should be small.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

The Claude adapter dropped the compact_boundary system frame, so a /compact
turn ended with no transcript content and the ring kept the pre-compaction
size until the next reply. Emit a "Context compacted." note (as Codex does)
and ContextUsage from post_tokens (as Pi does).

Fixes zeronsh#801
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Claude harness: /compact succeeds but the chat shows nothing and the context ring stays stale

1 participant