Harness Agents
SkillAI & modelsThis skill adds full agent runtimes, such as Claude Code, Codex, Pi, Cursor, Mastra, or ACP agents, to your AI. Once added, your AI can run coding agent tools like Claude Code or Codex inside your app while handling their sessions and permissions.
Available today. Use it from your connected AI after setup.
No other account needed.
After adding this skill, choose the agent runtime you want to use, such as Claude Code or Codex, and run it inside your app.
Then ask your AI: use the Harness Agents skill
What your AI can do with it
- Run coding agents like Claude Code or Codex inside your app
- Add full agent runtimes such as Pi, Cursor, Mastra, or ACP agents
- Manage sessions for the agents it starts
- Handle permissions for the coding agents it runs
What this skill tells your AI
The instructions your AI receives, as published by builderio/agent-native in .agents/skills/harness-agents/SKILL.md and read by ahel’s review.
Rule
Full agent harnesses are not AgentEngine providers. Use the AgentHarness
substrate in @agent-native/core/agent/harness.
Why
AgentEngine is for one model round trip beneath runAgentLoop. Harnesses like
Claude Code, Codex, Pi, Cursor, and Mastra own their own loop, workspace,
native tools, session state, compaction, approval model, and sandbox behavior.
Putting a harness under AgentEngine.stream() double-runs the loop and loses
session lifecycle semantics.
How
- Register or resolve a harness adapter.
import {
registerBuiltinAgentHarnesses,
resolveAgentHarness,
} from "@agent-native/core/agent/harness";
registerBuiltinAgentHarnesses();
const harness = resolveAgentHarness("ai-sdk-harness:codex");
- Start a turn through the run-manager bridge.
import { startAgentHarnessRun } from "@agent-native/core/agent/harness";
startAgentHarnessRun({
runId,
threadId,
adapter: harness,
input: { prompt },
createSession: {
sessionId,
resumeState,
instructions,
sandbox,
permissionMode: "allow-reads",
},
ownerEmail,
orgId,
});
- Persist native session state in SQL.
Use saveAgentHarnessSession, updateAgentHarnessSession, and
getLatestAgentHarnessSessionForThread. The resumeState is opaque; Agent
Native stores it but does not inspect it.
- Surface runs through background agents.
Harness runs are projected into the shared BackgroundAgentRun shape with
createAgentHarnessBackgroundAgentController() and are available through the
existing run routes as goalId=agent-harness.
ACP Agents
Agent-Native can act as an ACP (Agent Client Protocol) client and drive a local coding agent — Gemini CLI, Claude Code, or any ACP-compliant agent — through this same substrate. This is scoped to local coding: the agent is spawned as a child process speaking newline-delimited JSON-RPC over stdio, and inherits the parent environment so it reuses the user's local CLI login. It is not a hosted/sandboxed transport, and it is not a chat/A2A transport.
import {
registerBuiltinAgentHarnesses,
resolveAgentHarness,
} from "@agent-native/core/agent/harness";
registerBuiltinAgentHarnesses();
// Built-in presets (commands overridable via the resolve config):
const gemini = resolveAgentHarness("acp:gemini");
const claude = resolveAgentHarness("acp:claude-code");
// Or any ACP agent by command:
const custom = resolveAgentHarness("acp", {
command: "gemini",
args: ["--experimental-acp"],
});
- The protocol transport (
@zed-industries/agent-client-protocol) is an optional dependency loaded lazily;installPackagesurfaces a clear install hint. - The agent binary (e.g.
@google/gemini-cli,@zed-industries/claude-code-acp) is a separate external CLI the user installs; presets launch it throughnpxby default and the command/args are overridable because agent ACP entry flags still evolve. permissionModemaps onto ACPsession/request_permissionusing the reported tool-call kind: reads always run, edits run underallow-edits, everything risky prompts unlessallow-all. Approvals surface asapproval-requestevents; answer them through the harness session'sapprove().resumeStatecarries the ACPsessionId; resume works when the agent advertises theloadSessioncapability and degrades to a fresh session otherwise.fs/read_text_fileandfs/write_text_fileare served against the session workspace and refuse paths that escape it; terminal methods are not advertised (the agent uses its own shell).
Adapter Guidance
- Keep harness packages optional. Use dynamic imports in adapters and expose an
install hint through
installPackage. - Use the AI SDK harness adapter as one implementation, not as Agent-Native's public abstraction.
- For bridge-backed coding harnesses, require a real sandbox/workspace provider. Do not run arbitrary coding agents in the host process by default.
- Pass only a narrow, intentional set of Agent-Native actions as host tools.
Preserve
defineActionauth, request context, timeouts, truncation, and read-only metadata.
Code Execution Sandbox
- The
run-codetool executes through a pluggableSandboxAdapter(packages/core/src/coding-tools/sandbox/). The defaultLocalChildProcessAdapterspawns a locked-down local Node child process; swap it viaAGENT_NATIVE_SANDBOXorregisterSandboxAdapter()for a Docker/remote backend. An adapter only runs the already-prepared, non-secret module source — it never sees app secrets. See the Sandbox Adapters doc;agent-native add sandbox dockeremits a full Docker-adapter recipe. - Long compute exceeds the hosted ~40s run ceiling via the built-in durable
background backend: per-call
background: trueonrun-code(orAGENT_NATIVE_SANDBOX=backgroundto queue every call) enqueues to thesandbox_executionstable and executes out-of-band — self-dispatched to/_agent-native/sandbox/_process-executionon serverless, in-process on long-lived Node — with lease-based claiming, retries, and owner-scoped polling viarun-code {executionId}/get-code-execution.
Sub-Agent Delegation Depth
- Sub-agent spawning is capped server-side (default depth
2) so delegation chains can't fan out indefinitely. Override at deploy time withAGENT_NATIVE_MAX_SUBAGENT_DEPTH(0disables sub-agents; clamped to16). Enforcement is ambient viaevaluateSubagentDepthinpackages/core/src/server/agent-teams.ts— independent of any tool-level guard. See the Agent Teams doc for the depth model.
Don't
- Don't add Claude Code, Codex, Cursor, Mastra, or Pi as an
AgentEngine. - Don't replay full Agent-Native chat history into a native harness each turn. Resume the harness session instead.
- Don't store resume state in
application_state; it belongs in the harness session SQL table. - Don't expose every app action to every harness session by default.
Related Skills
adding-a-feature— feature parity across UI/actions/instructions/state.delegate-to-agent— background agents use run-manager infrastructure.external-agents— expose openable resources and external-agent surfaces.storing-data— durable SQL state and additive schema changes.
Signals
- GitHub stars
- 5k
- Forks
- 440
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
harness-agents- Source
- github.com/builderio/agent-native