API reference¶
Generated from the source. The public surface is small on purpose.
Building and running¶
Graph ¶
Assembles a graph of communicating agents.
Two styles, mixable:
- Linear
Graph().node("a", A).node("b", B)chains each node after the previous one, so A hands its message to B. - DAG pass
after=[...]to wire explicit dependencies, andbarrier/kto control fan-in (agent-to-agent) join semantics.
join ¶
join(name: str, *, after: list[str], agent: Any = None, barrier: str | BarrierKind = 'all', k: int | None = None, **kwargs: Any) -> Graph
Explicit fan-in node. Defaults to a pass-through :class:IdentityAgent.
A join ALWAYS hands its agent a dict keyed by the (surviving) upstream node names, even for a single upstream, so the input shape is stable.
run
async
¶
Convenience: compile and run in one call.
CompiledGraph ¶
A compiled, validated graph ready to exchange messages between agents.
Messages and results¶
Message ¶
Bases: BaseModel
The envelope passed from one agent to the next.
payload is the data itself (anything). meta carries provenance and
annotations that accumulate as the message travels between agents.
content_type is an optional, informational schema hint.
Result ¶
Bases: BaseModel
What a run returns: the final output plus a full trace of the exchange.
Nodes, barriers, grading¶
Node
dataclass
¶
A node in the graph: an agent, its upstream dependencies, and its gate.
Wraps a single :class:Agent, an optional quality check whose grade can
gate the exchange (per gate mode), an optional per-node timeout_s,
the after list of upstream node names, and the fan-in barrier.
BarrierPolicy
dataclass
¶
Verdict ¶
Bases: str, Enum
A node's quality judgement.
worst
classmethod
¶
The most severe verdict in a set (PASS if empty).
Grade ¶
Bases: BaseModel
The outcome of a node Check: a verdict plus a human reason.
GateMode ¶
Bases: str, Enum
How a node's Check grade affects the exchange.
The agent interface¶
Agent ¶
Bases: Protocol
A participant in the graph.
Anything a user brings, a callable, an HTTP/OpenAPI endpoint, an MCP tool, a framework agent, or an LLM, is adapted to this single async interface so it can exchange messages with every other agent.
Context
dataclass
¶
Run-scoped context threaded through every node in the graph.
state is a shared blackboard for the run. deadline (a
time.monotonic() value) bounds the whole run; individual nodes may also
carry their own timeout.
Adapters¶
adapt ¶
Return an :class:Agent for obj, inferring the right adapter.
Resolution order: already-an-Agent → custom/entry-point registrations → MCP ref → A2A ref → framework agent → HTTP/OpenAPI → plain callable.
register_adapter ¶
Register a custom adapter. Later registrations take precedence.
A2ARef
dataclass
¶
A reference to a remote A2A agent by base URL (recognized by adapt()).
McpRef
dataclass
¶
A reference to an MCP tool: a stdio server command + a tool name.
LLM ¶
A prompt-in / text-out worker backed by an LLM provider.
The node's input payload is substituted into prompt via {input}
(or sent as the whole user message when prompt is omitted).