Skip to content

[codex] Reproduce session stall and restart drain bugs#61225

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

[codex] Reproduce session stall and restart drain bugs#61225
vincentkoc merged 5 commits into
openclaw:mainfrom
osolmaz:codex/repro-session-stall-and-drain-bugs

Conversation

@dutifulbob

Copy link
Copy Markdown
Contributor

Summary

This PR adds failing regression tests for two user-facing auto-reply bugs in external chat channels.

It does not fix the bugs yet. The follow-up work will land the production changes in this same PR.

Bugs Reproduced

  1. Large-session preflight compaction can start before the embedded run is registered as active, so /stop cannot abort it and the channel appears stuck.
  2. /new during gateway restart/drain sends ✅ New session started too early and then surfaces a generic failure instead of a restart-specific reply.

User Impact

  • A busy channel with a huge session transcript can look hung and ignore /stop.
  • During restart/drain, users can see contradictory or misleading feedback after /new.

Tests Added

  • src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts
    • lets /stop abort a run that is still in preflight compaction
  • src/auto-reply/reply/get-reply-run.media-only.test.ts
    • does not emit a reset notice when /new is attempted during gateway drain
  • src/auto-reply/reply/agent-runner-execution.test.ts
    • returns a restart-specific error when the gateway is draining

Validation

pnpm exec vitest run --config vitest.auto-reply.config.ts src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts src/auto-reply/reply/get-reply-run.media-only.test.ts src/auto-reply/reply/agent-runner-execution.test.ts -t "lets /stop abort a run that is still in preflight compaction|does not emit a reset notice when /new is attempted during gateway drain|returns a restart-specific error when the gateway is draining"

Current result: intentionally red with 3 failing regressions.

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Apr 5, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the docs Improvements or additions to documentation label Apr 5, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review April 5, 2026 09:05
@vincentkoc
vincentkoc merged commit 83d29da into openclaw:main Apr 5, 2026
6 checks passed
@greptile-apps

greptile-apps Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds three intentionally-failing regression tests for two user-facing auto-reply bugs: preflight compaction starting before a run is registered as active (blocking /stop), and /new during gateway drain emitting a premature success notice followed by a generic failure. All imports, test helpers (__testing from abort.ts and runs.ts), and the deferred-compaction cleanup pattern in the finally block look correct. The createGatewayDrainingError() helper in the media-only test correctly mirrors the real class name and message as an intentional module-isolation workaround.

Confidence Score: 5/5

Safe to merge — all findings are P2 style suggestions with no impact on test correctness or runtime behavior.

The PR only adds intentionally-failing regression tests with no production code changes. The single finding is a P2 model-constant naming preference (claude-opus-4-6 vs. sonnet-4.6) that does not affect how the test runs or fails.

No files require special attention.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts
Line: 642

Comment:
**Prefer `sonnet-4.6` for Anthropic test model constants**

Per project guidelines, tests should use `sonnet-4.6` rather than `claude-opus-4-6` for Anthropic model examples.

```suggestion
      defaultModel: "anthropic/sonnet-4.6",
```

**Context Used:** CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Merge branch 'main' into codex/repro-ses..." | Re-trigger Greptile

sessionStore: { [sessionKey]: sessionEntry },
sessionKey,
storePath,
defaultModel: "anthropic/claude-opus-4-6",

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 Prefer sonnet-4.6 for Anthropic test model constants

Per project guidelines, tests should use sonnet-4.6 rather than claude-opus-4-6 for Anthropic model examples.

Suggested change
defaultModel: "anthropic/claude-opus-4-6",
defaultModel: "anthropic/sonnet-4.6",

Context Used: CLAUDE.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts
Line: 642

Comment:
**Prefer `sonnet-4.6` for Anthropic test model constants**

Per project guidelines, tests should use `sonnet-4.6` rather than `claude-opus-4-6` for Anthropic model examples.

```suggestion
      defaultModel: "anthropic/sonnet-4.6",
```

**Context Used:** CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@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: 182f65f41e

ℹ️ 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".

tokensAfter: 8_000,
},
});
await runPromise;

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.

P1 Badge Avoid unbounded wait on stalled run in regression test

The new /stop regression can leave runReplyAgent(...) unresolved when the preflight-compaction bug is present, but this finally block always awaits runPromise; that turns the expected red assertion into a hanging test process instead of a deterministic failure. Running this case locally required an external timeout (timeout 35s ..., exit 124), which means CI can stall on this test rather than report the regression cleanly.

Useful? React with 👍 / 👎.

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
* Tests: reproduce session stall and drain bugs

* Docs: add reply lifecycle unification plan

* Docs: lock down reply lifecycle plan

* Delete docs/experiments/plans/reply-lifecycle-unification.md

---------

Co-authored-by: Onur <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
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
* Tests: reproduce session stall and drain bugs

* Docs: add reply lifecycle unification plan

* Docs: lock down reply lifecycle plan

* Delete docs/experiments/plans/reply-lifecycle-unification.md

---------

Co-authored-by: Onur <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
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
* Tests: reproduce session stall and drain bugs

* Docs: add reply lifecycle unification plan

* Docs: lock down reply lifecycle plan

* Delete docs/experiments/plans/reply-lifecycle-unification.md

---------

Co-authored-by: Onur <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
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
* Tests: reproduce session stall and drain bugs

* Docs: add reply lifecycle unification plan

* Docs: lock down reply lifecycle plan

* Delete docs/experiments/plans/reply-lifecycle-unification.md

---------

Co-authored-by: Onur <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
* Tests: reproduce session stall and drain bugs

* Docs: add reply lifecycle unification plan

* Docs: lock down reply lifecycle plan

* Delete docs/experiments/plans/reply-lifecycle-unification.md

---------

Co-authored-by: Onur <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Nachx639 pushed a commit to Nachx639/clawdbot that referenced this pull request Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants