Agents
Agent creation and management.
What
Manage multiple agents:
- Create agents
- List agents
- Agent state
- Cleanup
Quick Start
Import agents:
const agents = require('vant').agents;
Spawn Agent
Spawn a new agent (the crew limit applies, default 4: you plus three coworkers):
const agent = agents.spawn({
name: 'Agent1',
role: 'Assistant'
});
console.log(agent.id); // "agent_abc123"
console.log(agent.name); // "Agent1"
spawn returns the agent record synchronously. Roster persistence is
asynchronous - call await agents.flush() before your process exits so a
fresh process sees the new agent.
List Agents
const list = await agents.list();
console.log(list);
// [{ id: "agent_1", name: "Agent1", state: "idle" }]
Get Agent
Get an agent by ID:
const agent = agents.get('agent_abc123');
Pause and Resume
agents.pause('agent_abc123');
agents.resume('agent_abc123');
Prune Stale Agents
Drop idle agents older than the max age:
await agents.prune();
Terminate Agent
Remove an agent from the roster (persisted; a fresh process sees it gone):
await agents.terminate('agent_abc123');
// agents.kill is an alias for terminate
State
Agent states:
| State | What |
|---|---|
| idle | Spawned, waiting for work |
| paused | Paused via pause() |
| (removed) | After terminate() / kill() the agent is deleted from the roster |
Related
- Runtime - Runtime API
- Multi-Agent - Multi-agent workflows
- Locks - Lock system and coordination
Next
- GitHub Integration - GitHub workflows