fix(gateway): preserve restart continuations after reboot#63406
Conversation
Greptile SummaryThis PR extends the restart-sentinel flow with an optional one-shot continuation payload ( Confidence Score: 5/5Safe to merge — no P0/P1 findings; the prior schema violation concern has been correctly addressed. All six changed files are clean. The Type.Union/anyOf schema issue flagged in the previous review round is resolved with optionalStringEnum. Continuation dispatch is one-shot (sentinel is consumed before any dispatch), error paths are caught and logged rather than bubbled, and test coverage spans the main agentTurn path, delivery failure, missing-route fallback, and the no-sessionKey warning branch. No files require special attention.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 972783881a
ℹ️ 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: 8575755c0c
ℹ️ 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-apps review |
|
Tip: Greploop — Automatically fix all review issues by running Use the Greptile plugin for Claude Code to query reviews, search comments, and manage custom context directly from your terminal. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6603b42d53
ℹ️ 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: 559e33847d
ℹ️ 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".
|
@BunsDev tagging you as I know you were interested/helped merge in the last time I fixed the restart flow. I also know there's a broader effort to stabilize and get things more secure so I'm sure that's why it was lost in the cleanup. That said, this is a bit more elegant than last time so hopefully it persists through future changes 🦞 |
8c4ab51 to
6691f05
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6691f05248
ℹ️ 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: 8d69efec31
ℹ️ 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".
8d69efe to
b4b53c0
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4b53c0e33
ℹ️ 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".
b4b53c0 to
a755686
Compare
03c5f62 to
3aa09d9
Compare
obviyus
left a comment
There was a problem hiding this comment.
Verified gateway restart continuations persist through reboot, resume the same session, and route replies back to the original channel/thread. Manual smoke covered PR-linked gateway restart and a valid restart-sentinel continuation; local tests cover stale routes, synthetic reply IDs, system-event wakeups, exhausted notice retries, and session-route fallback.
Maintainer follow-up: hardened route resolution, resolved current review threads, added restart-continuation edge coverage, documented the tool instruction, and added the Unreleased changelog entry.
Local gate: pnpm test src/gateway/server-restart-sentinel.test.ts src/agents/tools/gateway-tool.test.ts src/infra/restart-sentinel.test.ts; pnpm check:changed.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3aa09d9f7f
ℹ️ 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".
| Timestamp: Date.now(), | ||
| Provider: route.channel, | ||
| Surface: route.channel, | ||
| ChatType: "direct", |
There was a problem hiding this comment.
Preserve non-DM chat type in continuation context
Do not force restart agentTurn continuations to ChatType: "direct"; this misclassifies turns resumed from group/channel conversations. The reply pipeline keys behavior off ctx.ChatType (for example, group-context injection and related routing/prompt logic), so a continuation from a threaded/group route can be processed as a DM and produce the wrong follow-up behavior after reboot. Derive ChatType from the resolved session/route instead of hardcoding direct.
Useful? React with 👍 / 👎.
…anks @VACInc) * gateway: add restart continuation sentinel * gateway: address restart continuation review * gateway: handle restart continuation edge cases * gateway: keep restart continuations on threaded delivery path * fix(gateway): harden restart continuation routing * test(gateway): cover restart continuation edge cases * docs(agent): clarify restart continuation usage * fix: preserve restart continuations after reboot (openclaw#63406) (thanks @VACInc) --------- Co-authored-by: VACInc <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…anks @VACInc) * gateway: add restart continuation sentinel * gateway: address restart continuation review * gateway: handle restart continuation edge cases * gateway: keep restart continuations on threaded delivery path * fix(gateway): harden restart continuation routing * test(gateway): cover restart continuation edge cases * docs(agent): clarify restart continuation usage * fix: preserve restart continuations after reboot (openclaw#63406) (thanks @VACInc) --------- Co-authored-by: VACInc <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…anks @VACInc) * gateway: add restart continuation sentinel * gateway: address restart continuation review * gateway: handle restart continuation edge cases * gateway: keep restart continuations on threaded delivery path * fix(gateway): harden restart continuation routing * test(gateway): cover restart continuation edge cases * docs(agent): clarify restart continuation usage * fix: preserve restart continuations after reboot (openclaw#63406) (thanks @VACInc) --------- Co-authored-by: VACInc <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…anks @VACInc) * gateway: add restart continuation sentinel * gateway: address restart continuation review * gateway: handle restart continuation edge cases * gateway: keep restart continuations on threaded delivery path * fix(gateway): harden restart continuation routing * test(gateway): cover restart continuation edge cases * docs(agent): clarify restart continuation usage * fix: preserve restart continuations after reboot (openclaw#63406) (thanks @VACInc) --------- Co-authored-by: VACInc <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…anks @VACInc) * gateway: add restart continuation sentinel * gateway: address restart continuation review * gateway: handle restart continuation edge cases * gateway: keep restart continuations on threaded delivery path * fix(gateway): harden restart continuation routing * test(gateway): cover restart continuation edge cases * docs(agent): clarify restart continuation usage * fix: preserve restart continuations after reboot (openclaw#63406) (thanks @VACInc) --------- Co-authored-by: VACInc <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…anks @VACInc) * gateway: add restart continuation sentinel * gateway: address restart continuation review * gateway: handle restart continuation edge cases * gateway: keep restart continuations on threaded delivery path * fix(gateway): harden restart continuation routing * test(gateway): cover restart continuation edge cases * docs(agent): clarify restart continuation usage * fix: preserve restart continuations after reboot (openclaw#63406) (thanks @VACInc) --------- Co-authored-by: VACInc <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…anks @VACInc) * gateway: add restart continuation sentinel * gateway: address restart continuation review * gateway: handle restart continuation edge cases * gateway: keep restart continuations on threaded delivery path * fix(gateway): harden restart continuation routing * test(gateway): cover restart continuation edge cases * docs(agent): clarify restart continuation usage * fix: preserve restart continuations after reboot (openclaw#63406) (thanks @VACInc) --------- Co-authored-by: VACInc <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
…anks @VACInc) * gateway: add restart continuation sentinel * gateway: address restart continuation review * gateway: handle restart continuation edge cases * gateway: keep restart continuations on threaded delivery path * fix(gateway): harden restart continuation routing * test(gateway): cover restart continuation edge cases * docs(agent): clarify restart continuation usage * fix: preserve restart continuations after reboot (openclaw#63406) (thanks @VACInc) --------- Co-authored-by: VACInc <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Summary
gateway.restartis used specifically to resume work after reboot, so silent continuation loss breaks the main use case and is hard to diagnose.gateway.restartcan request it, restart wake dispatches it back into the same session/thread, and the edge cases raised in review now warn or re-wake instead of silently failing.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
systemEventwake timing.gateway.restartallows continuation requests without an explicitsessionKey, andsystemEventcontinuation enqueue happens later than the original restart wake.Regression Test Plan (if applicable)
src/gateway/server-restart-sentinel.test.ts,src/agents/tools/gateway-tool.test.ts,src/infra/restart-sentinel.test.tssystemEventcontinuations.User-visible / Behavior Changes
gateway.restartcan resume a one-shot continuation after reboot in the same session/thread instead of only sending a restart notice.agentTurncontinuations now preserve the stamped agent-facing text used for time-sensitive follow-up work.systemEventcontinuations now trigger their own wake instead of depending on the earlier restart-notice wake timing.Diagram (if applicable)
Security Impact (required)
Yes/No) YesYes/No) NoYes/No) NoYes/No) YesYes/No) NoYes, explain risk + mitigation: the owner-onlygateway.restarttool now accepts optional continuation inputs and can resume one follow-up turn after reboot. Risk is constrained by the existing restart auth boundary, one-shot sentinel consumption, same-session routing, and explicit warning/fail-fast handling when continuation delivery is unavailable.Repro + Verification
Environment
Steps
gateway.restartwithcontinuationMessagein a routed session.agentTurn,systemEvent, missing-route, and missing-sessionKeycontinuation cases.Expected
systemEventcontinuation requests a wake after enqueue.agentTurncontinuation keeps stampedBodyForAgentcontext.Actual
Evidence
Human Verification (required)
systemEventcontinuation wake, missing-route warning, missing-sessionKeywarning, one-shot consumption, and flat enum tool schema generation.BodyForAgent, no-route fail-fast path, no-sessionKeywarning path, and delayedsystemEventwake after restart notice delivery.Review Conversations
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations
systemEventcontinuation now schedules an extra heartbeat wake for the same session.src/gateway/server-restart-sentinel.test.ts.