Skip to main content

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:
boolean
default:false
Enable autonomous execution
enum
default:"execute"
Execution mode: execute (live) or paper (simulation)
number
default:30
Scheduler loop interval (max 86,400)
number
default:60
Rate limit for autonomous actions (max 3,600)
array
Predefined transaction steps to execute
array
Conditional decision rules (when/then)

Supervised Mode

Agents require explicit API calls to execute intents:
Execute via API:

Capabilities and Allowlists

Intent Allowlist

Agents can only execute intents explicitly allowed:
Attempting a non-allowed intent returns 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 is running, the scheduler executes a heartbeat loop:
  1. Fetch wallet context: Balance, tokens, transactions, positions, escrows, policies
  2. Evaluate autonomy rules: Check conditions and decide on actions
  3. Execute decisions: Submit intents if conditions match
  4. Update state: Track cooldowns, run counts, and execution history

Heartbeat Context

Configuration

Agent Pause Webhook

External systems can pause agents for safety:
Paused agents:
  • Stop scheduler execution
  • Reject all intent execution attempts (API and autonomy)
  • Store pausedReason for audit trail
  • Can only be resumed via explicit API call

Decision Engine

The autonomous decision engine evaluates rules and steps:
Decision flow:
  1. Check if autonomy is enabled and agent is running
  2. Evaluate all decision rules (when/then)
  3. If no rule matches, evaluate steps in order
  4. Apply cooldowns and maxRuns limits
  5. Return executable decision or null

Best Practices

  1. Always set budgets for autonomous agents
  2. Use manifests with short TTL for high-value operations
  3. Implement monitoring on agent heartbeats
  4. Set conservative maxActionsPerHour limits
  5. Use paper mode for testing autonomous strategies
  6. Configure pause webhooks for emergency stops
  1. Start agents in supervised mode for testing
  2. Use query intents to validate context
  3. Test budget exhaustion scenarios
  4. Verify allowlist enforcement
  5. Monitor scheduler loop performance
  1. Never expose agent IDs publicly
  2. Restrict allowedIntents to minimum required
  3. Use allowedProtocols in manifests
  4. Implement proper pauseWebhookSecret rotation
  5. 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)