- Gemini CLI (Google’s agent CLI)
- Cursor Agent (Cursor’s
cursor-agentcommand) - OpenClaw (our in-house OSS runtime)
- OpenCode (the open-source OpenCode runtime)
- Any other CLI agent that can emit newline-delimited JSON events to stdout and read responses from stdin
Configuring the Process adapter
The adapter is parameterized by the binary and the argv template. Configure it once per runtime, then hire agents that use that runtime. Inconfig.json:
{{workspacePath}}— the run workspace absolute path{{leaseToken}}— the current lease token{{fencingToken}}— the fencing token{{taskId}}— the task being worked on{{runId}}— the run identifier{{mcpUrl}}— the MCP server URL- Any env var in the format
${NAME}
The stdio protocol
The adapter expects newline-delimited JSON on both sides. Every line is a single event.Events the agent writes to stdout
Events the adapter writes to stdin
shutdown events by exiting cleanly within a few seconds.
Cost reporting
Because the Process adapter is generic, it does not know how to extract token counts from a random binary. The agent is responsible for reporting cost in eachprogress or complete
event:
costModel in the config) and computes the USD cost. If the
agent reports extras, they are added verbatim.
Process group and shutdown
Every Process adapter run is launched withdetached: true and
a fresh process group. When the adapter needs to kill the run,
it sends SIGTERM to the process group (kill(-pid, SIGTERM))
with a grace window before upgrading to SIGKILL. This is the
zombie-safe pattern and it is baked into the SDK; you do not
implement it yourself.
Writing a CLI that targets this adapter
If you are building a new agent runtime, the Process adapter is the zero-friction path. The contract is:- Read the env vars (
MCP_SERVER_URL,CA_LEASE_TOKEN, etc.) - Read JSON lines from stdin
- Write JSON lines to stdout
- Exit cleanly on
shutdown
When not to use Process
Use the HTTP adapter instead if:- The agent runs on a different host
- The agent is a long-lived service that takes many sessions
- You want to pool the agent across multiple runs to avoid cold-start costs
- The runtime has its own event protocol you cannot change
- You need to translate between the runtime’s tool set and the orchestrator’s tool set
- The runtime needs something the SDK does not offer
Next
- HTTP adapter for remote runtimes
- Creating an adapter for runtime-specific adapters
- Claude Code adapter for the worked example of a full custom adapter