Repository navigation
fix(agents): classify a caller's external timeout abort as a clean interruption - #283
Conversation
…terruption (ENG-21233)
Fleet telemetry showed `Error: Turn budget exceeded | 23` on agent_end
captures. The "23" is not a turn-count ceiling (there is none in this
repo) - it's DOMException.code for TimeoutError (verified:
`node -e 'console.log(new DOMException("x","TimeoutError").code)'` -> 23),
leaking through formatErrorMessage's cause-chain code-append when a
channel plugin's own external abortSignal fires as a timeout.
When a plugin passes replyOptions.abortSignal and that signal fires with a
TimeoutError reason, the DOMException (instanceof Error) gets wrapped by
abortable.ts's makeAbortError and lands in promptError - reported as
success:false with a misleading error string - even though
onExternalAbortSignal/abortRun already classified it as aborted+timedOut.
Add isExternalTimeoutAbortRejection (abort.ts), gated on
externalAbort && timedOut && isRunnerAbortError(err), and use it in
attempt.ts's prompt catch block to leave promptError unset for this one
case. OpenClaw's own internal-watchdog timeouts (scheduleAbortTimer,
idleTimeoutTrigger) never set externalAbort, so they are unaffected and
still report as errors.
This flips diagnostic outcome from "error" to "aborted"/"interrupted" in
attempt-trajectory-status.ts and harness/lifecycle.ts (no code change
needed there - both already branch on externalAbort/aborted/timedOut
ahead of promptError). success itself stays false (aborted is unchanged),
so extensions/sentry-monitor/src/captures.ts is also updated: a
success:false agent_end with no error text now reports as a low-severity
"message" capture instead of an exception, so the fleet stops paging on
every expected, policy-driven abort.
Companion PR in anychat-boon-web adds a wrap-up warning injected into the
live agent before this abort fires, so it gets a real chance to converge
to an answer instead of only ever hitting this path.
Co-Authored-By: Claude Opus 5 <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
…fication cubic-dev-ai flagged a real gap: an external abortSignal can fire with a timeout reason BEFORE abortRunForExternalSignal is installed (onExternalAbortSignal's early-exit path, attempt.ts), which sets promptError directly rather than going through abortRun. The new branch in the prompt catch block only declined to RE-set promptError for that rejection; it never cleared an already-set value from that earlier path, so the run was still reported as an error. Now explicitly resets promptError/promptErrorSource to null, matching the existing precedent at the mid-turn-precheck re-prompt branch a few lines below. Also drops stray Linear ticket references from source/test comments per repo convention (cubic flagged these too), and fixes a genuine check:test-types failure in captures.test.ts: accessing capture?.level after a separate capture?.kind assertion doesn't narrow the discriminated SentryCapture union, so TypeScript rejected the property access. Narrows with an explicit kind check before reading the message-kind fields. Co-Authored-By: Claude Opus 5 <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
cubic-dev-ai's re-review caught that the "stays false for OpenClaw's own internal-watchdog timeout" test used an unrealistic fixture: a plain Error with name="TimeoutError", which isRunnerAbortError already rejects on its own (it only matches name="AbortError" or a message containing "aborted"). The assertion passed, but for the wrong reason - it would still pass even if the externalAbort check were silently dropped from the predicate. The real internal-watchdog rejection, like the external one, passes through abortable()'s makeAbortError wrapper, which always sets name="AbortError" regardless of the original reason's name - the only actual difference between the two cases is the externalAbort/timedOut state flags, not the error's shape. Rebuilt the fixture through the same abortable() wrapper the production code uses, and added an explicit isRunnerAbortError(err) === true assertion so the test can no longer pass on isRunnerAbortError's own short-circuit. Co-Authored-By: Claude Opus 5 <[email protected]>
There was a problem hiding this comment.
Reviewed the abort classification and regression coverage. The predicate requires an external abort, timeout state, and abort-shaped rejection; internal watchdog timeouts and unrelated provider errors remain errors. The catch path clears promptError for the early-signal race, and no-error agent_end events are downgraded to info. No blocking correctness issues found.
…cation - Extract classifyAsyncTaskWaitTimeout so a pending async task at the completion-required wait's deadline can no longer silently repopulate promptError after a run was already classified as a clean external timeout abort. - Bump the no-error-text agent_end Sentry capture from info to warning: the shape isn't provably limited to the one caller-driven abort case, so an unrelated cause with the same shape stays visible for triage. - Trim an oversized inline comment on the classification branch to the repo's 1-3 line comment policy. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
cubic-dev-ai flagged a real gap: an external timeout can fire after the main prompt already resolved cleanly (so the classification branch in the prompt's catch block never runs), then independently time out the completion-required async-task wait's own abortSignal. That path never set externalTimeoutAbortClassified, so a pending async task there still repopulated promptError for what was genuinely a caller-driven abort. Classify it with the same isExternalTimeoutAbortRejection predicate inside that wait's own catch block. Also condenses an oversized inline comment in captures.ts to the repo's 1-3 line policy, per a second cubic-dev-ai finding. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…4x-customer-turns-abort-with
…go:test The sibling 'log' kind test accessed outcome.message after only asserting outcome.kind at runtime, which doesn't narrow the discriminated union for TypeScript — check-test-types failed with TS2339 since 'message' isn't on the 'none' variant. Match the adjacent 'error' kind test's toEqual shape instead, which asserts kind and message together without narrowing. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Cut the fork release that ships the six commits on boon since v2026.6.34-boon.6: - #286: decouple Rastermill's image decode and output pixel budgets so a source image above 25 megapixels downscales instead of being rejected outright; plus HEIC/data-URL pixel-guard and error-detail fixes. - #283 (ENG-21233): classify a caller's external timeout abort as a clean interruption instead of leaking DOMException's TimeoutError code as "Turn budget exceeded | 23" on agent_end. - #284 (ENG-21229): re-derive the memory-flush write guard's allowed path at execute time so a flush crossing midnight no longer rejects the correct current-date path. - #282 (ENG-21225): web_fetch 403/404/429 no longer page Sentry as unhandled exceptions; 429 now retries with bounded backoff honoring Retry-After. - #285: remove a duplicate simple-git/proxy-addr/source-map-js overrides block that crashed pnpm store path on every PR against boon. - #275: bump music-metadata 11.12.3 -> 11.16.0. Bump root package.json and npm-shrinkwrap.json, all 136 plugin manifests, and the version/peer floor in every extension npm-shrinkwrap.json via pnpm release:prep. The npm-shrinkwrap generator can't regenerate cleanly on this fork (pre-existing, unrelated @sentry/node nested @opentelemetry/resources / sdk-trace-base registry-resolution drift, verified present on unmodified origin boon); hand-patched the affected shrinkwrap version/peer-floor fields instead, verified against test/package-manager-config.test.ts (12/12 passing). Add the 2026.6.34-boon.7 CHANGELOG.md section and the generated extensions/matrix/CHANGELOG.md entry. No config schema, plugin-SDK surface, or plugin source/dependency change in slack/msteams/diagnostics-prometheus; this is a gateway-only roll. Co-authored-by: Claude Sonnet 5 <[email protected]>
Related: ENG-21233 (internal Linear)
What Problem This Solves
Resolves a problem where a channel plugin's own external
abortSignalfiring as a timeout (e.g. a plugin-level per-turn wall-clock budget) was reported as a run error (success: false+ an error string) instead of a clean interruption, and surfaced in Sentry telemetry with a misleading suffix (Turn budget exceeded | 23) that looked like a turn-count limit but is actuallyDOMException.codeforTimeoutErrorleaking through the generic error formatter's cause-chain code-append.Why This Change Was Made
Added
isExternalTimeoutAbortRejection(src/agents/embedded-agent-runner/abort.ts), gated onexternalAbort && timedOut && isRunnerAbortError(err), and used it inattempt.ts's prompt catch block so this one specific rejection shape (theabortable()wrapper echoing a caller's own externalabortSignalthat fired as a timeout) leavespromptErrorunset. OpenClaw's own internal watchdogs (scheduleAbortTimer, idle timeout) never setexternalAbort, so they are unaffected and still report as errors — this is scoped narrowly to a caller-driven timeout, not any abort-shaped rejection.extensions/sentry-monitor/src/captures.tsis updated alongside: asuccess:falseagent_endevent with no error text (exactly the shape this produces) now reports as a low-severitymessagecapture instead of anexception, since an expected, policy-driven stop should not page the fleet the same way a genuine crash does.No change to the upstream-owned
src/plugins/hook-types.ts(PluginHookAgentEndEvent), no new config surface, and no plugin-specific special-casing — the predicate keys only onAbortSignal/TimeoutErrorsemantics, so it benefits any plugin that passes an external abort signal with a timeout reason, not just the one that surfaced this.User Impact
"error"to"aborted"/"interrupted"(attempt-trajectory-status.ts,harness/lifecycle.ts— no code change needed there, both already branch onexternalAbort/timedOutahead ofpromptError).promptError-driven throw path inrun.tsis already!aborted-guarded except the Codex app-server recovery block (run.ts:3086), which is now correctly skipped for this path — an externally-aborted run must not be re-driven through app-server retry/failover.Evidence
src/agents/embedded-agent-runner/abort.test.ts(9 cases): the exact external-timeout shape → true; OpenClaw's own internal-watchdog timeout (never setsexternalAbort) → stays false/still an error; an external non-timeout abort (user cancel/restart) → false; a genuine prompt error racing an external abort → false; a loose "...aborted..." message match without the state flags → false; a regression anchor reproducing the literal"Turn budget exceeded | 23"string end-to-end through the realabortable()wrapper andformatErrorMessage, confirming the predicate (not a formatter change) is what suppresses it from reachingerror.attempt-trajectory-status.test.ts: the exact{ promptError: undefined, aborted: true, externalAbort: true, timedOut: true }shape now resolves to"interrupted".extensions/sentry-monitor/src/captures.test.ts: the existing "falls back to a generic message" case now assertskind: "message"/level: "info"instead of an exception capture.pnpm test src/agents/embedded-agent-runner/abort.test.ts src/agents/embedded-agent-runner/run/attempt-trajectory-status.test.ts src/agents/harness/lifecycle.test.ts extensions/sentry-monitor/src/captures.test.ts— 101 tests passedpnpm test src/agents/embedded-agent-runner/run.prompt-timeout-fallback.test.ts src/agents/embedded-agent-runner/run.timeout-triggered-compaction.test.ts— 18 tests passed (regression guard: a genuine provider-levelpromptErrorwithaborted:falsestill throwsFailoverErroras before)pnpm tsgo— cleannode scripts/run-oxlint.mjson touched files — cleanCompanion PR in
anychat-boon-web(getboon/anychat-boon-web#166) adds a wrap-up warning injected into the live agent before this abort fires, so the agent gets a real chance to converge to an answer instead of only ever hitting this abort path.🤖 Generated with Claude Code
Summary by cubic
Classifies a caller's external timeout abort as a clean interruption instead of a run error, so policy-driven turn-budget stops no longer page fleet telemetry with the misleading
Turn budget exceeded | 23string —23is the DOMException numeric code forTimeoutError, not a turn-count ceiling.isExternalTimeoutAbortRejectionpredicate, gated onexternalAbort+timedOut+ an abort-shaped rejection, and applies it in both the prompt catch and the async-task-wait catch so a still-pending async task can't repopulate an error after the abort.agent_endevents with no error text as low-severity warning messages instead of exceptions.Written for commit d93ee57. Summary will update on new commits.