Review the prerequisites
Suitable for: Backend developers learning Agent applications.
- Capability and status contracts for fallback models
- Switching the model changes the decision maker and cannot reset executed facts, authorizations and budgets. Only when the backup model meets the required capabilities and message semantics of the task can it be an executable downgrade path.
How does the mechanism work?
Step-by-step explanation
- Should the model be automatically changed after the main model returns a rejection?
Reasons for switching models must distinguish temporary failures from prohibited behavior.
- How to handle the tool call ID when switching?
Changing the message format must preserve correlations with actual actions.
- What should I do if the backup model is also limited?
When fallback also fails, a global stopping rule is needed.
Foundation · Understand the concepts
Understand the principle · Capability and status contracts for fallback models
Objectives of this level: Switching the model changes the decision maker and cannot reset executed facts, authorizations and budgets. Only when the backup model meets the required capabilities and message semantics of the task can it be an executable downgrade path.
Visual guide · Fallback preserves business facts
This routing fixture performs no writes. Consider fallback only after preserving business receipts, identity, required capabilities and shared limits. Select the figure to open it at full size.
Classify the failure before changing the decision maker
These are authored model-event and business-state fixtures: zero real model or production calls. wait_units=2 in integer logical time is this lab's chosen pre-fallback backoff policy. It is not a measured Retry-After value and does not claim that different providers share a rate-limit clock.
request = {"business_id": "biz-77", "required_caps": ["tools", "json"],
"deadline": 5, "max_model_calls": 2}
state = {"business_id": "biz-77", "write_state": "none", "receipt": None,
"facts": [{"kind": "tool_result", "operation_id": "read-op-1", "data": "confirmed"}],
"used_calls": 1}
event = {"kind": "rate_limited", "http_status": 429, "wait_units": 2}
capabilities = ["tools", "json"]
receipt = {"business_id": "biz-77", "receipt_id": "receipt-1", "status": "committed"}
now = 0
Predict four inputs: original 429; event changed to invalid_parameters/400; capabilities containing only tools; and state changed to committed with its receipt. For each, state whether fallback and a write are allowed and which facts survive. A transient 429 makes fallback a candidate; permanent parameter errors require fixing the request; missing capability blocks execution; a committed write retains its receipt before considering model recovery.
operation_id associates an executed tool result, business_id identifies the business operation, and receipt_id is commit evidence. Changing the decision maker must preserve these facts rather than generate a new business identity and redo the action. Declared capabilities are local fixtures; real providers need interface, message, tool/structured-output, context-limit, and quality validation.
Guided run and your own implementation
Only Python 3.9+ and the standard library are needed. guided covers one fixed 429 with no write, sufficient capability, and sufficient budget: wait(2), one fallback, draft_ready, four true checks, exit 0. draft_ready describes an authored draft rather than completed business work or measured model quality.
mkdir -p fallback-practice
cd fallback-practice
curl --fail --location https://ai.lwkjob.com/lab/interview-practice/fallback_lab.py --output fallback_lab.py
python3 fallback_lab.py guided --out fallback-guided.json
Bounded backoff and idempotence; Function calling associations; lab source.
code example
Failure class and executed facts
Handle 429, bad parameters, missing capability, and a known receipt separately. A commit precedes model recovery and cannot be replayed under a new ID.
Acceptance task for this level
Predict calls and terminal states for 429, invalid_parameters/400, missing json, and a committed receipt; label guided output as reference rather than module evidence.
Reading this browser’s record…
Hide the answer and check your understanding
What takes precedence after a committed write followed by a 429?
Expand reference derivation
The committed receipt takes precedence. Keep its business ID and facts, without replay. A model-stage 429 does not invalidate an executed tool effect.
Further explanations and practice
When encountering unfamiliar principles, first read the implementation, continuous questioning and migration cases, and then independently explain the premise and boundaries. Answers and notes are saved to the original account record.
All linked explanations and exercises (1 )
Sources and verification scope
The principles are based on public information; the numbers, cases and tasks are the teaching design of this website. Offline experiments verify the range noted on this page, and the learning effect still needs to be judged through independent tasks and feedback.
- AWS: Bounded backoff and idempotent retries
- MCP 2025-11-25: Tools and error types
- OpenAI: Function calling messages are associated with results
- OpenAI: Structural guarantees and boundaries for Structured outputs
- Harness Journey: one connected practical project
- Bilingual project guide and fault exercises
- Harness Journey source ZIP