Skip to content

Recipes

One page per wall you can hit. Each is the same shape: the question in the title, why you'd be here, one runnable script, what's actually happening, and the things that bite people.

Every snippet on these pages runs. Where a specific provider isn't the point of the page, the model is a FakeLLM from agentkit.core.testing, so you can paste and run with no API key. Where a key really is required, the page says so on its first line.

If you want a linear walkthrough instead, use the Tutorial; for the mental model of a primitive, the Concepts; for the tightest possible menu while you're already writing code, the Cheatsheet.

Unfamiliar word? The glossary defines every term these recipes use in a sentence of plain English.

Making the agent do something

  • Give an agent a tool


    Turn a Python function into something the model can call, and declare up front which calls mutate the world. Schemas, ctx injection, result validation, an agent as a tool.

    :octicons-arrow-right-24: Define and register a tool

  • Answer from my documents


    Retrieval and grounding, so the answer comes from your handbook rather than from training data that resembles it. One MemorySource Protocol, ten backends that nest.

    :octicons-arrow-right-24: Ground an agent in memory

  • Stream a typed object


    output=MyModel gives you AgentResult.parsed at the end; StreamEvent.partial_output gives you the object filling in field by field, on every delta.

    :octicons-arrow-right-24: Stream typed output

  • Consume an MCP server


    Point at any published MCP server and get its tools, resources, and prompts through agentkit's canonical Tool, MemorySource, and Prompt Protocols.

    :octicons-arrow-right-24: Use MCP tools

  • Serve your tools to the Claude CLI


    The CLI owns its loop, so you hand it a server rather than a function. serve_registry builds one from a ToolRegistry you already have — and the calls come back through your middleware.

    :octicons-arrow-right-24: Serve a registry

Structuring the work

  • Run a fixed multi-step pipeline


    A Workflow graph: declared dependencies, concurrent waves, branching, bounded loop-back, human gates with durable resume. Explicit control, when the order is yours to decide.

    :octicons-arrow-right-24: Author a workflow

  • Split work across several agents


    Coordinators, the four policies, Handoff routing, composable termination conditions. Emergent control, when who-goes-next depends on what was said.

    :octicons-arrow-right-24: Coordinate a team

  • Run agents in parallel, cancel on failure


    run_agents under a shared budget and cancel token. One failure stops the siblings; best_effort=True isolates failures into Failure objects instead.

    :octicons-arrow-right-24: Fan out with cancellation

Keeping a person in the loop

Controlling cost and behaviour

Running it in production