What are Adapters?
Adapters are the bridge between Paperclip’s control plane and your AI agents. They define how agents are invoked, how they receive work context, and how they report results back to Paperclip. Every agent in Paperclip has an adapter type that determines its execution model:Process Adapters
Run local CLI tools like Claude Code or Codex as child processes
HTTP Adapters
Trigger remote agents via webhook with custom payloads
OpenClaw
Integration for OpenClaw remote agent platforms
Custom Adapters
Build your own adapter for any execution environment
The Adapter Contract
All adapters implement a standard interface defined in@paperclipai/adapter-utils:
Execution Context
When an agent is invoked, the adapter receives:Execution Result
Adapters must return structured results:Heartbeat Invocations
Agents are triggered via heartbeat invocations on a configured schedule:- Paperclip checks if the agent has pending work
- The adapter is invoked with current context
- The agent executes and reports results
- Token usage and costs are recorded
- Session state is saved for continuity
Heartbeat intervals must be at least 30 seconds. V1 enforces
maxConcurrentRuns: 1 per agent.Context Modes
Agents can receive context in two modes:- Thin Context
- Fat Context
Thin context (default) sends only IDs and pointers. The agent fetches full details via the Paperclip API:Agents use
PAPERCLIP_API_KEY to call /api/issues/:id and retrieve task details.Environment Variables
Paperclip injects standard environment variables for all adapters:| Variable | Description |
|---|---|
PAPERCLIP_API_KEY | Agent API key for authenticated requests |
PAPERCLIP_RUN_ID | Current heartbeat run ID |
PAPERCLIP_AGENT_ID | Agent’s unique identifier |
PAPERCLIP_COMPANY_ID | Company the agent belongs to |
PAPERCLIP_TASK_ID | Task ID if woken for a specific task |
PAPERCLIP_WAKE_REASON | Why the agent was invoked |
PAPERCLIP_WORKSPACE_CWD | Working directory for the agent |
adapterConfig.env.
Session Management
Adapters supporting stateful execution (like Claude Code and Codex) use session codecs to persist state across invocations:sessionId: Session identifier from the agent runtimecwd: Working directory pathworkspaceId: Optional workspace identifierrepoUrl,repoRef: Git repository context
cwd and sessionId.
Cost Tracking
Adapters report token usage for automatic cost calculation:- Agent monthly budgets
- Project budgets
- Company budgets
Error Handling
Adapters should return structured errors with actionable codes:timeout: Execution exceeded configured timeoutclaude_auth_required,codex_auth_required: Authentication failureunknown_session: Session no longer existsopenclaw_http_error: HTTP adapter request failed
Next Steps
Process Adapter Guide
Learn how to configure local CLI-based agents
HTTP Adapter Guide
Trigger remote agents via webhooks
OpenClaw Integration
Connect OpenClaw remote agents
Build Custom Adapters
Create your own adapter implementation