Skip to content

Emit a concise post‑Compact context message after manual Op::Compact #5366

@roadrunner21

Description

@roadrunner21

What feature would you like to see?

Problem: After running manual compaction (Op::Compact), it is unclear what the next turn will "know."
Operators cannot easily confirm that prior user messages were aggregated and which summary the model will rely on.

Proposal: After a manual Op::Compact, emit a single concise AgentMessage that states what the next turn’s context includes. Do not emit this for inline auto-compaction (auto-compact-N) to avoid noise during automatic retries.

Suggested default message: Compact complete. Next turn context includes prior user messages and the following summary: {summary}

Optional richer message: Compact complete. Next turn context includes: prior user messages (trimmed); summary: {summary}; env: cwd={cwd}, approval={approval_policy}, sandbox={sandbox_policy}

Why this helps: Makes post-compaction behavior transparent, reduces confusion about context versus retained knowledge, and speeds up troubleshooting.

Additional information

Implementation notes: Use the compaction summary that already exists (summary_text) and emit the message immediately after history rewrite. Keep the existing "Compact task completed" message and insert the new message right before it. Suppress for inline auto-compaction by checking the sub-id prefix "auto-compact-". EnvironmentContext and user instructions are re-inserted automatically.

Non-goals: Do not change compaction semantics or bridge content; this is observability only. Do not emit the full bridge by default.

Acceptance criteria: After manual Op::Compact, exactly one informative AgentMessage is emitted with the compact template, including the compaction summary. No message is emitted for inline auto-compaction. No change to compaction logic or final model context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    context-managementIssues related to context management (including compaction)enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions