Skip to content

feat: expose model fallback status in terminal receipts - #164449

Open
Frosmans wants to merge 4 commits into
openclaw:mainfrom
Frosmans:feat/model-fallback-status
Open

Frosmans wants to merge 4 commits into
openclaw:mainfrom
Frosmans:feat/model-fallback-status

Conversation

@Frosmans

@Frosmans Frosmans commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

When an agent run falls back from the requested model to a configured fallback, the existing terminal receipt exposes the effective route but not whether fallback occurred or why. This leaves Gateway lifecycle consumers and parent agents without a bounded, redacted explanation of the completed run.

Summary

  • add an optional run-scoped fallback fact to the existing terminal receipt
  • derive occurrence and canonical FailoverReason from existing fallback attempts
  • include the safe fallback reason in the existing redacted route status
  • drop unrecognized reason metadata and leave model selection, execution authority, and external delivery routing unchanged

Evidence

  • Focused terminal-receipt suite: 14 passed.
  • Runner test lane: 32 passed.
  • Core tsgo, touched-file Oxlint/Oxfmt, and diff checks passed.
  • Current PR head 4f9052879f was executed through the real openclaw agent --local --json entry point.
  • An isolated loopback OpenAI-compatible provider returned HTTP 503 for proof/primary-model and a successful completion for proof/fallback-model; no external model API was called.
  • The terminal result was FALLBACK_PROOF_OK with exit code 0.
  • The terminal receipt recorded requested proof/primary-model, effective proof/fallback-model, rerouted: true, fallback.occurred: true, and fallback.reason: server_error.
  • The execution trace recorded primary candidate_failed with status 503, fallback success, and fallbackUsed: true.

This is real entry-point and transport evidence with a deterministic local provider. It is not a claim about any particular external provider outage.

Scope

No provider-, installation-, or operator-specific routing policy is included. No stored schema or retained-data format is changed.

CI follow-up (2026-10-04)

The follow-up commit 4f9052879f adds the missing src/agents/failover/signal.ts entry to the trusted PR-wrapper inventory, adds the required SAFETY invariants for the new runtime type assertions, and prunes the now-zero assertion baseline entry. The focused wrapper-closure checks pass 2/2, the assertion-safety ratchet passes, and the owning terminal-receipt/run-entry tests pass 46/46.

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Oct 3, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The branch adds fallback occurrence and a canonical failure category to agent completion receipts and their existing private model-route notices.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, compatible enhancement with relevant real transport proof and the previous review blockers resolved.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Contributor-recorded openclaw agent --local --json results exercise the production runner and real loopback provider: primary HTTP 503, successful fallback, and receipt reason server_error. The changed production modules are identical to that proof revision. No stored-data contract changes, so migration proof is not applicable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Merge readiness

✅ Ready for maintainer review

The PR remains useful: current main and the latest release lack the requested receipt metadata. The prior review blockers are resolved, the recorded runtime proof still covers the unchanged production patch, and no actionable correctness defect remains.

Priority: P2
Reviewed head: f5f5b80877d366e146d0f2d31bfcd66bfbdb54a1

Before merge

None.

Findings

None.

Agent review details

How this fits together

The agent runner tries the selected model and configured fallbacks, then publishes a completion receipt. Gateway lifecycle consumers and parent agents use that receipt to understand which model completed the run.

flowchart TD
  A[Requested model] --> B[Agent runner]
  C[Configured fallbacks] --> B
  B --> D[Attempt outcomes]
  D --> E[Completion receipt]
  E --> F[Gateway lifecycle consumers]
  E --> G[Private parent context]
Loading

Technical review

Best possible solution:

Keep fallback explanations attached to the existing run-owned receipt, using canonical categories and the established private-context delivery path.

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

Not applicable as a feature request. The contributor's recorded CLI run demonstrates the relevant primary-failure-to-fallback-completion scenario through the real transport boundary.

Is this the best way to solve the issue?

Yes. Projecting existing attempt facts into the current receipt is a narrow extension of the established owner and avoids another routing record or provider-specific policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1f576e4a4a21.

Security

None.

Evidence

What I checked:

  • Pinned introduced patch: Reviewed the complete merge-base-to-head diff and original receipt and terminal-builder blobs. The production changes project existing attempt facts into the existing receipt; they do not change candidate selection or execution authority. (src/agents/embedded-agent-runner/run-entry-terminal.ts:116, f5f5b80877d3)
  • Prior blocker resolved: The latest commit removes both obsolete positive baseline entries named by the previous review. The receipt assertions have SAFETY comments, the outcome module has only const assertions, and the wrapper inventory retains the required failover signal entry. This resolves the source-backed blocker; no ratchet execution was performed during this read-only review. (config/assertion-safety-baseline.txt:1217, f5f5b80877d3)
  • Real production-path proof: The captured PR body, source identity fe6a18da14f4fef1b18d0c3068ae7f4890b949efdcd42957d82ea37ff2307ea6, records openclaw agent --local --json against a real loopback OpenAI-compatible transport: primary HTTP 503, fallback completion FALLBACK_PROOF_OK, exit zero, and receipt fallback.occurred=true with reason=server_error. This exercises the changed runner-to-receipt boundary. The evidence is contributor-recorded terminal results, not reviewer-executed proof. (4f9052879f88)
  • Runtime proof remains applicable: GitHub comparison returns no changes to the three modified production modules between the proof revision and the reviewed head. The later commits therefore do not invalidate this focused runtime evidence. (src/agents/agent-run-terminal-receipt.ts:32, f5f5b80877d3)
  • Still missing on current main: The pinned current-main receipt exposes requested and effective routes but has no fallback occurrence or reason field. Existing session-level fallback notices and execution traces do not supply the same bounded completed-run receipt contract. (src/agents/agent-run-terminal-receipt.ts:8, 1f576e4a4a21)
  • Latest release boundary: The receipt source at v2026.9.8 likewise lacks fallback occurrence and reason metadata, so the latest release does not supersede this contribution. (src/agents/agent-run-terminal-receipt.ts:8, fc23bc864e45)

PR surface

Source +72, Tests +46, Other 0. Total +118 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 82 10 +72
Tests 2 47 1 +46
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 1 1 0
Total 7 130 12 +118

Review metrics

Metric Value Why it matters
Receipt contract 1 optional metadata field; 0 new configuration options The enhancement extends the existing completion contract without adding operator policy knobs.
Production versus test growth Production net +72 lines; tests net +46 lines Production growth implements the stated projection and sanitization boundary; tests cover receipt compatibility, reason filtering, and runner propagation.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded observability improvement for completed agent runs with no demonstrated urgent runtime regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-03T18:32:49.131Z sha 473381a :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-04T10:20:49.307Z sha 473381a :: blocked before merge. :: [P2] Include the new runtime dependency in the PR wrapper inventory
  • reviewed 2026-10-04T10:27:50.776Z sha 4f90528 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T22:24:18.820Z sha 4d8825b :: needs changes before merge. :: [P2] [P2] Prune the zero-count assertion baseline entries

Reviewed October 7, 2026, 5:03 AM ET / 09:03 UTC (Revision 5).

@Frosmans
Frosmans marked this pull request as ready for review October 4, 2026 10:09
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 4, 2026
@Frosmans

Frosmans commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 4, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 4, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 4, 2026
@clawsweeper clawsweeper Bot added the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Oct 6, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 6, 2026
@Frosmans

Frosmans commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 7, 2026

This branch has not been deployed

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

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant