Repository navigation
fix(cli): hide internal compaction summaries and drafts in CLI history - #1790
Open
Plastic-time wants to merge 2 commits into
Open
Plastic-time wants to merge 2 commits into
Plastic-time wants to merge 2 commits into
Conversation
Align renderHistory (used by penguin session log and penguin chat --resume) and StreamRenderer (echoInput) with Web's stream-model on compaction records: - Skip [context_summary] and legacy <context_summary> context openings in renderHistory (and defensively in StreamRenderer when echoInput is enabled), while keeping ordinary user messages that mention [context_summary] mid-sentence. - Track compaction_begin..compaction_end per origin in renderHistory (resetting on session_meta for that origin) so internal compaction prompts, thoughts, tool calls, and draft summaries stay out of the transcript without parent and nested subagent spans interfering with one another.
Plastic-time
marked this pull request as ready for review
November 24, 2026 02:35
This branch has not been deployed
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.
What this changes
After a long conversation compacts,
penguin session logandpenguin chat --resumecurrently print the internal compaction summary as if the user typed it (> [context_summary]...) and leak the compaction turn's internal prompt, intermediate thoughts, tool calls, and[summary]draft into the conversation transcript.This change aligns
renderHistory(and adds the same defensive guard toStreamRenderer) inpackages/cli/src/render.tswith the Web App'spackages/web/src/lib/amsp/stream-model.tsandpackages/server/src/services/message-window.tsfor compaction records:[context_summary]and legacy<context_summary>context openings via a sharedisContextSummary(text)helper inrenderHistory(and defensively inStreamRenderer.renderNowwhenechoInputis enabled, so replayed/fed compaction openings are never echoed as user input or clearexpectedInput). Ordinary user messages that merely mention[context_summary]mid-sentence remain untouched.compaction_begin..compaction_endper origin (originKey) duringrenderHistoryso compaction-internalmodel_msgrecords (compaction prompt, thinking, tool calls/outputs, and[summary]draft) stay out of the transcript for both the parent session and nested subagents without interfering with one another. Asession_metafor an origin also clears its active compaction span in case a truncated history lackscompaction_end.Verification
437df9d01, verified on commit73286e960.packages/cli/test/render.test.tson baseline437df9d01):3 failed | 77 passed (80)— all three new tests failed becauserenderHistoryprinted[context_summary]/<context_summary>openings and compaction-internal messages, andStreamRendererwithechoInputechoed[context_summary]/<context_summary>.73286e960):1 passed (1)—80 passed (80).pnpm --filter @prismshadow/penguin-cli typecheck: passed (src/ifaces.json unchanged (283 interfaces, 766 types)).pnpm exec prettier --check packages/cli/src/render.ts packages/cli/test/render.test.ts changelog/unreleased/2026-11-23-cli-history-compaction.md changelog/unreleased/2026-11-23-cli-history-compaction.zh.md: passed.pnpm exec oxlint packages/cli/src/render.ts packages/cli/test/render.test.ts: passed (0 warnings and 0 errors).packages/cli/src/render.ts,packages/cli/test/render.test.ts, and the changelog pair. Open draft PRs#1550and#289also touchpackages/cli/src/render.tsfor unrelated refactors/features.pnpm exec vitest runinpackages/cli):42 passed (42)files,652 passed | 8 skipped (660)tests.Checklist
changelog/unreleased/—YYYY-MM-DD-<slug>.mdand its.zh.mdcounterpart, in the format changelog/README.md describes.packages/docs/content/). (N/A — aligns CLI history rendering with existing Web App and live CLI compaction rules.)