Auto-reply: unify reply lifecycle across stop, rotation, and restart#61267
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9bb73f855f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Greptile SummaryThis PR fixes two reply lifecycle bugs: preflight compaction now runs under a registered Confidence Score: 5/5Safe to merge; the prior registry-cleanup concern is fully resolved and no new P0/P1 issues were found. The previously flagged stale ACTIVE_EMBEDDED_RUNS entry after /stop during preflight/running phases is fixed: complete() in both runner finally blocks always calls clearRegistryHandle(), which is idempotent. fail()/abortByUser() guard against double-setting result. All remaining observations are P2 style (e.g., the restart message string is defined as a helper function in agent-runner-execution.ts but inlined as a literal in agent-runner.ts — both are identical and functionally correct). No correctness, data-loss, or security issues remain. No files require special attention. Greploops — Automatically fix all review issues by running Reviews (2): Last reviewed commit: "Auto-reply: clarify ownership handoff co..." | Re-trigger Greptile |
|
Addressed the stale abort-handle leak in The fix keeps queued aborts immediate, but clears the stable Added regression coverage in |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe354df57f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 165485ee2c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5271b49eea
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Implementation is complete and the review threads are addressed, but the PR is currently blocked by GitHub state rather than by an outstanding code issue. What landed:
Local validation on the implemented tree:
Current blockers:
So the code work is done and locally validated, but this is not honestly merge-ready until the PR is rebased and GitHub runs a clean current-head |
33b6e76 to
9cd28f1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9cd28f194e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e97d8281a2
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf65843787
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a607c7cbc2
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e02bcc577
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cba6a64e12
ℹ️ 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".
|
Final report on current head What changed after the earlier round:
Validation run on this head:
Review / comments status:
Current GitHub status:
What I could not verify locally:
Given the current head and the resolved review threads, I consider the code changes ready. The remaining blockers are the unrelated local |
ce9c8f0 to
79407d9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79407d9449
ℹ️ 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".
| if (restartLifecycleError instanceof CommandLaneClearedError) { | ||
| params.replyOperation?.fail("command_lane_cleared", restartLifecycleError); | ||
| return { | ||
| kind: "final", | ||
| payload: { | ||
| text: buildRestartLifecycleReplyText(), | ||
| }, |
There was a problem hiding this comment.
Avoid treating lane-clear errors as restart failures
CommandLaneClearedError is not restart-specific: queue.mode: "interrupt" clears the session lane in get-reply-run.ts, and clearCommandLane(...) emits this same error type for normal supersession. Mapping every CommandLaneClearedError to buildRestartLifecycleReplyText() here causes interrupted turns to incorrectly tell users the gateway is restarting, which is misleading and obscures the actual queue/interrupt behavior.
Useful? React with 👍 / 👎.
2dd6fb6 to
f2cb3ef
Compare
|
Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test\n- Land commit: 3dae6d8\n- Merge commit: 3f68402\n\nThanks @dutifulbob! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3dae6d8289
ℹ️ 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".
| if (error instanceof CommandLaneClearedError) { | ||
| replyOperation.fail("command_lane_cleared", error); | ||
| return finalizeWithFollowup( | ||
| { text: "⚠️ Gateway is restarting. Please wait a few seconds and try again." }, |
There was a problem hiding this comment.
Don't report lane-clear interrupts as gateway restarts
CommandLaneClearedError is also thrown for normal supersession when queue.mode: "interrupt" clears a session lane (clearCommandLane(...) in get-reply-run.ts), not just during restart/drain. Treating every CommandLaneClearedError as a restart here causes interrupted turns (for example, a newer same-session message preempting preflight/memory work) to return the misleading "Gateway is restarting" reply and misclassify the failure reason, which obscures the real queue behavior.
Useful? React with 👍 / 👎.
Supersedes #61225.
Summary
sessionIdlookups, and separate abort paths./stopcould miss some reply paths, and gateway restart aborts could be misclassified as user aborts.sessionKey-keyed reply lifecycle registry, threads oneReplyOperationthrough preflight compaction, memory flush, embedded runs, and CLI-backed runs, and tightens the overlap / restart handling around that lifecycle.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
sessionId, which can rotate during compaction and memory flush, while CLI, embedded, and restart abort paths did not share one lifecycle owner./stop, rotated-session overlap, CLI abort parity, restart abort classification, or post-wait system-event re-drain.Regression Test Plan (if applicable)
src/auto-reply/reply/reply-run-registry.test.tssrc/auto-reply/reply/get-reply-run.media-only.test.tssrc/auto-reply/reply/agent-runner-execution.test.tssrc/auto-reply/reply/agent-runner.misc.runreplyagent.test.tssrc/agents/pi-embedded-runner/runs.test.tssrc/agents/cli-runner.spawn.test.ts/stopcan cancel preflight and CLI-backed reply runs, and gateway restart preserves the visible restart notice.User-visible / Behavior Changes
/stopcan cancel reply turns that are still in preflight compaction./stopnow cancels CLI-backed reply turns too./newand/resetturns do not prepend the standaloneNew session startednotice.Diagram (if applicable)
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
/stop, or trigger a gateway restart/drain path.Expected
/stophits the real active run, and restart keeps the visible restart notice.Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
pnpm test src/auto-reply/reply/reply-run-registry.test.ts src/auto-reply/reply/agent-runner-execution.test.ts src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts src/auto-reply/reply/get-reply-run.media-only.test.ts src/agents/pi-embedded-runner/runs.test.ts src/agents/cli-runner.spawn.test.ts src/auto-reply/reply/abort.test.ts src/auto-reply/reply/followup-runner.test.tspnpm exec oxlint src/auto-reply/reply/reply-run-registry.ts src/auto-reply/reply/reply-run-registry.test.ts src/auto-reply/reply/agent-runner-execution.ts src/auto-reply/reply/agent-runner-execution.test.ts src/auto-reply/reply/agent-runner.ts src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts src/auto-reply/reply/get-reply-run.ts src/auto-reply/reply/get-reply-run.media-only.test.tspnpm exec oxfmt --check src/auto-reply/reply/reply-run-registry.ts src/auto-reply/reply/reply-run-registry.test.ts src/auto-reply/reply/agent-runner-execution.ts src/auto-reply/reply/agent-runner-execution.test.ts src/auto-reply/reply/agent-runner.ts src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts src/auto-reply/reply/get-reply-run.ts src/auto-reply/reply/get-reply-run.media-only.test.ts/stopsessionIdhandoffReview Conversations
Compatibility / Migration
Yes)No)No)Risks and Mitigations
sessionKey, keepssessionIdas mutable metadata only, and is covered by wait/rotate/abort/restart regression tests.bash-toolstype failures.src/agents/bash-tools.exec.tsandsrc/agents/bash-tools.process.ts, outside this PR's write set.