Skip to main content

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:
On each heartbeat:
  1. Paperclip checks if the agent has pending work
  2. The adapter is invoked with current context
  3. The agent executes and reports results
  4. Token usage and costs are recorded
  5. 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 (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: Adapters can add custom environment variables via adapterConfig.env.

Session Management

Adapters supporting stateful execution (like Claude Code and Codex) use session codecs to persist state across invocations:
Session parameters typically include:
  • sessionId: Session identifier from the agent runtime
  • cwd: Working directory path
  • workspaceId: Optional workspace identifier
  • repoUrl, repoRef: Git repository context
Sessions are automatically resumed when the agent is invoked with the same cwd and sessionId.
Sessions are cleared when clearSession: true is returned, or when max-turns limits are reached.

Cost Tracking

Adapters report token usage for automatic cost calculation:
Cost events are automatically created and rolled up to:
  • Agent monthly budgets
  • Project budgets
  • Company budgets
Budget enforcement triggers auto-pause when limits are exceeded.

Error Handling

Adapters should return structured errors with actionable codes:
Common error codes:
  • timeout: Execution exceeded configured timeout
  • claude_auth_required, codex_auth_required: Authentication failure
  • unknown_session: Session no longer exists
  • openclaw_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