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
Run and verify
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
consumer.py
Next step and API
API Reference · Configuration · Learning path · Next Source file (optional; all required code is already on this page).Native model I/O mechanism proof
The additionalconsumer.py uses the built-in OpenAI-compatible adapter with an offline SDK transport, public composition and Session, and real parallel tools. It asserts three requests, three executions, reversed first-batch completion, declaration-order results, final 11 and journal identities. The truncated second batch executes no tool and produces no successful final. This proves framework mechanisms, not live model capability. Install qitos[openai] before running it outside the source checkout.
Stream construction failures raise sanitized typed failures without becoming answer text. Native streams require an explicit provider terminal, collect trailing usage once and close owned resources on completion, failure and consumer close. Unknown usage stays unknown. Cancellation remains cooperative for Python workers.