Skip to content

Fix extension ctx.compact to use auto-compaction lifecycle#2

Open
tmustier wants to merge 1 commit intomainfrom
fix/extension-compact-lifecycle
Open

Fix extension ctx.compact to use auto-compaction lifecycle#2
tmustier wants to merge 1 commit intomainfrom
fix/extension-compact-lifecycle

Conversation

@tmustier
Copy link
Owner

@tmustier tmustier commented Mar 3, 2026

Summary

  • make extension-runner ctx.compact() emit auto_compaction_start / auto_compaction_end events
  • after successful extension-triggered compaction, resume queued agent messages via agent.continue()
  • preserve cancel/error semantics by emitting aborted/error end events

Why

compact-level (and any extension using ctx.compact() from event/command context) bypassed the interactive auto-compaction lifecycle, so:

  • UI did not match native auto-compaction behavior
  • queued messages could remain stuck after compaction

Tests

  • added should emit auto-compaction lifecycle and resume queue for extension ctx.compact() to agent-session-auto-compaction-queue.test.ts
  • ran in packages/coding-agent:
    • npm test -- agent-session-auto-compaction-queue.test.ts

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc6f91fabd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}, 100);
}

options?.onComplete?.(result);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent duplicate compaction end events on callback failure

If options.onComplete throws, this try block has already emitted a successful auto_compaction_end, then the catch emits a second end event marked as failure/aborted. In interactive mode this can produce conflicting UI/state transitions for a single compaction (success followed by error) and can trigger end-of-compaction handlers twice. The completion callback should be isolated from lifecycle emission so extension callback bugs do not fabricate a second compaction outcome.

Useful? React with 👍 / 👎.

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.

1 participant