Skip to main content
Author an agent against the Agent contract and load it from the manifest. An agent is an LLM-driven capability registered alongside tools. You implement one interface — the Agent contract — and the runtime derives two faces from it: a JSON run tool (LLM, MCP, and flow-engine facing) and an in-process astream method (API and SSE facing). You write only the Agent class; no hand-written tool wrapper.

Implement the Agent contract

Subclass Agent, declare the three class attributes that drive tool generation, and implement run. run is the primitive; the base class provides a default astream that runs once and emits one terminal event, which streaming agents override.
myapp/agents.py
ToolInput is a JSON-able pydantic model of the tool parameters — a non-JSON field fails loudly when its schema is generated. The @tai42_app.agents.agent(name) decorator registers the agent and auto-registers its JSON run tool.

Load it from the manifest

Name the module under agents[]. Importing it runs the decorator.
manifest.yml

Run it

1

List registered agents

2

Stream a run

Stream a run one event frame at a time, passing the input as a JSON object.
Author a saved variant of an agent — an authored agent — by baking fixed_kwargs into a preset over the agent: tai presets create, then run it with tai agents authored-run. Which fields you may bake is a per-field capability the agent declares. Mark spec_runnable = True to make every ToolInput field bakeable, or list individual field names in preset_bakeable_fields to bake just those. Baking a field the agent does not declare bakeable is rejected at author time with a 400 (see Author an agent plugin for the gate and its errors).

See also