Skip to content
Skillpedia
Agents7.6k · #13163

harness-agents

What it does

This skill describes how a full agent harness, such as Claude Code, Codex or Cursor, is added to Agent-Native through its own runtime layer. It covers starting a run, saving session state and surfacing background work. It is for developers who want those agents inside an app.

When to use it

  • ✓When you want Claude Code or Codex to run a task inside an Agent-Native app.
  • ✓When an external agent program needs its session state saved between turns.
  • ✓When you want background agent runs shown in the app.

Skill link

https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/harness-agents/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/harness-agents/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Can you let Codex run a coding task inside my app and keep its session so it can continue later?”

5 new skills a week. 1 minute to read.

How it works

The developer registers the harness adapter and starts a run through the run manager. The session state is saved in the app's database, and the harness keeps its own loop.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Harness Agents

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

  1. Register or resolve a harness adapter.
import {
  registerBuiltinAgentHarnesses,
  resolveAgentHarness,
} from "@agent-native/core/agent/harness";

registerBuiltinAgentHarnesses();
const harness = resolveAgentHarness("ai-sdk-harness:codex");
  1. 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,
});
  1. Persist native session state in SQL.

Use saveAgentHarnessSession, updateAgentHarnessSession, and getLatestAgentHarnessSessionForThread. The resumeState is opaque; Agent Native stores it but does not inspect it.

  1. 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; installPackage surfaces 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 through npx by default and the command/args are overridable because agent ACP entry flags still evolve.
  • permissionMode maps onto ACP session/request_permission using the reported tool-call kind: reads always run, edits run under allow-edits, everything risky prompts unless allow-all. Approvals surface as approval-request events; answer them through the harness session's approve().
  • resumeState carries the ACP sessionId; resume works when the agent advertises the loadSession capability and degrades to a fresh session otherwise.
  • fs/read_text_file and fs/write_text_file are 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 defineAction auth, request context, timeouts, truncation, and read-only metadata.

Code Execution Sandbox

  • The run-code tool executes through a pluggable SandboxAdapter (packages/core/src/coding-tools/sandbox/). The default LocalChildProcessAdapter spawns a locked-down local Node child process; swap it via AGENT_NATIVE_SANDBOX or `registerSandboxAdapt
FAQ

Is a harness the same as a model provider?

No. The skill says full harnesses own their own loop and state, so they are not plugged in as model providers.

Who can read the saved session state?

The framework stores it without inspecting it, since the state is opaque to Agent-Native.

Which harnesses are supported?

The skill names several, including Claude Code, Codex, Pi, Cursor and Mastra.

Details

Original description by the author

Add or use full agent harness runtimes like Claude Code, Codex, Pi, Cursor, Mastra, or ACP agents inside Agent-Native.

repo: BuilderIO/agent-native

Popularity

GitHub stars
7.6k
Ranking position
#13163
License
MIT
Updated
11/2/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills