Skip to content

fix(status): surface model-pricing health degradation - #80277

Merged
steipete merged 3 commits into
mainfrom
codex/model-pricing-health
May 10, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/model-pricing-health

Conversation

@steipete

@steipete steipete commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Track model-pricing bootstrap/refresh failures in gateway-owned pricing cache state and clear them after successful source refreshes.
  • Surface degraded model-pricing state through health snapshots, cached health RPC responses, openclaw health, openclaw status, openclaw status --json, and openclaw gateway status warnings without changing liveness semantics.
  • Add focused regressions for swallowed pricing source failures, cached health merging, and CLI/status rendering.

Fixes #79599.

Real behavior proof

Behavior addressed: Gateway model-pricing catalog/bootstrap failures should be visible in health/status as degraded model-pricing state while Gateway liveness remains healthy.

Real setup tested: Local foreground OpenClaw Gateway on macOS using temporary profile pricing-proof-80277 on port 19077. Pricing catalog fetches were forced to fail before Gateway startup to simulate the reported upstream/bootstrap failure mode.

Exact steps or command run after the patch:

$ pnpm openclaw --profile pricing-proof-80277 gateway --allow-unconfigured --auth none --port 19077 --verbose
$ pnpm openclaw --profile pricing-proof-80277 health --json --timeout 5000

Evidence after fix: Copied live Gateway log and CLI output from that run:

15:13:48 [gateway] ready
15:13:48 [model-pricing] OpenRouter pricing fetch failed: TypeError: proof-forced-pricing-fetch-failure
15:13:48 [model-pricing] LiteLLM pricing fetch failed: TypeError: proof-forced-pricing-fetch-failure

$ pnpm openclaw --profile pricing-proof-80277 health --json --timeout 5000
{
  "ok": true,
  "modelPricing": {
    "state": "degraded",
    "sources": [
      {
        "source": "litellm",
        "state": "degraded",
        "detail": "LiteLLM pricing fetch failed: TypeError: proof-forced-pricing-fetch-failure"
      },
      {
        "source": "openrouter",
        "state": "degraded",
        "detail": "OpenRouter pricing fetch failed: TypeError: proof-forced-pricing-fetch-failure"
      }
    ],
    "detail": "LiteLLM pricing fetch failed: TypeError: proof-forced-pricing-fetch-failure"
  }
}

Observed result after fix: The Gateway stayed live with ok: true, and the health payload exposed modelPricing.state: "degraded" plus per-source openrouter and litellm failure details instead of silently reporting healthy pricing.

What was not tested: No additional gaps for this scoped status/health fix; the scheduled-refresh rejection path is covered by the added regression test.

Verification

  • pnpm test src/gateway/model-pricing-cache.test.ts src/commands/health.test.ts src/gateway/server-methods/server-methods.test.ts src/commands/gateway-status.test.ts src/commands/status.command-report-data.test.ts src/commands/status-json-payload.test.ts src/commands/status.command-sections.test.ts
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/gateway/model-pricing-cache-state.ts src/gateway/model-pricing-cache.ts src/commands/health.types.ts src/commands/health.ts src/gateway/server-methods/health.ts src/commands/gateway-status/output.ts src/commands/status-overview-rows.ts src/commands/status-overview-surface.ts src/commands/status-all/format.ts src/commands/status.command-sections.ts src/gateway/model-pricing-cache.test.ts src/commands/health.test.ts src/gateway/server-methods/server-methods.test.ts src/commands/gateway-status.test.ts src/commands/status.command-report-data.test.ts src/commands/status-json-payload.test.ts
  • pnpm tsgo:core
  • git diff --check
  • OPENCLAW_TESTBOX=0 pnpm check:changed
  • pnpm install --frozen-lockfile --offline --ignore-scripts
  • pnpm test src/plugins/contracts/extension-runtime-dependencies.contract.test.ts

Notes

pnpm check:changed first attempted to delegate to Testbox because OPENCLAW_TESTBOX=1 was present in the environment but no OPENCLAW_TESTBOX_ID was set. The changed-lane planner selected only core/coreTests/docs, so I reran the same gate locally with OPENCLAW_TESTBOX=0; it passed.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations size: L maintainer Maintainer-authored PR labels May 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper autofix

@clawsweeper clawsweeper Bot added the clawsweeper:autofix Maintainer opted this PR into bounded ClawSweeper-reviewed autofix without merge label May 10, 2026
@clawsweeper

clawsweeper Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

🦞🔧
ClawSweeper autofix is enabled.

This is fix-only; I will not merge this PR.

@clawsweeper

clawsweeper Bot commented May 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The branch records model-pricing bootstrap and refresh failures in gateway cache state and renders degraded model-pricing warnings through health, status, gateway-status, JSON outputs, tests, and the changelog.

Reproducibility: no. live runtime reproduction was run in this read-only review. Source inspection shows the current-main path: pricing fetch/bootstrap failures are warning-only, while health/status have no model-pricing field to emit.

Real behavior proof
Not applicable: This is a maintainer-labeled draft PR, so the external contributor real-behavior-proof gate does not apply; the body lists targeted tests but no live runtime proof.

Next step before merge
Human review remains because this PR has a protected maintainer label, draft/dirty state, and an overlapping open contributor PR for the same bug.

Security
Cleared: The diff does not add dependencies, workflows, install hooks, secret handling, or broader permissions; it exposes existing warning detail through operator-read health/status surfaces.

Review details

Best possible solution:

Land one canonical implementation that records pricing source failures in gateway-owned state, keeps gateway liveness healthy, and surfaces degraded model-pricing warnings consistently across health/status outputs.

Do we have a high-confidence way to reproduce the issue?

No live runtime reproduction was run in this read-only review. Source inspection shows the current-main path: pricing fetch/bootstrap failures are warning-only, while health/status have no model-pricing field to emit.

Is this the best way to solve the issue?

Yes, the proposed direction is the narrow maintainable fix: store structured pricing failure state, keep liveness semantics unchanged, and render it through existing operator health/status surfaces. The remaining decision is which overlapping PR should become canonical.

Acceptance criteria:

  • pnpm test src/gateway/model-pricing-cache.test.ts src/commands/health.test.ts src/gateway/server-methods/server-methods.test.ts src/commands/gateway-status.test.ts src/commands/status.command-report-data.test.ts src/commands/status-json-payload.test.ts src/commands/status.command-sections.test.ts
  • pnpm tsgo:core
  • OPENCLAW_TESTBOX=0 pnpm check:changed

What I checked:

  • Live PR state requires human handling: GitHub API shows this PR is open, draft, mergeable=false, mergeable_state=dirty, labeled maintainer, clawsweeper:human-review, and clawsweeper:autofix, with head 08cbc043506f7ef923f7797542580383986b64db. (08cbc043506f)
  • Current main has no pricing health state: Current main's pricing cache state stores cached pricing and cache metadata only; the search found no GatewayModelPricingHealth, recordGatewayModelPricingSourceFailure, model_pricing_degraded, or modelPricing health/status surface on main. (src/gateway/model-pricing-cache-state.ts:23, 4fc09608efa7)
  • Current main logs pricing failures without surfacing them: The current refresh path catches scheduled refresh and OpenRouter/LiteLLM catalog failures, logs warnings, and returns empty maps, but does not record a structured degraded state for health/status consumers. (src/gateway/model-pricing-cache.ts:1124, 4fc09608efa7)
  • Current gateway status warnings omit model pricing: Current main builds gateway-status warnings from SSH, TLS, discovery, auth, scope, and detail-probe failures; JSON degraded is only tied to post-connect probe failure, not subsystem health. (src/commands/gateway-status/output.ts:35, 4fc09608efa7)
  • PR diff adds the intended surfaces: The PR diff adds model-pricing health types and failure ledger helpers, records and clears source failures, merges live pricing health into cached health responses, and adds CLI/status/gateway-status tests for degraded output. (src/gateway/model-pricing-cache-state.ts:65, 08cbc043506f)
  • Related issue and overlapping PR are active: The linked bug remains open, and feat(health): surface model-pricing bootstrap failures (#79599) #79914 is also open for the same model-pricing health/status problem with supplied real-behavior proof.

Likely related people:

  • @steipete: Recent merged commits on the model-pricing cache and status-adjacent surfaces include pricing refresh aborts, local pricing refresh behavior, pricing fetch timeout changes, and status overview changes; this PR author also has current-main history in the affected paths. (role: recent area contributor; confidence: high; commits: 7b5d95671cb5, 5ff49ae03e08, a5a438a17c90; files: src/gateway/model-pricing-cache.ts, src/gateway/model-pricing-cache-state.ts, src/commands/status-overview-rows.ts)
  • @vincentkoc: Recent merged gateway-status diagnostics and status typing work touched the same warning/output and status-report surfaces this PR extends. (role: gateway status diagnostics contributor; confidence: medium; commits: 08ce17c33ddb, 5fa166ed1177; files: src/commands/gateway-status/output.ts, src/commands/gateway-status.test.ts, src/commands/status-overview-rows.ts)
  • @rolandrscheel: Recent merged plugin metadata work changed model-pricing collection behavior in the central pricing cache path this PR extends with health state. (role: recent model-pricing contributor; confidence: medium; commits: aeac10f5cea7; files: src/gateway/model-pricing-cache.ts)

Remaining risk / open question:

  • I did not run the PR's tests or a live gateway repro because this was a read-only review.
  • The branch is dirty and not maintainer-modifiable, so landing may require author-side rebase or replacement even if maintainers choose this implementation.

Codex review notes: model gpt-5.5, reasoning high; reviewed against dc112f833f93.

@clawsweeper clawsweeper Bot added the clawsweeper:human-review Needs maintainer review before ClawSweeper can continue label May 10, 2026
@clawsweeper

clawsweeper Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper is pausing this repair loop for human review.

Source: clawsweeper[bot]
Reason: No automated repair is indicated from this review; maintainers need to resolve draft/dirty landing state and choose between this maintainer rewrite and the overlapping open contributor PR.; Cleared: The diff does not introduce new dependencies, workflow execution, install hooks, secret handling, or gateway permissions; it exposes existing warning detail through operator-read health/status surfaces. (sha=ead7a7a9e92b04b2b17c2836afcc229f0ff858c5)

I added clawsweeper:human-review and left the final call with a maintainer.

@clawsweeper

clawsweeper Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper 🐠 automerge status

This pass ended as a no-op: no narrow repair surfaced, so ClawSweeper left the branch untouched.

Executor outcome: source PR #80277 is paused by clawsweeper:human-review; refusing to mutate the PR branch.
Worker summary: Canonical this PR is the right repair path for issue #79599, but it is not merge-ready: the hydrated preflight shows it is draft, dirty, and has a failing Real behavior proof check. Because the same-repo head branch is writable and fix work is allowed while merge/close are blocked, plan an in-place contributor-branch repair and keep all close/merge actions out of scope.

Worker actions:

  • fix_needed on this PR: planned - Repair the existing writable contributor branch before any merge decision; merge is disabled for this autonomous autofix job.
  • keep_related on #79599: planned - Keep the issue open and associated with the repair candidate until this PR is repaired and validated.
  • build_fix_artifact on cluster:automerge-openclaw-openclaw-80277: planned - A narrow repair artifact is needed to make this PR pass proof, rebase/resolve dirty state, run review, and keep the PR open for maintainer finalization.

This pass stayed observational only. No branch push, replacement, merge, or re-review was started.

fish notes: model gpt-5.5, reasoning high.

Automerge progress:

@clawsweeper

clawsweeper Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper is pausing this repair loop for human review.

Source: clawsweeper[bot]
Reason: Human review remains because this PR has a protected maintainer label, draft/dirty state, and an overlapping open contributor PR for the same bug.; Cleared: The diff does not add dependencies, workflows, install hooks, secret handling, or broader permissions; it exposes existing warning detail through operator-read health/status surfaces. (sha=08cbc043506f7ef923f7797542580383986b64db)

I added clawsweeper:human-review and left the final call with a maintainer.

@steipete
steipete marked this pull request as ready for review May 10, 2026 14:16
@steipete
steipete force-pushed the codex/model-pricing-health branch from 08cbc04 to 18ab43c Compare May 10, 2026 14:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18ab43c8ac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +92 to +95
...(params.eventLoop ? { eventLoop: params.eventLoop } : {}),
modelPricing: getGatewayModelPricingHealth({
enabled: params.cached.modelPricing?.state !== "disabled",
}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Clear stale event-loop health when no live sample exists

When serving cached health, mergeCachedHealthRuntimeState only overwrites eventLoop if the new sample is truthy. If getEventLoopHealth() returns undefined (for example when the monitor is unavailable/stopped), the previous cached eventLoop object is kept and returned, so clients can see stale WARN/OK event-loop diagnostics for up to the cache window instead of the field disappearing as before. This is a behavior regression introduced by the conditional spread and can mislead status/health consumers.

Useful? React with 👍 / 👎.

@openclaw-barnacle openclaw-barnacle Bot added the channel: slack Channel integration: slack label May 10, 2026
@steipete
steipete merged commit fa2b97d into main May 10, 2026
121 of 127 checks passed
@steipete
steipete deleted the codex/model-pricing-health branch May 10, 2026 14:27
@steipete

steipete commented May 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Landed via rebase onto main.

  • Source head: 47c3b22
  • Landed model-pricing commits: 02d3fe343dfbaf4b63cf24fd47ac407b39d9b44c, fa2b97d
  • Landed CI dependency fix: 8f0f12ce53ab21892d96eb7db4dccab09296e552
  • Proof: local foreground Gateway showed ok: true with modelPricing.state: "degraded" and per-source OpenRouter/LiteLLM failure details after forced pricing fetch failures.
  • Gates: OPENCLAW_TESTBOX=0 pnpm check:changed, pnpm install --frozen-lockfile --offline --ignore-scripts, pnpm test src/plugins/contracts/extension-runtime-dependencies.contract.test.ts; PR CI/proof gates green on the current SHA before/around landing.

Thanks @bzelones!

Re-review progress:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: slack Channel integration: slack clawsweeper:autofix Maintainer opted this PR into bounded ClawSweeper-reviewed autofix without merge clawsweeper:human-review Needs maintainer review before ClawSweeper can continue commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: model-pricing bootstrap failure is silent — not surfaced in gateway status or health check

1 participant