Skip to main content

Goal and prerequisites

A composition accepts a public model override and explicitly named extension factories. ObservedFakeProvider preserves the callable interface, counts actual requests and asserts the selected project context appears in each request. It then delegates to the visible deterministic provider. The project contributor is a factory returning StaticContextContributor. Its registration name matches context.contributors. This avoids imports from arbitrary names embedded in YAML and keeps executable extension selection under application control. This is a complete provider substitution and context integration example, not a new transport client. For a real provider, use the matching configuration and explicit credential resolver described in Configuration. Consult the extension index before replacing stores, sinks or sandboxes: preserving a Python method signature alone does not preserve their durability and security contracts. Basic Python is required. The package declares Python ≥3.10; local qualification uses Python 3.12.7. Each chapter runs independently; reuse the environment and matching files when continuing your project. Commands below use a macOS/Linux shell.

Prepare the project

Save the complete files below in this directory. No repository clone, editable install, or copied tests are needed.

Run and verify

Expected output fragments (generated IDs vary). Each run verifies tool results or persistence assertions and exits 0 on success.

Behavior and support boundaries

No provider is universally compatible. Codec, continuation, tool schema and loss policy must agree. Inspect typed failures; do not disable loss checks to accept an incompatible response.

Exercise and answer

Rename the contributor key in both config and extensions. Leaving only one side changed must produce a configuration/extension failure.

Common errors and cleanup

ModuleNotFoundError: activate the environment with the specified installation and save every file on this page. Existing run root: choose a new --root instead of overwriting evidence. Assertion failure: inspect the first failed tool or typed error, not only the final text. After all processes and the board stop, remove only this lesson’s newly created run directories if no longer needed; retain SQLite, journals and reports you want to debug.

Complete files: save in the project root

notes.py
agent.yaml
provider_extension.py

Next step and API

API Reference · Configuration · Learning path · Next Source file (optional; all required code is already on this page).