Skip to content

fix(agents): classify a caller's external timeout abort as a clean interruption - #283

Merged
convyusboy merged 7 commits into
boonfrom
ridho/eng-21233-sentryfleet-openclaw-fleet-14x-customer-turns-abort-with
Oct 13, 2026
Merged

convyusboy merged 7 commits into
boonfrom
ridho/eng-21233-sentryfleet-openclaw-fleet-14x-customer-turns-abort-with

Conversation

@convyusboy

@convyusboy convyusboy commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Related: ENG-21233 (internal Linear)

What Problem This Solves

Resolves a problem where a channel plugin's own external abortSignal firing 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 actually DOMException.code for TimeoutError leaking 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 on externalAbort && timedOut && isRunnerAbortError(err), and used it in attempt.ts's prompt catch block so this one specific rejection shape (the abortable() wrapper echoing a caller's own external abortSignal that fired as a timeout) leaves promptError unset. OpenClaw's own internal watchdogs (scheduleAbortTimer, idle timeout) never set externalAbort, 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.ts is updated alongside: a success:false agent_end event with no error text (exactly the shape this produces) now reports as a low-severity message capture instead of an exception, 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 on AbortSignal/TimeoutError semantics, so it benefits any plugin that passes an external abort signal with a timeout reason, not just the one that surfaced this.

User Impact

  • Diagnostic/trajectory outcome for this abort shape flips from "error" to "aborted"/"interrupted" (attempt-trajectory-status.ts, harness/lifecycle.ts — no code change needed there, both already branch on externalAbort/timedOut ahead of promptError).
  • Fleet operators stop getting paged for an expected, caller-driven turn-budget stop; a genuine OpenClaw-side internal-watchdog timeout still alerts exactly as before.
  • No behavior change for the calling plugin: every promptError-driven throw path in run.ts is 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

  • New src/agents/embedded-agent-runner/abort.test.ts (9 cases): the exact external-timeout shape → true; OpenClaw's own internal-watchdog timeout (never sets externalAbort) → 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 real abortable() wrapper and formatErrorMessage, confirming the predicate (not a formatter change) is what suppresses it from reaching error.
  • Extended attempt-trajectory-status.test.ts: the exact { promptError: undefined, aborted: true, externalAbort: true, timedOut: true } shape now resolves to "interrupted".
  • Updated extensions/sentry-monitor/src/captures.test.ts: the existing "falls back to a generic message" case now asserts kind: "message" / level: "info" instead of an exception capture.
  • Validation (all green):
    • 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 passed
    • pnpm 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-level promptError with aborted:false still throws FailoverError as before)
    • pnpm tsgo — clean
    • node scripts/run-oxlint.mjs on touched files — clean

Companion 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 | 23 string — 23 is the DOMException numeric code for TimeoutError, not a turn-count ceiling.

  • Adds the isExternalTimeoutAbortRejection predicate, gated on externalAbort + 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.
  • OpenClaw's own internal-watchdog timeouts and genuine errors still report as errors.
  • Reports agent_end events with no error text as low-severity warning messages instead of exceptions.

Written for commit d93ee57. Summary will update on new commits.

View guided diff Turn on auto-fix

…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]>
@convyusboy
convyusboy requested a review from a team October 12, 2026 12:03

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>

@boon-hermes-bot boon-hermes-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>
convyusboy and others added 2 commits October 13, 2026 18:41
…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]>
@convyusboy
convyusboy enabled auto-merge (squash) October 13, 2026 12:52
@convyusboy
convyusboy disabled auto-merge October 13, 2026 12:53
@convyusboy
convyusboy merged commit 41ce68e into boon Oct 13, 2026
144 checks passed
@convyusboy
convyusboy deleted the ridho/eng-21233-sentryfleet-openclaw-fleet-14x-customer-turns-abort-with branch October 13, 2026 12:54
convyusboy added a commit that referenced this pull request Oct 13, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants