Skip to content

Auto-reply: unify reply lifecycle across stop, rotation, and restart#61267

Merged
osolmaz merged 20 commits into
openclaw:mainfrom
osolmaz:codex/repro-session-stall-and-drain-bugs-2
Apr 5, 2026
Merged

Auto-reply: unify reply lifecycle across stop, rotation, and restart#61267
osolmaz merged 20 commits into
openclaw:mainfrom
osolmaz:codex/repro-session-stall-and-drain-bugs-2

Conversation

@dutifulbob

@dutifulbob dutifulbob commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Supersedes #61225.

Summary

  • Problem: reply lifecycle ownership was split across embedded-only handles, mutable sessionId lookups, and separate abort paths.
  • Why it matters: same-session turns could overlap after compaction or wait handoff, /stop could miss some reply paths, and gateway restart aborts could be misclassified as user aborts.
  • What changed: this PR introduces a sessionKey-keyed reply lifecycle registry, threads one ReplyOperation through preflight compaction, memory flush, embedded runs, and CLI-backed runs, and tightens the overlap / restart handling around that lifecycle.
  • What did NOT change: this is reply-only lifecycle cleanup; it does not replace the generic runtime lifecycle for unrelated non-reply work.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause (if applicable)

  • Root cause: active reply ownership was keyed in multiple places by sessionId, which can rotate during compaction and memory flush, while CLI, embedded, and restart abort paths did not share one lifecycle owner.
  • Missing detection / guardrail: we did not have regression coverage for preflight /stop, rotated-session overlap, CLI abort parity, restart abort classification, or post-wait system-event re-drain.
  • Contributing context (if known): queue-policy and busy-state checks mixed preloaded session state, reply-specific lifecycle state, and embedded-only compatibility state.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file:
    • src/auto-reply/reply/reply-run-registry.test.ts
    • src/auto-reply/reply/get-reply-run.media-only.test.ts
    • src/auto-reply/reply/agent-runner-execution.test.ts
    • src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts
    • src/agents/pi-embedded-runner/runs.test.ts
    • src/agents/cli-runner.spawn.test.ts
  • Scenario the test should lock in: same-session turns cannot overlap across session rotation or wait handoff, /stop can cancel preflight and CLI-backed reply runs, and gateway restart preserves the visible restart notice.
  • Why this is the smallest reliable guardrail: the bugs were orchestration races across runner boundaries, not isolated helper mistakes.
  • Existing test that already covers this (if any): N/A
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • /stop can cancel reply turns that are still in preflight compaction.
  • /stop now cancels CLI-backed reply turns too.
  • Same-session turns no longer bypass the active-run guard after session rotation or after a wait-for-idle handoff.
  • Gateway restart / drain interruptions return the visible restart notice instead of being silently dropped as user aborts.
  • Reply-producing /new and /reset turns do not prepend the standalone New session started notice.

Diagram (if applicable)

Before:
[new turn] -> [check stale sessionId state] -> [maybe run now] -> [overlap / wrong abort target]

After:
[new turn] -> [resolve sessionKey-owned active reply] -> [wait/interrupt] -> [recheck ownership] -> [single reply lifecycle]

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS local dev
  • Runtime/container: Node 22 / pnpm
  • Model/provider: mocked embedded + CLI runner seams
  • Integration/channel (if any): auto-reply orchestration
  • Relevant config (redacted): queued / interrupt paths exercised via targeted tests

Steps

  1. Start a same-session reply turn and hold it in preflight compaction, memory flush, or running state.
  2. Send a competing same-session turn, /stop, or trigger a gateway restart/drain path.
  3. Observe whether the new turn overlaps, whether the active run can be cancelled, and whether restart returns the correct visible reply.

Expected

  • One reply lifecycle owns the session at a time, /stop hits the real active run, and restart keeps the visible restart notice.

Actual

  • This PR matches the expected behavior in the targeted regression suite below.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
    • 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.ts
    • pnpm 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.ts
    • pnpm 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
  • Edge cases checked:
    • preflight /stop
    • CLI abort parity
    • rotated sessionId handoff
    • interrupt/wait ownership recheck
    • post-wait system-event re-drain
    • restart abort classification
  • What you did not verify:
    • live staging/production gateway restart over a real channel
    • end-to-end channel delivery of the restart notice outside the mocked test harness

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps:

Risks and Mitigations

  • Risk: reply lifecycle ownership now has one more central registry/state path.
    • Mitigation: the registry is keyed by canonical sessionKey, keeps sessionId as mutable metadata only, and is covered by wait/rotate/abort/restart regression tests.
  • Risk: repo-wide local gates still have unrelated existing bash-tools type failures.
    • Mitigation: touched-surface tests, lint, and formatting were run directly; the unrelated errors are in src/agents/bash-tools.exec.ts and src/agents/bash-tools.process.ts, outside this PR's write set.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M agents Agent runtime and tooling size: XL and removed size: M labels Apr 5, 2026
@dutifulbob dutifulbob changed the title [codex] Reproduce session stall and restart drain bugs [codex] Fix stalled sessions and restart drain replies Apr 5, 2026
@dutifulbob
dutifulbob marked this pull request as ready for review April 5, 2026 10:18

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

Copy link
Copy Markdown
Contributor

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: 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".

Comment thread src/auto-reply/reply/reply-operation.ts Outdated
@greptile-apps

greptile-apps Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes two reply lifecycle bugs: preflight compaction now runs under a registered ReplyOperation handle so /stop can cancel before the main embedded run starts, and GatewayDrainingError/CommandLaneClearedError now surface a restart-specific user reply instead of the generic failure text. The previously flagged registry-handle leak on non-queued aborts is resolved — complete() in the finally blocks of both runReplyAgent and createFollowupRunner unconditionally calls clearRegistryHandle(), making cleanup idempotent regardless of abort phase.

Confidence Score: 5/5

Safe 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 /greploops in Claude Code. It iterates: fix, push, re-review, repeat until 5/5 confidence.
Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal.

Reviews (2): Last reviewed commit: "Auto-reply: clarify ownership handoff co..." | Re-trigger Greptile

Comment thread src/auto-reply/reply/reply-operation.ts Outdated

osolmaz commented Apr 5, 2026

Copy link
Copy Markdown
Member

Addressed the stale abort-handle leak in fe354df57f.

The fix keeps queued aborts immediate, but clears the stable ReplyOperation registry handle from the outer runner finally path so non-queued aborts stay active only until preflight or running unwind completes, then cleanly disappear from ACTIVE_EMBEDDED_RUNS.

Added regression coverage in src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts.

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

Copy link
Copy Markdown
Contributor

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: 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".

Comment thread src/auto-reply/reply/get-reply-run.ts Outdated

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

Copy link
Copy Markdown
Contributor

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: 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".

Comment thread src/auto-reply/reply/get-reply-run.ts Outdated
@dutifulbob dutifulbob closed this Apr 5, 2026
@dutifulbob dutifulbob reopened this Apr 5, 2026

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

Copy link
Copy Markdown
Contributor

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: 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".

Comment thread src/auto-reply/reply/get-reply-run.ts Outdated

osolmaz commented Apr 5, 2026

Copy link
Copy Markdown
Member

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:

  • unified the reply lifecycle under ReplyOperation
  • made preflight compaction abortable through the active-run registry
  • carried the lifecycle across memory-flush session rotation
  • fixed /new + drain messaging and removed the eager standalone reset notice for reply-producing reset turns
  • fixed the remaining same-session ownership race in src/auto-reply/reply/get-reply-run.ts
  • resolved the last inline P1 thread with 5271b49eea

Local validation on the implemented tree:

  • pnpm exec vitest run --config vitest.auto-reply.config.ts src/auto-reply/reply/get-reply-run.media-only.test.ts
    • passed: 17 tests
  • pnpm exec vitest run --config vitest.auto-reply.config.ts src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts src/auto-reply/reply/agent-runner-execution.test.ts src/auto-reply/reply/followup-runner.test.ts
    • passed: 73 tests
  • pnpm check
    • passed
  • pnpm build
    • passed
  • codex review --base main
    • rerun locally on the current branch head; no new actionable P0/P1 findings surfaced in PR thread state

Current blockers:

  1. GitHub Actions / fork workflow state
    • the real CI workflow for the code-bearing head 5271b49eea was created and then cancelled before any jobs were scheduled (https://github.com/openclaw/openclaw/actions/runs/24000907347)
    • I do not have permission to cancel the stale org-side in-progress CI run on the previous head or rerun the cancelled one
    • later no-op / comment-only synchronizations only retriggered Labeler, so I could not force a fresh full CI run on the current head from this side
  2. GitHub now reports the PR as conflicting with main
    • gh pr view currently returns mergeable=CONFLICTING / mergeStateStatus=DIRTY

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 CI pass.

@dutifulbob
dutifulbob force-pushed the codex/repro-session-stall-and-drain-bugs-2 branch from 33b6e76 to 9cd28f1 Compare April 5, 2026 13:17

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

Copy link
Copy Markdown
Contributor

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: 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".

Comment thread src/auto-reply/reply/agent-runner-execution.ts Outdated
@dutifulbob dutifulbob changed the title [codex] Fix stalled sessions and restart drain replies Fix stalled sessions and restart drain replies Apr 5, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the docs Improvements or additions to documentation label Apr 5, 2026

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

Copy link
Copy Markdown
Contributor

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: 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".

Comment thread src/auto-reply/reply/get-reply-run.ts

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

Copy link
Copy Markdown
Contributor

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: 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".

Comment thread src/auto-reply/reply/get-reply-run.ts Outdated

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

Copy link
Copy Markdown
Contributor

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: 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".

Comment thread src/auto-reply/reply/get-reply-run.ts Outdated
Comment thread src/auto-reply/reply/get-reply-run.ts Outdated

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

Copy link
Copy Markdown
Contributor

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: 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".

Comment thread src/auto-reply/reply/reply-run-registry.ts Outdated

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

Copy link
Copy Markdown
Contributor

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: 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".

Comment thread src/auto-reply/reply/reply-run-registry.ts Outdated

osolmaz commented Apr 5, 2026

Copy link
Copy Markdown
Member

Final report on current head ce9c8f0530.

What changed after the earlier round:

  • cba6a64e12 fixes the remaining interrupt/wait path regressions in src/auto-reply/reply/get-reply-run.ts:
    • interrupt mode now aborts the active run before waiting
    • waited turns re-drain system events after the wait so post-compaction context is not lost
  • ce9c8f0530 keeps restart aborts visible instead of classifying them as /stop user aborts:
    • bulk restart aborts now flow through abortForRestart()
    • restart-interrupted turns now return the visible restart notice instead of SILENT_REPLY_TOKEN

Validation run on this head:

  • 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.ts
    • passed
  • pnpm 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.ts
    • passed
  • pnpm 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
    • passed
  • pnpm check
    • still fails only on unrelated existing type errors in src/agents/bash-tools.exec.ts:1223 and src/agents/bash-tools.process.ts:166 (displaySummary not in AgentTool)
  • pnpm build
    • still fails only on the same unrelated bash-tools type errors
  • codex review --base origin/main
    • rerun locally on the current head; the earlier actionable P1/P2 issues from review are fixed and all current-head inline review threads are resolved. A fresh rerun did not produce additional PR findings before the local review CLI stalled in diff inspection, so I am not claiming a clean completed review run beyond the resolved thread state.

Review / comments status:

  • all inline review threads are replied to and resolved
  • checked PR issue comments; no remaining actionable Codex issue comments on the current head

Current GitHub status:

  • install-smoke is green on ce9c8f0530
  • the remaining visible failure is actionlint in Workflow Sanity: the job log shows scripts/check-no-conflict-markers.mjs reporting unresolved conflict markers in CHANGELOG.md:72
  • I did not touch CHANGELOG.md, rg -n '^(<<<<<<<|=======|>>>>>>>)' CHANGELOG.md is clean locally, and git merge-tree $(git merge-base HEAD origin/main) origin/main HEAD | rg -n '^(<<<<<<<|=======|>>>>>>>)' is also clean, so this looks like a GitHub synthetic merge-ref problem rather than a failure caused by this PR's code changes

What I could not verify locally:

  • no live gateway restart exercise across a real embedded or CLI-backed reply turn
  • no staging/production verification that restart-interrupted turns show the restart notice on real channels

Given the current head and the resolved review threads, I consider the code changes ready. The remaining blockers are the unrelated local bash-tools repo-wide type errors and the GitHub-side actionlint synthetic-merge failure.

@osolmaz
osolmaz force-pushed the codex/repro-session-stall-and-drain-bugs-2 branch from ce9c8f0 to 79407d9 Compare April 5, 2026 17:03
@osolmaz osolmaz changed the title Fix stalled sessions and restart drain replies Auto-reply: unify reply lifecycle across stop, rotation, and restart Apr 5, 2026

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

Copy link
Copy Markdown
Contributor

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: 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".

Comment on lines +1247 to +1253
if (restartLifecycleError instanceof CommandLaneClearedError) {
params.replyOperation?.fail("command_lane_cleared", restartLifecycleError);
return {
kind: "final",
payload: {
text: buildRestartLifecycleReplyText(),
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@osolmaz
osolmaz force-pushed the codex/repro-session-stall-and-drain-bugs-2 branch from 2dd6fb6 to f2cb3ef Compare April 5, 2026 17:26
@osolmaz osolmaz self-assigned this Apr 5, 2026
@osolmaz
osolmaz merged commit 3f68402 into openclaw:main Apr 5, 2026
7 checks passed
@osolmaz
osolmaz deleted the codex/repro-session-stall-and-drain-bugs-2 branch April 5, 2026 17:32
@osolmaz

osolmaz commented Apr 5, 2026

Copy link
Copy Markdown
Member

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!

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

Copy link
Copy Markdown
Contributor

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: 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".

Comment on lines +854 to +857
if (error instanceof CommandLaneClearedError) {
replyOperation.fail("command_lane_cleared", error);
return finalizeWithFollowup(
{ text: "⚠️ Gateway is restarting. Please wait a few seconds and try again." },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants