Skip to content

fix(failover): classify edge/WAF HTML 429 as transient timeout, not model rate-limit - #86

Merged
convyusboy merged 2 commits into
boonfrom
fix/edge-html-429-misclassified-rate-limit
Jul 29, 2026
Merged

convyusboy merged 2 commits into
boonfrom
fix/edge-html-429-misclassified-rate-limit

Conversation

@convyusboy

@convyusboy convyusboy commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

A Cloudflare/edge WAF in front of boon-llm-gateway intermittently returns a 429 with an HTML "Blocked" body. The gateway relays that same 429 to every model hop, so openclaw classified it as a provider rate_limit, walked and exhausted the fallback chain, and surfaced a false "all models rate-limited" message on healthy, low-volume traffic (the Arguijo incident: ~67 req/day from one fixed IP, no model was actually rate-limited).

Why This Change Was Made

The failover-decision classifier never inspected the 429 body for HTML. The existing HTML short-circuit in classifyFailoverSignal only fires for statuses 408/499/5xx (isTransportHtmlErrorStatus), so an HTML 429 fell straight through to the status === 429 branch → rate_limit. As a result the transient external edge blip was indistinguishable from a real provider rate-limit in both behavior and metrics.

This change makes the status === 429 branch of classifyFailoverClassificationFromHttpStatus detect an HTML/Cloudflare body (new shared helper isEdgeBlockErrorBody, composing the existing isHtmlErrorResponse + isCloudflareOrHtmlErrorPage) and classify it as timeout instead of rate_limit. Billing 429s are checked first and still win.

To avoid regressing the already-shipped client-side ride-out retry — which keyed on rate_limit/overloaded only and would have dropped the now-timeout edge 429 out of the loop — isPureTransientRateLimitSummary now also matches edge-block attempts by their preserved raw HTML body (attempt.error). Genuine model timeouts (no HTML body) stay excluded.

Scope is code only; the Cloudflare/EC2 WAF rule tuning, egress allowlisting, and external paging alerts are handled separately by ops.

User Impact

  • No customer-facing "all models rate-limited" message is produced by an edge block: the existing whole-chain backoff retry absorbs the blip, and if it ever surfaces it uses the honest transient-busy copy instead of a false rate-limit.
  • An edge 429 is now observably distinct from a real provider rate_limit: the model.failover metric carries reason=timeout (vs rate_limit), and the observation path already tags providerRuntimeFailureKind=upstream_html — giving ops a scrapeable signal to alert on.
  • No behavior change for real provider 429s (plain JSON → still rate_limit) or billing 429s (→ still billing).

Evidence

Classifier (src/agents/embedded-agent-helpers/errors.ts): new isEdgeBlockErrorBody; HTML-429 → timeout in the status === 429 branch (after billing).
Retry continuity (src/auto-reply/reply/agent-runner-execution.ts): isPureTransientRateLimitSummary widened to match edge-block attempts by HTML body.

Tests (run via node scripts/run-vitest.mjs, linked-worktree path):

  • src/agents/embedded-agent-helpers.isbillingerrormessage.test.ts — 155 passed, incl. new cases: HTML 429 → timeout, Cloudflare-challenge 429 → timeout, plain JSON 429 → rate_limit, billing 429 → billing, classifyProviderRuntimeFailureKind → upstream_html.
  • src/auto-reply/reply/agent-runner-execution.test.ts — 222 passed, incl. new cases: an edge block classified as timeout (HTML body) still rides out and recovers; a genuine model timeout (no HTML body) does NOT trigger the edge-block backoff loop.
  • oxfmt clean on all touched files. Two parallel code reviews: no functional bugs; status/body preservation and billing-wins ordering independently confirmed.

Follow-up (out of repo): Cloudflare rule identification + EC2 egress allowlist (mirror Render's tweak) + edge-429 alert wiring, using the new reason=timeout / upstream_html signals.

🤖 Generated with Claude Code


Summary by cubic

Fixes misclassification of edge/WAF HTML 429s in front of boon-llm-gateway by treating them as transient timeouts instead of provider rate limits, and keeps the ride‑out retry for these cases without retrying HTML auth/format errors. Metrics now reflect the true cause. (Linear ENG-14852)

  • Bug Fixes
    • Added isEdgeBlockErrorBody and used it in the 429 path to classify HTML-bodied/Cloudflare 429s as timeout (billing 429s → billing; JSON 429s → rate_limit).
    • Ride-out retry: widened isPureTransientRateLimitSummary to include edge blocks only when reason === "timeout" using the preserved HTML body; genuine model timeouts (no HTML) remain excluded.
    • Observability: edge 429s emit reason=timeout; providerRuntimeFailureKind=upstream_html.
    • Tests updated: HTML 429 and Cloudflare challenge 429 → timeout; plain JSON 429 → rate_limit; billing 429 → billing; updated prior 429-HTML assertion to the new behavior; added ride-out vs real-timeout cases.

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

Review in cubic

…odel rate-limit

A Cloudflare/edge WAF in front of boon-llm-gateway intermittently returns a
429 with an HTML "Blocked" body. The gateway relays it on every model hop, so
openclaw classified it as a provider rate_limit, exhausted the fallback chain,
and surfaced a false "all models rate-limited" message on healthy low-volume
traffic (the Arguijo incident).

The 429 branch of classifyFailoverClassificationFromHttpStatus now detects an
HTML/Cloudflare body (via the shared isEdgeBlockErrorBody helper composing the
existing isHtmlErrorResponse + isCloudflareOrHtmlErrorPage) and classifies it
as timeout instead of rate_limit. Billing 429s are checked first and still win.

This makes an edge 429 observably distinct from a real provider rate-limit in
the model.failover metric (reason=timeout vs rate_limit; observation path
already tags upstream_html). To keep the already-shipped client-side ride-out
retry firing after the reclassification, isPureTransientRateLimitSummary now
also matches edge-block attempts by their preserved raw HTML body, so the
transient-busy backoff loop still absorbs the blip while genuine model timeouts
(no HTML body) stay excluded.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@claude

claude Bot commented Jul 28, 2026

Copy link
Copy Markdown

Claude Code is working…

I'll analyze this and get back to you.

View job run

@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

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

Fix all with cubic | Re-trigger cubic

…TML test

Address PR review + CI:

- isPureTransientRateLimitSummary now gates the HTML-body edge-block check on
  reason === "timeout", so HTML auth (401/403 -> auth) and format (400/422 ->
  format) failures are not swept into the blind ride-out retry loop and keep
  their actionable copy. Real edge blocks (429/5xx HTML -> timeout) still ride
  out.
- Update the pre-existing openclaw#67517 test that asserted 429 HTML -> rate_limit to
  the new canonical behavior (429 HTML -> timeout); plain JSON 429 stays
  rate_limit.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@gandalfboon gandalfboon 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 — reviewed the full diff, verified the logic, and ran the tests locally on the PR branch.

Correctness

  • HTML-429 → timeout is inserted in the status === 429 branch after the billing check (billing 429 still wins) and before the rate_limit fallthrough. Plain JSON 429 stays rate_limit. Ordering is right.
  • isEdgeBlockErrorBody cleanly composes the existing isHtmlErrorResponse + isCloudflareOrHtmlErrorPage — reuse, no duplication.
  • The isPureTransientRateLimitSummary widening is correctly gated on reason === "timeout", so HTML auth (401/403→auth) and format (400/422→format) errors keep their actionable copy and are NOT swept into the blind ride-out loop. Only real edge blocks ride out.

Tests — ran all three touched suites on this branch:

  • embedded-agent-helpers.isbillingerrormessage.test.ts — 155 passed
  • agent-runner-execution.test.ts — 222 passed (incl. ride-out-vs-real-timeout cases)
  • provider-error-patterns.test.ts — 39 passed (updated openclaw#67517 429-HTML assertion to timeout)
    oxfmt clean on all touched files.

Ticket (ENG-14852) — this is the client-side classification slice: satisfies AC #3 (edge-429 observably distinct from provider rate_limit via reason=timeout / upstream_html) and AC #5 (no false all-models-rate-limited from an edge block). The WAF rule-tuning, egress allowlist, and edge-429 alerting ACs are correctly and explicitly deferred to ops as out-of-repo follow-up.

No secrets, no migrations, no breaking contract changes. Ship it.

@convyusboy
convyusboy merged commit 1ca4b57 into boon Jul 29, 2026
146 of 148 checks passed
@convyusboy
convyusboy deleted the fix/edge-html-429-misclassified-rate-limit branch July 29, 2026 10:38
convyusboy added a commit that referenced this pull request Jul 30, 2026
Version-bump release carrying the 3 commits merged onto boon since boon.11:

- #86: edge/WAF HTML 429 now classifies as transient timeout (not model
  rate_limit), so a Cloudflare-relayed 429 no longer surfaces a false
  'all models rate-limited'; the client-side ride-out retry still absorbs it.
- #88: DEBUG-level trace of the Slack thread-resolution decision on the agent
  message-send tool path (sendMessage/uploadFile); observability only, no
  behavior change, message content never logged.
- #89: sentry-monitor classifies gateway-relayed upstream (Bedrock) 5xx vs
  gateway-origin 5xx via classify5xxSource(), tagging error_class + http_status
  on the model_call_ended capture so the Rohan alert can split/rate-gate them.

Bumps the gateway + @openclaw/slack + @openclaw/msteams to 2026.6.11-boon.12 in
lockstep (7 files: 3 package.json, 3 npm-shrinkwrap.json, CHANGELOG.md). Tagging
v2026.6.11-boon.12 after merge triggers boon-release.yml to publish the 6 assets.
convyusboy added a commit that referenced this pull request Jul 31, 2026
…ease asset (ENG-15788) (#94)

* release: 2026.6.11-boon.12

Version-bump release carrying the 3 commits merged onto boon since boon.11:

- #86: edge/WAF HTML 429 now classifies as transient timeout (not model
  rate_limit), so a Cloudflare-relayed 429 no longer surfaces a false
  'all models rate-limited'; the client-side ride-out retry still absorbs it.
- #88: DEBUG-level trace of the Slack thread-resolution decision on the agent
  message-send tool path (sendMessage/uploadFile); observability only, no
  behavior change, message content never logged.
- #89: sentry-monitor classifies gateway-relayed upstream (Bedrock) 5xx vs
  gateway-origin 5xx via classify5xxSource(), tagging error_class + http_status
  on the model_call_ended capture so the Rohan alert can split/rate-gate them.

Bumps the gateway + @openclaw/slack + @openclaw/msteams to 2026.6.11-boon.12 in
lockstep (7 files: 3 package.json, 3 npm-shrinkwrap.json, CHANGELOG.md). Tagging
v2026.6.11-boon.12 after merge triggers boon-release.yml to publish the 6 assets.

* feat(release): publish @openclaw/diagnostics-prometheus as a fork release asset (ENG-15788)

The diagnostics-prometheus plugin's dist is excluded from the published gateway
package (`!dist/extensions/diagnostics-prometheus/**`), so a fleet host has no
way to run the Prometheus exporter unless the plugin is installed separately —
and gandalf-manager's Alloy scrape (job boon-agent-openclaw, ENG-15788 step 2)
has nothing to read until it is. There was no release tarball for it.

- Pin extensions/diagnostics-prometheus/package.json + npm-shrinkwrap.json to
  2026.6.11-boon.12 in lockstep with the gateway (same contract as slack/msteams
  — the pack step asserts TAG == v<version>).
- Add a 'Pack diagnostics-prometheus plugin tarball + compute sha256' step to
  boon-release.yml mirroring the slack/msteams steps (runtime-build + manifest
  overlay pack), and wire the new asset + its .sha256 into the Publish step (both
  create and upload --clobber arms) so it ships on the same v*-boon.N tag.

Asset contract:
  openclaw-diagnostics-prometheus-<version>.tgz + .tgz.sha256

Unlike slack/msteams this plugin does NOT use openKeyedStore (no trust-gate), so
a bare install wouldn't crash-loop — but the npm-pack: trusted path is used for
install-shape consistency across the fork's plugins. Version must advance in
lockstep on every future release, same as slack/msteams. actionlint clean; YAML
valid. Pack machinery validated by CI on the release run (no node_modules in this
worktree to pack locally).
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.

1 participant