Fix extension ctx.compact to use auto-compaction lifecycle#2
Fix extension ctx.compact to use auto-compaction lifecycle#2
Conversation
There was a problem hiding this comment.
💡 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); |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
ctx.compact()emitauto_compaction_start/auto_compaction_endeventsagent.continue()Why
compact-level(and any extension usingctx.compact()from event/command context) bypassed the interactive auto-compaction lifecycle, so:Tests
should emit auto-compaction lifecycle and resume queue for extension ctx.compact()toagent-session-auto-compaction-queue.test.tspackages/coding-agent:npm test -- agent-session-auto-compaction-queue.test.ts