Skip to content
Agent Field Notes
Practice topicsFilter practice questions by topic.All practice →
knowledge unit 61AdvancedSystem designAbout 18 minutes

Understand → Implement → Debug → Design

Compatibility means preserving business semantics across durable intents

Pin units and versions, then handle new result states and an unavailable old implementation without unsafe retries.

SchemaVersion compatiblerollback

Knowledge content check2026-10-11 · Check the source of the original question2026-10-11

Which step do you want to learn from this knowledge point?

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.

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 →

Implement next

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 →

Debug failures

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 →

Compare designs

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 →
Knowledge unit directory

LEARN · PRACTICE · REFLECT

Knowledge learning and personal records

My notes and review ↗

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.

Answers and personal notes

Each 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

Understand the core principles first

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.

Visual guide · Preserve meaning across a tool upgrade

Preserve meaning across a tool upgrade

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.

Tool calls: trust boundaries from proposal to receipt
  1. 1
    Model

    Proposes a tool name, arguments, and call_id. All are candidate inputs.

  2. 2
    Runtime

    Checks the allowlist, completeness, shared budget, and arguments. A failed check stops the action.

  3. 3
    Business service

    Reads identity from a trusted session; checks resource ownership and current permissions, then state at the commit boundary.

  4. 4
    Tool adapter

    Correlates success, failure, or unknown receipts by call_id and preserves facts that already occurred.

  5. 5
    Acceptance

    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.

Check understanding with a question

How can a tool upgrade preserve in-flight action semantics and unknown results?

Compare with the reference answer

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.

Implementation and trade-offs

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.

code example

Reproducible local boundary check

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

1

Engineering deduction

scene
Authored v1/v2 unit migration with an in-flight approved refund and a new pending_settlement response.
design decisions
Pin or explicitly migrate normalized semantics, test both request and result adapters, and keep pending outcomes reconcilable.
Verify target
The executable v2 lab rejects unrecognized request version1 and prevents changed-payload replay. Migration/remote behavior is a reasoned design table.
applicable boundary
No actual v1 implementation, remote provider, signed migration approval or deployment rollback is executed.

Continuous questions and answers

Continue 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.

Draw inferences from one example: If the conditions change, how to deduce it?

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.

A genuinely optional field

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?

Derivation and reference solutions

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.

Old executor unavailable

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?

Derivation and reference solutions

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.

Easy to make mistakes

  • Assuming an added enum or changed default is harmless because JSON still parses.
  • Treating unknown remote status as failed and starting a new operation.
  • Executing both live write implementations to compare them.
  • Retiring the only receipt interpreter before old operations can be reconciled.

References

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.

Check how far you understand

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.

Basic standards met
Identifies request/result version pinning and rejects silent semantic changes.
Intermediate and advanced signals
Works through unit/default migration and pending enum handling with a rejection fixture and recovery path.
Senior criteria
Accounts for renewed approvals, no-double-write shadowing, receipt retention and unavailable old services during rollback.

View verification records for independent examples

Continue to do advanced research experiments

Push the read-only tool boundary to the approval boundary

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 批准并恢复

Keep evidence and check item by item

  • Status waiting_approval, no reports service has written yet.
  • Review actions, targets, scopes, inputs, and content summaries before approving the corresponding binding_hash.
  • Run tests to reject, cancel and modify content respectively to explain why old approvals cannot be reused.

Local approval fixture; --actor is not a login or production authentication. No network by default.

Hands-on verificationComplete on demand · Suggestions35 minutes

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.

Expand acceptance requirements and checkpoints
  • Version1 request is explicitly rejected by the runnable v2 module, not guessed.
  • The proposed adapter preserves integer units/currency and rejects unknown semantics.
  • A pending result remains reconcilable without a new business operation.
  • Review renewal and old intent/receipt readability are included.

Key inspections

  • Pins both request and result semantics for in-flight intents.
  • Checks integer amount units, currency and expanded defaults before approval.
  • Preserves pending/unknown states rather than mapping every new enum to failed.
  • Explains side-effect-free shadow checks, rollback and old-service unavailability.