Skip to main content

Goal and prerequisites

A custom Agent makes the decision policy explicit. NotesState.titles starts empty. decide declares two actions, reduce folds their observations into state, and the next decide returns a final decision. This example needs no model. The same notes fixture is used in the Quickstart. Here you replace the decision policy rather than the configured provider. AgentComposition builds its configured Agent; it does not accept an arbitrary agent_override. Construct the public Engine with your own AgentModule and RuntimeComposition, then create a Session. Run both execution modes. They must produce the same declaration-ordered title list. In reduce, action observations are dictionaries; EngineResult.records contains typed ToolResult objects. Do not confuse those two representations. 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.

State and decisions

Run and assertions

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

The default RuntimeComposition uses a process-local Memory checkpoint store. A Session identity alone does not make that store durable. Use the composition/SQLite lifecycle lesson for cross-process recovery.

Exercise and answer

Process only the first note: change the action indices to (0,) and expect Session in both modes.

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
custom_agent.py

Next step and API

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