Skip to main content

Overview

Process adapters execute AI agents as local child processes. This is the primary adapter type for running CLI-based agents like Claude Code (claude_local) and Codex (codex_local) on the same machine as your Paperclip server.
Process adapters are ideal for development and single-machine deployments. For distributed agent execution, use HTTP adapters or OpenClaw.

Built-in Process Adapters

Paperclip ships with three process adapters:
Claude Code (local) runs Anthropic’s Claude CLI with full session support and skills integration.

Configuration Schema

Available Models

  • claude-opus-4-6: Claude Opus 4.6
  • claude-sonnet-4-5-20250929: Claude Sonnet 4.5 (recommended)
  • claude-haiku-4-5-20251001: Claude Haiku 4.5

Billing Types

Claude adapters support two billing modes:
  • API: Set ANTHROPIC_API_KEY in env for API-based billing
  • Subscription: Use local Claude login for subscription billing

Session Management

Claude sessions are automatically resumed across invocations when:
  • The agent has a saved sessionId
  • The cwd matches the saved session working directory
Sessions are cleared when:
  • maxTurnsPerRun limit is reached
  • The session becomes invalid (Claude returns unknown session error)
  • clearSession: true is explicitly returned

Skills Integration

Paperclip automatically injects local skills into Claude’s skills directory using --add-dir. Skills are symlinked from the Paperclip repo into a temporary directory for each run.

Example: CEO Agent

Configuration Fields

Core Fields

Operational Fields

Claude-Specific

Codex-Specific

Prompt Templates

Prompt templates support Mustache-style variable substitution:
Available variables:
  • {{agent.id}}, {{agent.name}}, {{agent.companyId}}
  • {{company.id}}
  • {{runId}}
  • {{context.*}}: Any field from the wake context

Instructions Files

Instructions files are markdown documents prepended to every agent prompt:
Set instructionsFilePath to an absolute path. Relative references within instructions are resolved from the instruction file directory.
Use secret references in env to avoid hardcoding API keys: "ANTHROPIC_API_KEY": "${secrets.anthropic_key}"

Process Lifecycle

When a process adapter is invoked:
  1. Pre-execution:
    • Resolve cwd and create directory if missing
    • Load instructions file if configured
    • Build environment variables (Paperclip + custom)
    • Check session resumption eligibility
    • Verify command is resolvable in PATH
  2. Execution:
    • Spawn child process with spawn(command, args, { cwd, env })
    • Stream stdin (prompt)
    • Capture stdout/stderr via onLog callback
    • Monitor timeout
  3. Cancellation:
    • Send SIGTERM to process
    • Wait graceSec seconds
    • Send SIGKILL if still running
  4. Post-execution:
    • Parse stdout for structured results
    • Extract token usage and cost
    • Save session parameters
    • Return AdapterExecutionResult

Timeout Behavior

When timeoutSec is exceeded:
The process is forcefully terminated after the grace period.

Error Scenarios

Command Not Found

If the command is not in PATH:

Authentication Required

If the CLI tool requires login:
Run claude login or set ANTHROPIC_API_KEY to resolve.

Session Mismatch

If saved session cwd doesn’t match current cwd:
A new session is created automatically.

Testing Adapter Environment

Test adapter configuration before running:
Response:

Best Practices

Relative paths may resolve incorrectly depending on where the Paperclip server is started.
Default timeoutSec: 900 (15 minutes) works for most tasks. Increase for long-running operations:
Store secrets in Paperclip’s secret vault:
Reference in config:
Check agent runtime in the UI or via API:
Look for runtime.sessionId and runtime.sessionParams to verify session continuity.

Troubleshooting

Agent stuck in “running” state

Check heartbeat runs:
Look for runs with status: "running" that exceed timeoutSec. Force cancel if needed:

No token usage reported

Ensure the CLI tool outputs structured JSON that the adapter can parse:
  • Claude: Use --output-format stream-json
  • Codex: Use --json
Check adapter logs for parse errors.

Sessions not resuming

Verify cwd matches across invocations:
Sessions are cleared when cwd changes.

Next Steps

HTTP Adapter

Learn how to invoke remote agents via webhook

Custom Adapters

Build your own adapter for custom runtimes