Understand first
New to this knowledge point
Complete the prerequisite concepts, read the principles and counterexamples, and then explain why in your own words.
Start with core principles →Understand → Implement → Debug → Design
Pin units and versions, then handle new result states and an unavailable old implementation without unsafe retries.
Knowledge content check2026-10-11 · Check the source of the original question2026-10-11
It is recommended to understand first:
Context and generation budgets →Select the starting point based on the current basis, or you can go deeper one by one. When you encounter an unfamiliar concept, go back to the core principles first; use the knowledge exercises to check your understanding when you are finished.
New to this knowledge point
Complete the prerequisite concepts, read the principles and counterexamples, and then explain why in your own words.
Start with core principles →Prepare to write the principles into code
Understand implementation steps and boundaries, complete small tasks, and check results against acceptance requirements.
View the code example →Need to handle failures and changes in conditions
Follow the continuous questioning to locate the failure premise, and then compare the migration cases to explain how the plan should be adjusted.
Continue to delve deeper into the problem →Need to design or review plans
Combine engineering deductions and senior self-evaluation standards to explain the applicable conditions, costs and alternatives of the plan.
Analyze engineering scenarios →LEARN · PRACTICE · REFLECT
First read along the principles, Q&A and migration cases. When you need to check your understanding, switch to reinforcement exercises or start personal recording.
Can be practiced directly. After logging in, answers, favorites, and notes will be saved to your account.
Log in and saveEach modified commit will be kept as an independent history. Your level of mastery is up to you to evaluate yourself against the standards.
Core concept · Compatibility means preserving business semantics across durable intents
Preparatory concepts:Versioned request/result contracts, Durable intent and receipt identity, Approval over normalized semantics
A parseable new payload is compatible only when it preserves the old action and result meaning under the pinned version.
Parseable fields do not prove compatibility. Keep pinned intent and receipt meaning, and reconcile unknown result enums before retiring old code. Select the figure to open it at full size.
A durable intent outlives one deployment. Resuming it under current code without its original unit/default/result interpretation can change what the user approved. A version adapter is therefore a proof obligation over semantics, not a field rename.
For the cents example the valid mapping is explicit and narrow. For a new result enum, preserve uncertainty and reconcile with the authority. The operation key still names one business intent, so a migration that changes the effect must not reuse its approval or receipt as if it were only a transport retry. The tool course provides the local fingerprint and receipt checks.
Proposes a tool name, arguments, and call_id. All are candidate inputs.
Checks the allowlist, completeness, shared budget, and arguments. A failed check stops the action.
Reads identity from a trusted session; checks resource ownership and current permissions, then state at the commit boundary.
Correlates success, failure, or unknown receipts by call_id and preserves facts that already occurred.
Adds the receipt to the next input; checks the final answer against facts before reporting business completion.
Valid structure grants no permission. call_id correlates a call in this turn; it cannot replace a business operation key across recovery.
Persist request/result versions and normalized intent. Use a tested semantics-preserving adapter for compatible units/defaults; changed targets, units or behavior require explicit migration and renewed review. Unknown result enums are not terminal failure. Retain old intent/receipt readability and reconcile remote status before retiring the old executor.
Use an authored upgrade from v1 integer amount_cents with implicit USD to v2 integer amount_minor plus explicit currency. Mapping 300 cents to 300 USD minor units preserves meaning; mapping 3 to three dollars does not. Persist v1 identity and normalization rules or explicitly migrate to a new reviewed intent. Never let a resumed task pick new defaults silently.
Request compatibility is only half the boundary. A new response state pending_settlement is not a completed refund and not proof that no effect exists. An old consumer can preserve an explicit unsupported/unknown state, store the raw versioned receipt safely and invoke a supported reconciliation path. Mapping it to failed and retrying a fresh operation risks duplication.
The v2 local experiment rejects schema_version=1 instead of silently adapting it. Its unchanged v2 request commits/replays once; a changed payload conflicts. That is observed behavior. The v1 adapter and remote status strategy here are design proposals, not tested provider integration.
Validate adapters with captured or authored request/result fixtures and dry-run authority decisions. Shadowing a live write by executing both versions creates two effects; compare normalized intents or read-only provider checks instead. Retire v1 only after in-flight intent, receipt and reconciliation needs are satisfied or deliberately moved to a documented blocked/manual path.
Python 3.9+, standard library. Extract /lab/deep-dive/agent-core-deep-dive-v1.zip and run this snippet beside tool_contract_deep_dive.py; /lab/deep-dive/tool_contract_deep_dive.py is also available. Authored fixtures only; not a live model or external service.
from tool_contract_deep_dive import Executor, Context, request
e = Executor()
ctx = Context('tenant-a', 'user-a')
assert e.execute(ctx, request(schema_version=1))['gate'] == 'contract_version'
assert e.execute(ctx, request())['status'] == 'committed'
assert e.execute(ctx, request(amount_minor=301))['gate'] == 'idempotency_conflict'
print(e.state()['effect_count'])
e.close()
expected output
1Continue reading along with the premises and constraints of the problem. Understand the reference answers first, then try to put away the answers and explain the cause and effect and trade-offs in your own words.
Level 1Why can adding pending_settlement break an old result consumer?
Changes valid JSON into a new semantic result state.
The old consumer may exhaustively classify states or map unknown to failed. Pending does not establish absence or completion of an effect. Preserve a versioned pending/unsupported state and route to a supported interpreter/reconciliation path.
Follow this answer further
Level 2If the adapter maps every unknown status to failed, what can a retry do?
Adds an automatic retry triggered by the unsafe mapping.
Create another effect if the first operation is already pending or committed. Unknown is an information state, not a terminal business failure. Keep the same operation identity, query the authority and prohibit a fresh dispatch until the outcome is known or explicitly escalated.
Follow this answer further
Level 3The old interpreter is gone and the new status remains unresolved. How does the task end?
Removes the old execution/interpreter capability.
Persist the unresolved versioned receipt and a blocked/manual reconciliation outcome with an owner and next action. Restore a reader/adapter if possible. Do not relabel the effect as failed just to terminate the workflow; later reconciliation may need to preserve committed business history.
Level 1How can v2 shadow testing compare a write without double writing?
Introduces live side effects into a compatibility comparison.
Compare normalized proposals and result fixtures, or use a provider-supported dry-run/read-only validation. Only one path dispatches the live intent. Replaying an old receipt can test parsing; executing both tools is not a harmless shadow check.
Level 1Old approved tasks omitted a recipient default, and v2 changes that default. What must happen?
Changes a default that affects action semantics.
Recover the originally normalized recipient and pin it if it was reviewed. If the original intent did not resolve it or v2 would send elsewhere, block and renew the proposal/review. Field omission cannot hide a changed business target.
First find out the conditions for change, and then determine which premises in the original plan still hold true. The following cases are teaching deductions to facilitate the transfer of principles to new problems.
Changing conditions:The upgrade adds an optional trace label that does not change targets, units or results.
Extended question:Can old tasks continue without a new approval?
Potentially, if the parser tolerates the extension at the version boundary and omission preserves all old business behavior. Test request and result fixtures and keep the label out of action semantics if it is only observation metadata. If it changes routing, billing or policy, it is not merely an optional trace field.
The principles that remain unchanged:Compatibility preserves the action and outcome semantics, not just syntax.
Changing conditions:A security patch makes the v1 executor unsafe to keep running.
Extended question:What is a safe retirement path for in-flight intents?
Stop v1 dispatch. Retain read-only intent/receipt interpretation, reconcile already sent operations, and migrate only reviewed semantics through a verified adapter or fresh approval. Explicitly block unresolved tasks. Availability may decline; it is preferable to silently changing or duplicating the action.
The principles that remain unchanged:Retirement cannot erase unknown effects or reinterpret reviewed intent silently.
Official mechanisms were checked on 2026-10-11. Examples and schedules are authored; local Python/SQLite outputs are actually executed. No enterprise incident, live model accuracy or production reliability is asserted. New Q&A and migration cases are added for principle explanation, and source verification and case operation verification are recorded separately.
After reading, you can explain the principles, boundaries, and trade-offs against these standards. It is up to you to evaluate your mastery; if further verification is needed, complete the small tasks below.
View verification records for independent examples
First observe whether business effects have been generated while waiting for approval, and then press README to check action binding and recovery.
Read full text and fault analysis → · Download experiment package ↓
python3 approval_cli.py submit
python3 approval_cli.py run
python3 approval_cli.py inspect
# 审查 draft 和 action_json 后,按 README 使用对应 binding_hash 批准并恢复Local approval fixture; --actor is not a login or production authentication. No network by default.
Run the v2 tool lab, then build a request/result compatibility matrix for v1 cents, v2 explicit currency and pending_settlement. Include a rollback/retirement checklist and a side-effect-free shadow plan.