Fix restart continuations after explicit restarts#73812
Conversation
|
Codex review: needs changes before merge. Summary Reproducibility: yes. The source-level reproduction is to set gateway.reload.deferralTimeoutMs to 0, schedule a no-timeout restart that waits on a nonzero pre-restart pending count, then coalesce an explicit restart with deferralTimeoutMs and observe that the old pending/preparing wait still controls emission. Next step before merge Security Review findings
Review detailsBest possible solution: Update the scheduler so coalesced restarts can update effective timeout state, keep the automatic-delivery override, share one explicit timeout constant, add focused coalescing coverage, and add the required changelog entry. Do we have a high-confidence way to reproduce the issue? Yes. The source-level reproduction is to set gateway.reload.deferralTimeoutMs to 0, schedule a no-timeout restart that waits on a nonzero pre-restart pending count, then coalesce an explicit restart with deferralTimeoutMs and observe that the old pending/preparing wait still controls emission. Is this the best way to solve the issue? No as submitted. The automatic source-delivery override is the right narrow fix, but the timeout policy must live in pending/preparing restart state rather than only in the first scheduled call's captured opts. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 3980eaa1c22e. |
Greptile SummaryThis PR fixes two bugs: restart-sentinel continuations now force
Confidence Score: 3/5The sourceReplyDeliveryMode fix is safe, but the deferral-timeout fix has a logical gap in the coalesced restart path that can recreate the original bug. One P1 finding: deferralTimeoutMs is silently dropped when a new explicit restart is coalesced onto an existing pending restart that lacks a timeout. In the coalesced branch, only emitHooks are updated; the opts captured in the pending setTimeout closure still carries no deferralTimeoutMs, leaving maxWaitMs = undefined and the indefinite-wait bug intact for that code path. src/infra/restart.ts — specifically the coalesced-restart branch starting at line 694
|
| const log = createSubsystemLogger("gateway-tool"); | ||
|
|
There was a problem hiding this comment.
Duplicate constant risks silent divergence
EXPLICIT_RESTART_DEFERRAL_TIMEOUT_MS = 30_000 is independently defined here and again in src/auto-reply/reply/commands-session.ts. The two values must stay in sync to provide consistent deferral-timeout protection across explicit restart paths. Exporting a single named constant from src/infra/restart.ts and importing it in both call sites would prevent silent drift.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agents/tools/gateway-tool.ts
Line: 24-25
Comment:
**Duplicate constant risks silent divergence**
`EXPLICIT_RESTART_DEFERRAL_TIMEOUT_MS = 30_000` is independently defined here and again in `src/auto-reply/reply/commands-session.ts`. The two values must stay in sync to provide consistent deferral-timeout protection across explicit restart paths. Exporting a single named constant from `src/infra/restart.ts` and importing it in both call sites would prevent silent drift.
How can I resolve this? If you propose a fix, please make it concise.e7d8034 to
ba9a6ec
Compare
Summary
gateway.restartreturn ok without ever emitting SIGUSR1.Root cause
Recent group reply handling defaults normal group/channel turns to message-tool-only delivery. Restart-sentinel continuations use the generic gateway dispatch path, so their final reply could be suppressed in a Telegram topic even though the continuation turn ran.
A second issue showed up in topic 22684: the
gateway.restarttool wrote a continuation and returned ok, but the scheduler waited indefinitely in the pre-restart deferral layer. With no runtime deferral timeout, any stale pending counter could prevent SIGUSR1 from ever being emitted.Validation
pnpm exec oxfmt --check --threads=1 src/infra/restart.ts src/infra/infra-runtime.test.ts src/agents/tools/gateway-tool.ts src/agents/tools/gateway-tool.test.ts src/auto-reply/reply/commands-session.ts src/gateway/server-restart-sentinel.ts src/gateway/server-restart-sentinel.test.tspnpm test src/infra/infra-runtime.test.ts src/agents/tools/gateway-tool.test.ts src/gateway/server-restart-sentinel.test.ts