Core concepts
Agents
An agent proposes actions; the runtime governs and executes them. Antraft ships a ReAct agent and prebuilt patterns, and any object that proposes actions can be governed.
ReActAgent
The default agent runs an LLM tool-calling loop, emitting neutral Action andThought objects so every tool call flows through the Guard.
agent.py
from antraft import Antraft, ToolRegistry, tool_from_functionfrom antraft.models import create_model runtime = ( Antraft.agent( create_model("openai:gpt-4o"), ToolRegistry([tool_from_function(my_tool)]), task="...", system_prompt="You are concise.", max_turns=12, parallel_tools=True, # one turn's tool calls run concurrently ) .allow(["my_tool"]) .build())Structured output
Pass a pydantic model or JSON Schema; the final answer is validated into it.
structured.py
from pydantic import BaseModel class Summary(BaseModel): title: str bullets: list[str] runtime = Antraft.agent(model, tools, task="...", output_schema=Summary).build()await runtime.run()runtime.agent.structured # -> Summary(...) (or .structured_error)Prebuilt patterns
patterns.py
from antraft.agents import reflection_agent, plan_execute_agent # self-critique then improve, before finishingagent = reflection_agent(model, tools, task="...", reflect_rounds=1) # plan explicitly, then execute the planagent = plan_execute_agent(model, tools, task="...")Govern any agent
Implement next_action() and observe(result) and Antraft will govern it — no need to use ReActAgent.
custom.py
from antraft.core.agent import BaseAgentfrom antraft.core.action import Action class MyAgent(BaseAgent): id = "my-agent" def next_action(self): return Action(name="search", params={"q": "antraft"}) # or None to finish def observe(self, result): ... await Antraft.guard(MyAgent(), {"search": do_search}).allow(["search"]).run()Tip
Multi-agent workflows compose with
antraft.graph.Graph — nodes can run governed agents, edges route on shared state.