Micro Agents
The smallest thing that acts: one signature, a few tools, a typed reply. Most agents in a production codebase should be this size.
import { agent, ai, f, fn } from '@ax-llm/ax';
const llm = ai({ name: 'openai', apiKey: process.env.OPENAI_APIKEY! });
const lookupOrder = fn('lookupOrder')
.description('Fetch an order record by id')
.arg('orderId', f.string('Order id, e.g. ord-1042'))
.returns(f.json('Order record'))
.handler(async ({ orderId }) => orderStore.get(orderId))
.build();
const support = agent('ticket:string -> reply:string', {
functions: [lookupOrder],
});
const out = await support.forward(llm, {
ticket: 'Where is my order ord-1042?',
});That is the whole program. There is no prompt to write, no parser to maintain, no retry loop to hand-roll — the signature generates all three, and the reply comes back as typed data.
Zero Config Is The Full Harness
A micro agent is not a lesser mode. With no configuration, agent() already runs the complete pipeline — distiller, executor with a live runtime session, responder — the same machinery the long-horizon tier uses. You just haven’t needed to touch any of it yet. Two practical consequences:
- Typed outputs are the system boundary. The reply is validated against the signature and retried with feedback on mismatch, so downstream code consumes data, not prose.
- Actions really run. Tools execute in the runtime; results are inspected before the agent answers. A micro agent that looks up an order answers from the record it fetched, not from a guess.
Keeping It Micro
- One signature, one job. If the task description needs the word “then”, consider two agents or a flow.
- Pass tools flat —
functions: [lookupOrder, sendReply]. At this size every callable is obviously relevant, and flat inline tools are the most reliable shape for small models (grouped discovery earns its keep later, at catalog scale). - Small models are the point. Micro agents run well on cheap, fast models — see Performance for measured model guidance.
When To Graduate
Move up a tier when one of these appears:
| Signal | Go to |
|---|---|
| The tool list is growing past what fits comfortably in one prompt | Standard — namespaces, groups, discovery |
| A specialist should own part of the job (its own signature, tools, identity) | Standard — child agents |
| An input field is getting bulky (logs, ledgers, transcripts) | Long-horizon — context fields |
| Runs are getting long, or the same material is queried repeatedly | Long-horizon — policies, maps, memory |
Runnable code: agent examples and the agent() API.