Repository navigation
fix(agents): quiet model turns are aborted by a false "no response from model" idle timeout - #117884
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 10:18 AM ET / 14:18 UTC. ClawSweeper reviewWhat this changesThe PR forwards provider liveness from a composed cancellation signal back to the embedded-run idle-watchdog signal and adds focused regressions for quiet but active model streams. Regression provenancePossible regression — probable (reviewed change; reproduction). No predecessor PR is attributed. Merge readinessThis remains a useful, source-backed repair: current main still passes a fresh composite signal to providers while the watchdog subscribes to its own signal, so quiet provider activity is lost. The branch restores that missing activity path at the sole composition boundary; no correctness finding was identified, but exact-head checks are still pending. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherEmbedded agent runs wrap provider streams with an idle watchdog and pass cancellation signals down to transports. Providers report hidden progress through a signal-keyed activity registry, which the watchdog uses to keep an active request alive. flowchart LR
A[Embedded agent turn] --> B[Idle watchdog]
B --> C[Composed cancellation signal]
C --> D[Provider transport]
D --> E[Request activity registry]
E --> B
B --> F[Reply or idle timeout]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +14, Tests +187. Total +201 across 2 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the single composition-boundary bridge after the current head completes required validation; keep provider transports and timeout policy unchanged. Do we have a high-confidence way to reproduce the issue? Yes—current main visibly creates the composite without an activity bridge, and the focused regression describes the exact two-signal quiet-progress path. Is this the best way to solve the issue? Yes—the composition boundary is the only place that holds both signal identities, while multiple provider siblings already correctly report activity on their received signal. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fe6b8bf1e4d4. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (22 earlier review cycles; latest 8 shown)
|
|
Maintainer lifecycle repair pushed at The activity bridge now stops forwarding provider liveness once the composed request signal is aborted. Regression coverage exercises both cancellation after signal composition and a run signal that was already aborted before composition. Exact-head proof:
Repair delta: production +3/-1; tests +40. @clawsweeper re-review CI follow-up: HOLD. Exact-head CI run https://github.com/openclaw/openclaw/actions/runs/30740886446 failed only Current |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Refreshed the head with The previous run and its isolated retry both failed at the 120s ceiling in Merged rather than rebased so your commit stays intact. The diff in this PR is unchanged. |
|
Thank you @vincentkoc for the maintainer lifecycle repair at 85b6097a1. The activity bridge fix looks solid — it correctly stops forwarding provider liveness once the composed signal is aborted. The head refresh I did picked up the 120s→300s budget widening from #117931, which resolved the previous flaky timeout in the event-loop test. All evidence remains current and the regression coverage exercises both post-composition cancellation and pre-aborted signals. Ready for merge when you are. Let me know if you need anything else verified. |
|
That was the only outstanding condition on either side. Both remaining items on the review card are "wait for exact-head CI to complete green", and the card was last updated at 09:41:24Z, about ten minutes before the run finished, so it never recorded the result. Nothing else has changed: the diff is unchanged, |
0d96a7c to
fb9de08
Compare
|
@vincentkoc thank you for the lifecycle repair at I want to be precise about scope, because I checked whether your commit had made this PR unnecessary before doing any more work on it. Your commit narrowed the bridge; it did not land the bridge on
|
…om model" idle timeout The embedded runner merges the caller's request signal with the run's cancellation signal through AbortSignal.any, which produces a new signal object. The LLM request-activity registry is keyed by signal identity, so transports that report progress with notifyLlmRequestActivity(options.signal) now notify the composite while the idle watchdog is still listening on the signal it handed in. Every keep-alive is dropped, and turns whose only sign of life is that keep-alive (hidden reasoning on openai-completions, buffered Claude refusals) are aborted as idle while the model is still responding. Bridge activity from the composite back to the caller signal at mergeRunSignal, the single site that holds both, restoring the pre-merge identity for the activity channel while keeping both cancellation owners. The bridge is disposed from the caller signal rather than the composite: Node keeps composite signals that carry an abort listener in a process-wide strong set until the last listener is removed.
3802e28 to
5025958
Compare
|
Merged via squash.
|
…om model" idle timeout (openclaw#117884) * fix(agents): quiet model turns are aborted by a false "no response from model" idle timeout The embedded runner merges the caller's request signal with the run's cancellation signal through AbortSignal.any, which produces a new signal object. The LLM request-activity registry is keyed by signal identity, so transports that report progress with notifyLlmRequestActivity(options.signal) now notify the composite while the idle watchdog is still listening on the signal it handed in. Every keep-alive is dropped, and turns whose only sign of life is that keep-alive (hidden reasoning on openai-completions, buffered Claude refusals) are aborted as idle while the model is still responding. Bridge activity from the composite back to the caller signal at mergeRunSignal, the single site that holds both, restoring the pre-merge identity for the activity channel while keeping both cancellation owners. The bridge is disposed from the caller signal rather than the composite: Node keeps composite signals that carry an abort listener in a process-wide strong set until the last listener is removed. * fix(agents): stop idle activity after run cancellation * style: satisfy oxfmt import ordering in stream-resolution.test.ts * fix(agents): release completed watchdog activity bridges * test(agents): isolate provider stream activity regressions --------- Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
Related: #117731
Related: #113323 (that issue's local-provider path opts out of gap policing; this regression bites the cloud path that #114997 hardened)
What Problem This Solves
Fixes an issue where users running an agent turn whose model streams no visible output for a while would have the run killed with
LLM idle timeout (120s): no response from modelwhile the model was still responding. Two shipping cases produce such turns: hidden reasoning onopenai-completionsproviders (nothing is exposed until the answer starts), and Claude turns under the streaming-refusal contract, where every event is buffered until the terminal stop reason is known.The affected surface is an embedded agent run — CLI, gateway/channel, or subagent — whose turn reaches the Anthropic or OpenAI-completions transport and stays visibly silent past the idle budget (120s; 60s on cron) while the provider is still streaming.
Why This Change Was Made
The idle watchdog keeps itself alive on quiet turns by listening for transport keep-alives on the
AbortSignalit hands down (llm-idle-timeout.ts:436,454-457,530-533), and that activity registry is keyed by signal identity (packages/ai/src/utils/llm-request-activity.ts:1,7). #117731 correctly made the embedded runner honour both cancellation owners by composing the caller signal with the run signal (stream-resolution.ts:273-276); the unforeseen interaction is thatAbortSignal.any()returns a new object, so the transport now reports keep-alives on the composite (openai-completions-transport.ts:658,anthropic-transport-stream.ts:1152) while the watchdog is still listening on the signal it created — and every keep-alive is dropped. Before that commit the same expression returnedcallerSignalwhen both existed, so identity was preserved and the channel worked.This bridges activity from the composite back to the caller signal in
mergeRunSignal, the only site that holds both objects (AbortSignal.anyhides its sources, so nothing downstream can re-associate them). That restores the pre-merge identity for the activity channel and leaves #117731's cancellation property exactly as it is. Non-goals: no change to cancellation semantics, timeout defaults, transport code, or the activity registry itself.The bridge is intentionally listener-free:
onLlmRequestActivityalready stores callbacks in aWeakMapkeyed by the composite signal, so the composite, its callback, and its registry entry become collectible when a completed request releases the composite. No abort listener is attached to either cancellation signal. Attaching cleanup to the reusable caller signal would retain one completed-request closure and composite per successful turn; attaching an abort listener directly to the composite would instead trigger Node's process-widegcPersistentSignalsretention.composedSignal.abortedstill suppresses stale activity when either cancellation owner aborts.User Impact
Long turns whose only sign of life is provider keep-alive — hidden reasoning, buffered refusals — now run to completion instead of failing with "no response from model". Reusing a caller signal across successfully completed turns also remains bounded: finished requests do not accumulate abort listeners or retain old activity bridges.
Scope, stated plainly: turns that emit visible events already refresh the watchdog through the iterator path and were never affected; runs without a separate run signal, and the
anthropic-vertexpath (stream-resolution.ts:176-178, which returns before any wrapper), never build a composite and are unchanged. No config change, no new surface, no behaviour change for anyone not hitting a quiet turn.Evidence
Focused regression coverage in the dedicated
src/agents/embedded-agent-runner/stream-resolution.activity.test.tsowner suite:keeps provider request activity reaching the caller signal after the run signal merge— the contract, no timers: activity notified on the merged signal must reach a listener registered on the caller signal.keeps the idle watchdog armed when a merged run signal turn only reports hidden progress— the real topology,streamWithIdleTimeoutoutside andresolveEmbeddedAgentStreamFninside, with a transport that emits no visible event for 120ms and reports liveness only vianotifyLlmRequestActivity(options.signal), against a 50ms idle budget.AssistantMessage, and explicitly resolvesstream.result()successfully; each distinct composite forwards exactly its own activity, whilegetEventListeners(callerSignal, "abort")remains at its original baseline after each completed turn.Original contributor's adversarial check — tests applied, production change reverted to
AbortSignal.any([callerSignal, params.runSignal]), test file untouched:Original contributor's owner and sibling evidence before the lifecycle follow-up:
Real behavior proof — quiet-turn idle watchdog
Original contributor's loopback harness, real production chain, no mocks, no fake timers (Windows, Node v24.18.1, archived proof head
46f98d1b0):The server mimics a quiet reasoning turn (
reasoning: falsemodel): only hiddenreasoning_contentchunks every 2 s for ~10 s (no visible client event in that phase), then one visible content chunk and[DONE]. Loopback only, not a live provider account;apiKeyis a dummy value. Timestamps are the harness's relative stamps.Run 1 — pre-fix
Bug reproduced: the turn dies 3.0 s after the watchdog armed while the provider is actively streaming — keep-alives land on the composite signal, but the watchdog listens on the signal it handed in; the identity mismatch drops every keep-alive.
Run 2 — post-fix, same quiet-but-alive server
Fix verified: a 10 s hidden phase survives a 3 s watchdog budget. Nothing visible is emitted until +11.1 s; only the bridged keep-alives re-arm the watchdog.
Run 3 — post-fix control: SSE headers sent, then silence
Control verified: a genuinely silent provider still times out at ~3 s and the abort propagates into the provider request — the fix does not disarm the watchdog. In all three runs
runController.signal.aborted=falseat exit; the watchdog is the only abort source.Why no existing test caught this:
run/llm-idle-timeout.test.ts:944wiresbaseFndirectly understreamWithIdleTimeoutwith no merge wrapper and no run signal, so it notifies the very object the watchdog registered on; the OpenAI transport loopback coverage passes options with no run signal; and the coverage added by #117731 proves the composite aborts correctly but never composes the idle watchdog. Neither layer is wrong on its own — only their composition is.Sibling surfaces sharing the same invariant, all downstream of this one merge and all notifying on
options.signal:packages/ai/src/transports/anthropic-transport-stream.ts,packages/ai/src/transports/openai-completions-transport.ts,packages/ai/src/providers/anthropic.ts,packages/ai/src/providers/openai-completions.ts, andextensions/amazon-bedrock/stream.runtime.ts. One bridge at the merge restores all of them; none of them needs to change.Dependency contracts checked directly:
packages/ai/src/utils/llm-request-activity.tsuses a signal-keyedWeakMap;packages/llm-core/src/utils/event-stream.tsrequires a real terminal event or final result for successful stream completion; Node'slib/internal/abort_controller.jscreates a fresh composite, tracks dependencies weakly, and strongly retains composites only when abort listeners are installed.ClawSweeper finding resolved
The accepted lifecycle finding was valid: the previous cleanup listener on the reusable caller signal retained one completed bridge after every successful stream. The follow-up removes that listener entirely and relies on the existing canonical signal-keyed
WeakMap, reducing production code by 16 lines relative to the previous contributor head. Across the entire PR versus its merge base, the necessary new composed-signal activity bridge adds 15 production lines and removes one (net +14); approximately eight executable lines provide the otherwise-missing generic identity bridge at its sole architectural owner. The new deterministic regression proves two genuinely successful completed turns keep caller abort listeners at baseline. Both caller/run cancellation ownership, hidden provider progress, and true-silence timeouts are unchanged.The first exact-head hosted run also exposed an existing generic owner test file crossing the repository's maximum-line rule after this regression was added. The complete four-case activity/watchdog neighborhood now lives in a focused 187-line owner suite, leaving the generic owner suite at 955 physical lines. This test-only extraction adds 188 lines and removes 219 (net -31 test lines); no lint thresholds, configuration, runtime behavior, or original human regression coverage were weakened.
The original contributor's local proof above is historical evidence on their earlier head. Maintainer review did not execute contributor-controlled source, tests, configuration, or hooks locally; current-head runtime verification is delegated to the isolated GitHub-hosted CI sandbox. Independent source review covered the complete original contribution and follow-up, including the Node and stream dependency contracts.
Not claimed: this has not been reproduced against a paid live provider account.
Original implementation and real loopback investigation by @pacocartones, with an existing activity-cancellation correction by Vincent Koc. Both original human contributions are preserved; @pacocartones remains the primary PR author.