Skip to main content
Add a control when you can name the behavior it changes and how to verify it. These patterns assume you already have a working Agent. Use complete projects for initial setup.

Bound a request owned by your host

Host function: the caller owns an Agent and supplies input plus a deadline in milliseconds. The function returns a successful result or fails; it does not close an Agent that may serve other requests.
Test this with a deliberately slow local fixture and verify the caller handles the unsuccessful outcome. Cancellation requests that work stop; it cannot retract an external effect already accepted by a service. For connection-owned work, use the transport’s disconnect lifecycle.

Keep a model/tool run bounded

Host factory: this gives each model call an output limit and bounds the Agent’s tool rounds. The caller supplies configured tools/model and owns the returned Agent.
Output tokens, tool rounds, request deadline, concurrency, and aggregate harness budgets constrain different things. Pick values from the task and observed behavior; these example values are not universal service defaults. Close the Agent after its runs settle.

Select controls by the problem

Compose controls in a meaningful order

Start with one task and a quality assertion. Add request identity and tool authorization, then the limits required by its execution. Add telemetry so you can see denied, failed, canceled, and completed work. Finally, choose persistence and recovery for the failure you actually need to survive. A checkpoint, queue retry, cache hit, and durable task are different contracts. Use recovery design before combining them around an external action. Prefer a harness when shared abilities and controls need a reusable composition boundary.

More patterns

Use lifecycle patterns for hooks and dependencies, cost patterns for usage estimates, security patterns for host integration, and operations for admission and shutdown.