Skip to content

fix(media): raise image vision timeout and stop it paging on exhaustion - #293

Merged
convyusboy merged 5 commits into
boonfrom
ridho/eng-21406-sentryfleet-openclaw-fleet-x8-image-vision-description
Oct 15, 2026
Merged

convyusboy merged 5 commits into
boonfrom
ridho/eng-21406-sentryfleet-openclaw-fleet-x8-image-vision-description

Conversation

@convyusboy

@convyusboy convyusboy commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Related: Linear ENG-21406, Sentry OPENCLAW-FLEET-X8

What Problem This Solves

Fixes an issue where agents analyzing large, dense multi-sheet architectural plan images in Boon Chat would hard-time-out at exactly 60s and page Sentry (OPENCLAW-FLEET-X8) across the fleet, losing the user's answer.

Why This Change Was Made

The image-understanding timeout was already converted to a graceful tool result rather than a crash by an earlier fix, but it still classified as an upstream error and paged on every occurrence, and the default budget (60s) was too tight for dense plan sheets under real provider latency. This change raises the default to 150s (sized above boon-llm-gateway's own 120s fallback-chain budget), closes a latent bug where setup, the provider request, and its retry each independently raced the full configured timeout (worst case ~3x the configured budget), and converts the timeout into a graceful status: "timeout" result with retry guidance that the Sentry monitor now downgrades to a warning instead of paging.

MiniMax VLM provider calls are deliberately left on the old per-phase timeout behavior (documented in code): that provider's own timeout resolver treats a falsy/zero value as "unset" and substitutes its own 60s default, so forwarding a near-exhausted shared budget there would silently grant extra time instead of enforcing a limit.

Out of scope: latency-triggered progressive downscaling (the existing size-triggered compression ladder already caps resolution and shrinking further would destroy the legibility of plan-sheet text), and scaling the Codex harness watchdog grace to a configured image-model fallback count (a separate, pre-existing gap, now documented rather than fixed in this change).

User Impact

Large, dense plan-set images complete instead of timing out at 60s. When a vision request genuinely can't complete in time, the agent now gets actionable text ("retry, or narrow to a single sheet / crop a region") and the turn continues, instead of the turn ending on a raw error. Operators stop getting paged for routine vision-model latency.

Evidence

  • 218 tests passing across the four touched suites (image.test.ts, image-tool.test.ts, captures.test.ts, dynamic-tool-execution.test.ts), run three times with no flakiness.
  • New tests cover: the raised default resolving to 150s end-to-end through the tool; the single-model-candidate graceful timeout result; the fallback-configured case (proving the FailoverError/FallbackSummaryError .cause chain is unwrapped correctly); the full classifyToolCallErrorKind chain from the tool result to errorKind: "timeout"; the sentry-monitor downgrade scoped to the image tool only (with a sibling test proving other tools' timeouts still page); and the shared-deadline arithmetic (a slow setup leaves correspondingly less time for the request, not a fresh window).
  • tsgo:core, tsgo:extensions, and tsgo:extensions:test typecheck clean. tsgo:core:test passed clean on an earlier revision of this diff; a later re-run (after one small supplementary test edit) was killed by the local environment's memory-pressure guard before completing — the edited test itself passed at runtime under Vitest in the same run that confirmed all 218 tests green.

🤖 Generated with Claude Code


Summary by cubic

Fixes the image vision tool hard-timing out at 60s on large, dense plan-set images and paging Sentry (OPENCLAW-FLEET-X8), so those requests now complete and genuine timeouts degrade gracefully instead of ending the turn.

  • Raises the default image timeout from 60s to 150s, sized above boon-llm-gateway's own 120s provider-fallback-chain budget.
  • Makes setup, the provider request, and the reasoning-only retry share one end-to-end 150s deadline per model-description attempt instead of each phase independently racing the full budget (previously up to ~3x). MiniMax VLM calls keep the old per-phase behavior because its timeout resolver treats a falsy value as unset; each configured fallback candidate gets a fresh budget.
  • Converts a vision timeout into a graceful status: "timeout" tool result with retry guidance, so the turn continues and the Sentry monitor downgrades it to a warning instead of paging (scoped to the image tool only). Near-deadline timeout rejections from a provider SDK's own internal timeout or MiniMax's native AbortSignal.timeout are normalized into the shared timeout error, but a late rejection carrying an HTTP status code is never treated as a timeout — a status means a response actually came back.
  • Checks the remaining budget before dispatching the provider request, so an already-exhausted deadline doesn't still send a doomed request.
  • Brings the Codex dynamic-tool watchdog in line with the raise, adding a 30s grace so the outer budget never sits below the inner deadline. The harness docs now also note the remaining watchdog gaps: it doesn't see a per-image-model timeoutSeconds override, and each fallback candidate's fresh inner budget isn't covered by the single-candidate grace.

Written for commit 3bfbcf3. Summary will update on new commits.

View guided diff Turn on auto-fix

@convyusboy
convyusboy requested a review from a team October 14, 2026 16:21

@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.

cubic analysis

All reported issues were addressed across 13 files

Linked issue analysis

Linked issue: ENG-21406: [Sentry][Fleet] OPENCLAW-FLEET-X8: Image vision description requests hard-timeout after 60s on complex plan sets

Status Acceptance criteria Notes
✅ Increase the image timeout to 120–180 seconds The default image timeout is raised to 150 seconds in the media-understanding defaults.
✅ Return retry guidance instead of crashing on timeout The image tool returns a graceful timeout result with retry and narrowing guidance when the request deadline expires.
✅ Avoid paging on image timeout events The Sentry monitor downgrades image-tool timeouts to warnings while leaving other tool timeouts unchanged.

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/media-understanding/image.ts Resolved
Comment thread src/media-understanding/image.ts Resolved
Comment thread docs/gateway/config-tools.md Resolved
Comment thread src/media-understanding/image.ts Resolved
Comment thread src/media-understanding/image.ts Resolved
Comment thread src/media-understanding/image.test.ts Resolved
Comment thread src/media-understanding/image.test.ts Resolved
Comment thread src/agents/tools/image-tool.ts Resolved
Comment thread src/media-understanding/image.ts Resolved

@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 12 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread docs/plugins/codex-harness.md Resolved
Comment thread src/media-understanding/image.ts Resolved

@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.

✅ Approved

This PR resolves Linear issue ENG-21406 and Sentry issue OPENCLAW-FLEET-X8 by raising the default image vision timeout from 60s to 150s (sized above boon-llm-gateway's 120s fallback-chain ceiling), sharing one deadline across setup, requests, and reasoning retries, and converting timeout rejections into graceful structured tool results (status: "timeout") with retry guidance that Sentry downgrades to non-paging warnings.

Strengths

  • Single shared deadline arithmetic: Setup, provider dispatch, and reasoning-only retries now draw from one end-to-end deadlineAtMs budget instead of each phase independently racing the full timeout window (which previously allowed up to ~3x the configured budget before failing).
  • Graceful degradation for agent UX: Instead of hard-failing and crashing the agent turn on vision latency, the image tool catches ImageDescriptionTimeoutError (walking up to 5 .cause hops for fallback lists) and returns actionable user/agent guidance with status: "timeout".
  • Targeted Sentry downgrade: Scoped specifically to event.toolName === "image" && event.errorKind === "timeout" in extensions/sentry-monitor/src/captures.ts, ensuring other tool timeouts (e.g. sessions_send) continue reporting as actionable exceptions.
  • Defensive provider normalization: Near-deadline provider rejections (within 10% / max 5s) without HTTP status codes are normalized to ImageDescriptionTimeoutError, while responses with HTTP status codes (e.g. 401/429/500) are strictly preserved. MiniMax's native AbortSignal.timeout (TimeoutError) is likewise caught and normalized.
  • Codex watchdog alignment & documentation: CODEX_DYNAMIC_IMAGE_TOOL_TIMEOUT_MS is bumped to 150s + 30s grace (180s total) in extensions/codex/src/app-server/dynamic-tool-execution.ts, preventing the outer watchdog from killing the tool before the inner timeout fires.

Technical Review & Verification

  • ✅ Codex dependency contract verified: Personally inspected sibling ../codex source at:
    • ../codex/codex-rs/app-server/src/dynamic_tools.rs:25-50 (on_call_response and fallback_response decoding)
    • ../codex/codex-rs/app-server-protocol/src/protocol/common.rs:1796-1800 (DynamicToolCall => "item/tool/call")
    • ../codex/codex-rs/app-server-protocol/src/protocol/v2/item.rs:1669 (DynamicToolCallResponse)
      Confirming that OpenClaw's structured response with success and content_items delivers cleanly across the dynamic tool execution protocol.
  • ✅ Targeted suites passing locally:
    • src/agents/tools/image-tool.test.ts (100/100 tests green)
    • extensions/sentry-monitor/src/captures.test.ts (71/71 tests green)
    • extensions/codex/src/app-server/dynamic-tool-execution.test.ts (18/18 tests green)
    • src/media-understanding/apply.test.ts (56/56 tests green)
    • src/media-understanding/image.test.ts (32/32 tests green when isolated)
  • ✅ Typecheck & Lints: pnpm tsgo:prod and pnpm tsgo:extensions:test pass cleanly with zero errors. All cubic review comments (P1-P3) have been addressed and marked resolved.

Minor Non-Blocking Suggestion

  • In src/media-understanding/image.test.ts:894 (clamps oversized image description timeouts before scheduling):
    expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS);
    checks exact equality against MAX_TIMER_TIMEOUT_MS. Because setup now passes remainingTimeoutMs(deadlineAtMs), if the system clock advances by even 1ms between startedAtMs and the setup timer scheduling, setTimeout is called with 2146999999 rather than 2147000000. Checking setTimeoutSpy.mock.calls against an interval <= MAX_TIMER_TIMEOUT_MS && >= MAX_TIMER_TIMEOUT_MS - 5_000 (matching line 902) or freezing timers with vi.useFakeTimers() will prevent potential timing flakiness under heavy test concurrency.

CI Status ✅

  • GitHub Actions check runs: All checks passed (50+ checks completed green, CodeQL/Cubic passing, 0 failures).
  • Mergeable: MERGEABLE.

Post-Deploy Monitoring

  • Monitor Sentry OPENCLAW-FLEET-X8: verify that image-understanding timeouts now log as non-paging warning messages instead of paging errors.
  • Monitor Boon Chat image understanding latency and completion rate on multi-sheet plan sets to confirm successful completions within the 150s window.

Verdict: Approved. Ready to merge.

convyusboy and others added 5 commits October 15, 2026 09:06
ENG-21406: dense multi-sheet plan images regularly exceeded the image
tool's 60s default, hard-timing out mid-request and paging Sentry
(OPENCLAW-FLEET-X8) across the fleet. The timeout became an isError
tool result rather than a crash, but that result still classified as
"upstream" and paged on every occurrence.

- Raise DEFAULT_TIMEOUT_SECONDS.image 60s -> 150s, sized above
  boon-llm-gateway's own 120s provider-fallback-chain budget so the
  gateway finishes its own fallback before OpenClaw gives up.
- Mirror the raise in the Codex dynamic-tool watchdog
  (CODEX_DYNAMIC_IMAGE_TOOL_TIMEOUT_MS), with the same headroom grace
  already applied to explicit per-call timeouts.
- describeImagesWithModelInternal now shares one deadline across
  runtime/auth setup and the provider request (including the
  reasoning-only retry), instead of each phase independently racing
  the full configured timeout -- previously up to ~3x the configured
  budget before a call ever failed. MiniMax VLM calls are deliberately
  kept on the old per-phase behavior: minimaxUnderstandImage treats a
  falsy/zero timeout as "unset" and substitutes its own 60s default,
  so forwarding a near-zero shared remainder there would silently
  grant a fresh budget instead of enforcing one.
- A new ImageDescriptionTimeoutError carries a stable name so the
  image tool can classify a timeout thrown across the lazy
  image-runtime.ts boundary without a static import, including through
  the FailoverError/FallbackSummaryError wrapping a configured
  fallback list applies.
- The image tool now returns a graceful `status: "timeout"` result
  with retry guidance instead of letting the raw error end the turn.
  That status routes through classifyToolCallErrorKind as "timeout",
  which the sentry-monitor extension now downgrades to a warning
  instead of paging, scoped to the image tool only.

Tests: 218 passing across the four touched suites (image.test.ts,
image-tool.test.ts, captures.test.ts, dynamic-tool-execution.test.ts),
run three times with no flakiness. tsgo:core, tsgo:extensions, and
tsgo:extensions:test typecheck clean; tsgo:core:test passed once
before a later supplementary edit, which Vitest's own transform/run
has since proven correct at runtime.

Not in scope: latency-triggered progressive downscaling (the ticket's
AC item 2) -- the existing size-triggered ladder already caps at
2048px and shrinking further would destroy plan-sheet text legibility;
and scaling the Codex watchdog grace to a configured fallback count,
a pre-existing gap now documented rather than fixed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Addresses automated review feedback on the image vision timeout PR:

- Normalize a provider SDK's own near-deadline timeout rejection (some
  SDKs enforce streamOptions.timeoutMs as their own internal HTTP
  timeout, starting before our race begins and able to win it) into
  ImageDescriptionTimeoutError instead of letting it escape unclassified.
- Normalize MiniMax's native AbortSignal.timeout rejection the same way,
  so MiniMax-configured image models get the same graceful degradation
  and Sentry downgrade as every other provider.
- Check the remaining budget before dispatching the provider request,
  not only after, so an already-exhausted deadline doesn't still send
  a doomed request.
- Export DEFAULT_MINIMAX_VLM_TIMEOUT_MS so the normalized MiniMax
  timeout error can report an accurate value when no outer budget is
  configured.
- Fix check-lint CI failure (oxlint prefer-includes).
- Clarify docs: the shared budget is per model-description attempt, not
  per whole image-tool call (fallback candidates and MiniMax's
  per-image loop each still get a fresh budget); the Codex watchdog
  grace doesn't see a per-image-model timeoutSeconds override.
- Remove Linear ticket/Sentry incident identifiers from source comments
  per repo policy, keeping only the durable technical rationale.
- Tighten a test's timing tolerance from 60s to 5s so it still catches a
  real regression.
- Decline (reply + resolve) the request for latency-triggered
  progressive downscaling: already explicitly out of scope per the
  approved plan, since the existing size-triggered compression ladder
  already caps resolution and shrinking further would destroy
  plan-sheet text legibility.

Tests: 220 passing across the four touched suites, plus two new
regression tests (provider-race normalization, MiniMax native timeout
normalization).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
oxlint's use-unknown-in-catch-callback-variable rule requires an
explicit : unknown annotation on a Promise.prototype.catch() callback
parameter (unlike a try/catch block, which TypeScript already infers
as unknown).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…eout

The Antigravity CLI auto-fallback test hardcoded the old 60s image
default; it now references DEFAULT_TIMEOUT_SECONDS.image directly so it
can't drift from the real default again. The audio CLI timeout
assertions elsewhere in this file are correctly unchanged (audio's
default stays 60s).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
…rclaims

Addresses a second round of cubic review feedback:

- Restrict the near-deadline normalization in withImageDescriptionTimeout
  to rejections that do NOT carry an HTTP status code. A status means a
  response actually came back (auth/rate-limit/server error), which is
  never a timeout regardless of when it lands in the race — previously
  any late rejection was normalized, which could have mislabeled a real
  late failure as a routine timeout. New regression test.
- Document the fallback-candidate gap in both codex-harness docs: a
  configured imageModel fallback list gives each candidate its own
  fresh inner deadline, so the outer Codex watchdog's single-candidate
  grace doesn't cover a slow first candidate's later fallbacks either.
- Fix an overclaim in the sentry-monitor downgrade comment/test: the
  image tool is not the only producer of a "timeout" errorKind
  (sessions_send also returns one); the downgrade is still correctly
  scoped by toolName, the comment just overstated why.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@convyusboy
convyusboy force-pushed the ridho/eng-21406-sentryfleet-openclaw-fleet-x8-image-vision-description branch from 98bfc27 to 3bfbcf3 Compare October 15, 2026 02:08
@convyusboy
convyusboy merged commit 2607666 into boon Oct 15, 2026
145 checks passed
@convyusboy
convyusboy deleted the ridho/eng-21406-sentryfleet-openclaw-fleet-x8-image-vision-description branch October 15, 2026 03:00
convyusboy added a commit that referenced this pull request Oct 15, 2026
Cut the fork release that ships the six commits on boon since
v2026.6.34-boon.7:

- #292 (ENG-21407): resolve relative media/PDF paths against the agent
  workspace in pdf, image_generate, video_generate, and music_generate,
  instead of the gateway process cwd; delete the image tool's duplicate
  inline resolution now that the loader owns it canonically.
- #289 (ENG-21228): let image, pdf, image_generate, video_generate, and
  music_generate read agent-rendered files outside the default roots
  (e.g. /tmp crops) when the agent is permitted host reads outside its
  workspace, matching the outbound MEDIA: path; a blocked path now
  returns a denied tool result instead of a raw error that paged Sentry.
- #293 (ENG-21406): raise the image tool's default vision timeout 60s ->
  150s (above boon-llm-gateway's 120s fallback-chain budget), share one
  deadline across setup and the provider request, and return a graceful
  timeout status instead of letting the raw error end the turn; mirrored
  in the Codex dynamic-tool watchdog; sentry-monitor downgrades image
  timeouts to a warning.
- #291: sentry-monitor no longer pages on ordinary non-zero exec exit
  codes; only shell lookup failures (126/127) stay exceptions, now
  fingerprinted per missing binary. Runtime Docker image adds unzip.
- #288 (ENG-21227): memory_search no longer pauses/pages Sentry while
  the index is still building ("missing" identity); only a real
  "mismatched" embedding provider pauses it.
- #294 (ENG-21405, test-only): regression coverage confirming the cron
  delivery-target guard already rejects a directory-less channel's
  unknown target end to end; root cause for the live Sentry errors was
  a stale anychat-boon-web plugin install, not a core gap.

Bump root package.json and npm-shrinkwrap.json, all 136 plugin
manifests, and the version field in every extension's
npm-shrinkwrap.json via pnpm plugins:sync, hand-patched the same way as
boon.7 (the npm-shrinkwrap generator still can't regenerate cleanly on
this fork: pre-existing, unrelated @sentry/node nested
@opentelemetry/resources / sdk-trace-base registry-resolution drift,
reproduced again on this base). Verified via
test/package-manager-config.test.ts (12/12) and the full
release-preflight check suite (plugin versions, inventory, base config
schema, bundled channel config metadata, config docs baseline, plugin
SDK exports/API baseline/surface budget, root dependency ownership) --
all green except the known shrinkwrap generator drift. Add the
2026.6.34-boon.8 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 (bundled-plugin source changes in codex, memory-core, and
sentry-monitor ship inside the gateway tarball). Targeted tests for all
three touched extensions plus the codex dynamic-tool-execution suite:
1075/1075 passing.

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