Agents
Agents are autonomous or supervised actors that execute transactions on behalf of wallets. They provide fine-grained capability control, budget management, and execution automation.Agent Structure
Agent States
Agents transition through well-defined lifecycle states:Stopped
Initial StateAgent created but not executing. Scheduler is inactive.
Running
Active ExecutionScheduler active, agent can execute intents based on mode.
Paused
SuspendedTemporarily disabled. Stores reason for audit trail.
State Transitions
Execution Modes
Autonomous Mode
Agents execute intents automatically based on rules and steps:Autonomous Configuration Fields
Autonomous Configuration Fields
Enable autonomous execution
Execution mode:
execute (live) or paper (simulation)Scheduler loop interval (max 86,400)
Rate limit for autonomous actions (max 3,600)
Predefined transaction steps to execute
Conditional decision rules (when/then)
Supervised Mode
Agents require explicit API calls to execute intents:Capabilities and Allowlists
Intent Allowlist
Agents can only execute intents explicitly allowed:403 Forbidden.
Capability Manifests
Optional cryptographic proof of allowed capabilities:Issuing a Manifest
Manifests are enforced when
AGENT_REQUIRE_MANIFEST=true. The signature is verified using AGENT_MANIFEST_SIGNING_SECRET.Budget Management
Agents can have spending budgets tracked in lamports:Budget Operations
Budget Enforcement
The agent runtime checks budgets before executing spend-capable intents:Agent Scheduler
When an agent isrunning, the scheduler executes a heartbeat loop:
- Fetch wallet context: Balance, tokens, transactions, positions, escrows, policies
- Evaluate autonomy rules: Check conditions and decide on actions
- Execute decisions: Submit intents if conditions match
- Update state: Track cooldowns, run counts, and execution history
Heartbeat Context
Configuration
Agent Pause Webhook
External systems can pause agents for safety:- Stop scheduler execution
- Reject all intent execution attempts (API and autonomy)
- Store
pausedReasonfor audit trail - Can only be resumed via explicit API call
Decision Engine
The autonomous decision engine evaluates rules and steps:- Check if autonomy is enabled and agent is running
- Evaluate all decision rules (when/then)
- If no rule matches, evaluate steps in order
- Apply cooldowns and maxRuns limits
- Return executable decision or null
Best Practices
Production Agents
Production Agents
- Always set budgets for autonomous agents
- Use manifests with short TTL for high-value operations
- Implement monitoring on agent heartbeats
- Set conservative
maxActionsPerHourlimits - Use paper mode for testing autonomous strategies
- Configure pause webhooks for emergency stops
Development
Development
- Start agents in supervised mode for testing
- Use query intents to validate context
- Test budget exhaustion scenarios
- Verify allowlist enforcement
- Monitor scheduler loop performance
Security
Security
- Never expose agent IDs publicly
- Restrict allowedIntents to minimum required
- Use allowedProtocols in manifests
- Implement proper pauseWebhookSecret rotation
- Audit agent creation and capability changes
Source Code Reference
Agent functionality is implemented in:services/agent-runtime/src/index.ts- Main agent service (services/agent-runtime/src/index.ts:1)services/agent-runtime/src/scheduler/scheduler.ts- Heartbeat scheduler (services/agent-runtime/src/scheduler/scheduler.ts:1)services/agent-runtime/src/decision/engine.ts- Autonomous decision logic (services/agent-runtime/src/decision/engine.ts:1)services/agent-runtime/src/security/capability-manifest.ts- Manifest signing/verification (services/agent-runtime/src/security/capability-manifest.ts:1)packages/common/src/schemas/agent.ts- TypeScript schemas (packages/common/src/schemas/agent.ts:1)