- Reads/writes JSON lines on stdio → use Process
- Exposes HTTP with SSE → use HTTP
- Has its own weird protocol, bespoke event shapes, or needs custom tool translation → write a custom adapter
What the SDK gives you
Adapters inherit from one of two base classes inpackages/adapters/sdk/:
ProcessAdapter— for adapters that launch a local binaryHttpAdapter— for adapters that hold a session with a remote
- Workspace setup
- Env var and argument templating
- Process group isolation (
detached: true, negative PID signaling) - Lease renewal loop
- Stdio/stream parsing skeleton
- Shutdown sequencing (SIGTERM → grace → SIGKILL)
- Retry and timeout handling
- Error classification (
crash,timeout,lease_expired,kill,auth)
launch()— how to start the process or sessiononOutput()— how to interpret output eventsonToolResult()— how to pass tool results backextractCost()— optional, how to pull token/cost data out of your runtime’s events
Minimum shape of a custom adapter
Testing your adapter
The SDK ships with a test harness that runs a mock orchestrator, a mock MCP server, and a fake task, then asserts that your adapter:- Launches the runtime with the right argv and env
- Translates output events correctly
- Calls the MCP server for tool calls
- Renews the lease on schedule
- Shuts down cleanly on a forced kill
Publishing an adapter
Adapters live inside the monorepo inpackages/adapters/. To
add one:
pnpm --filter @company-agents/adapters create-adapter my-runtime- Edit the generated file to implement the four methods
- Add tests
- Run
pnpm --filter @company-agents/adapters test - Open a PR
Out-of-tree adapters
You can also publish an adapter as its own npm package and pointconfig.json at it:
- Commercial runtimes with their own release cadence
- Company-internal runtimes that should not live in the public monorepo
- Experimental adapters you do not want to pin to a Company Agents release
What to keep an eye on
A few rules of thumb from the adapters that have already been written:- Do not trust the runtime to clean up its own children. Process groups are your friend. Use the SDK’s group kill helper, do not roll your own.
- Do not retry inside the adapter. The orchestrator handles retries. If the run fails, fail it cleanly and let the orchestrator decide.
- Do not cache tool results inside the adapter. Tool results are metered. Caching them is a silent bill dodge.
- Do not swallow stderr. Pass it up to the log collector. The orchestrator decides what to show the user.
- Do not hold onto the master key. The adapter should not even see it. Secrets come through the MCP server at call time.
Next
- Process adapter for the ready-made shape that works for most CLIs
- HTTP adapter for remote runtimes
- Writing a skill if you are building the agent’s logic as well as its adapter