Bring your harness
Use a harness participant when you want to share a local OpenCode, Claude Code, or Codex process with an application in a Gambi room. The harness runs on your machine, in its own workspace, with your existing login.
This is different from sharing a model endpoint. Applications reach a harness participant through the harness attach of the management API, which carries ACP v1 messages. Harness participants never receive OpenAI-compatible inference requests.
Before you start
Section titled “Before you start”You need:
- the Gambi CLI installed, on the same minor version as the hub
- a reachable hub on a trusted network
- an existing room code
- a stable participant ID that you can reuse after a reconnect
- one supported harness installed and authenticated on your machine
If the hub is not on your machine, keep its URL handy. For example, http://192.168.1.10:3000.
Install and authenticate your harness
Section titled “Install and authenticate your harness”Choose one setup. Gambi checks the corresponding local login before it registers the participant.
OpenCode
Section titled “OpenCode”Install OpenCode, then configure at least one provider:
opencode auth loginopencode auth listOpenCode includes its ACP command. Gambi starts opencode acp for you.
Claude Code
Section titled “Claude Code”Install Claude Code and its ACP adapter, then log in:
npm install -g @anthropic-ai/claude-codenpm install -g @agentclientprotocol/claude-agent-acpclaude auth loginclaude auth status --jsonEach person must run the unmodified Anthropic binary with their own local authentication. Gambi does not intermediate a Claude subscription login and must not host Claude Code for third parties. Review Anthropic’s legal and compliance terms before joining.
Install Codex CLI and its ACP adapter, then log in:
npm install -g @openai/codexnpm install -g @agentclientprotocol/codex-acpcodex logincodex login statusJoin the room
Section titled “Join the room”Run one of these commands. Replace the room code, participant ID, and name with your own values.
# OpenCodegambi participant join \ --room ABC123 \ --participant-id arthur-opencode \ --nickname Arthur \ --harness opencode
# Claude Codegambi participant join \ --room ABC123 \ --participant-id bia-claude \ --nickname Bia \ --harness claude-code
# Codexgambi participant join \ --room ABC123 \ --participant-id caio-codex \ --nickname Caio \ --harness codexAdd --hub when the hub runs on another machine:
gambi participant join \ --hub http://192.168.1.10:3000 \ --room ABC123 \ --participant-id arthur-opencode \ --nickname Arthur \ --harness opencodeAdd --password for a password-protected room. Do not pass --endpoint, --header, or --header-env in harness mode. Harness authentication comes from the local harness process.
Check the running participant
Section titled “Check the running participant”When startup succeeds, the CLI reports three milestones:
- the harness process started and its first ACP session opened
- participant registration completed
- the participant tunnel connected
The process stays in the foreground. If the network drops for a moment, the participant reconnects by itself with the same ID, and attached applications keep their streams. Press Ctrl+C once to stop: the participant sends a final workspace snapshot while the harness and the tunnel are still running (best effort, up to 2 seconds), then the tunnel closes, the harness gets 2 seconds to exit before it is killed, and the participant leaves the room.
For machine-readable lifecycle output, use NDJSON:
gambi participant join \ --room ABC123 \ --participant-id arthur-opencode \ --harness opencode \ --format ndjsonThe startup events are harness_started, registered, and tunnel_connected. File changes produce artifact_sent, or artifact_skipped when the workspace is too large to send. A dropped tunnel produces reconnecting, then tunnel_connected again. Ctrl+C produces leaving and left. If the harness exits on its own, the CLI prints harness_exited, leaves the room, and exits with code 3.
Understand the workspace
Section titled “Understand the workspace”The workspace is the folder on your machine where the harness runs. By default Gambi uses this one, creating it empty the first time; a later join with the same room and participant ID reuses it with what it holds:
~/.gambi/workspaces/<room>/<participant-id>/To work in a folder you already have, such as a project checkout or a starter someone shared with you, pass it with --workspace:
gambi participant join \ --room ABC123 \ --participant-id arthur-opencode \ --harness opencode \ --workspace ./my-projectThe participant watches this directory and sends a versioned snapshot of the whole folder one second after file changes settle. It excludes .git, node_modules, symbolic links, and Gambi’s local runtime metadata.
Two limits to know:
- A snapshot larger than 8 MiB is not sent at all. The CLI prints
artifact_skippedwithcause: "tooLarge". Keep large files, datasets, and build output out of the workspace. artifact_sentmeans the snapshot was queued for the hub. If the tunnel drops before it leaves, that snapshot is lost; the next change sends a new one.
The harness login remains local. It is not part of participant registration, lifecycle events, or the tunnel. Workspace files are different. The participant sends them deliberately as artifacts so the attached application can consume the harness output. Nothing travels the other way. The hub cannot write files into your workspace.
Use the harness from an application
Section titled “Use the harness from an application”Any application on the network can attach to your harness with gambi-sdk, open a harness session, send it a prompt, and read what it answers and writes. The application talks to the hub; the hub relays through your tunnel.
import { createClient } from "gambi-sdk";
const client = createClient({ hubUrl: "http://192.168.1.10:3000" });const room = "ABC123";const participant = "arthur-opencode";const sessionId = "demo"; // the session ID is yours to pick
await client.harness.openSession(room, participant, sessionId);
let prompted = false;for await (const event of client.harness.attach(room, participant)) { // The stream replays nothing, so send the prompt once it is open. if (event.type === "harness.connected" && !prompted) { prompted = true; await client.harness.send(room, participant, sessionId, { jsonrpc: "2.0", id: 1, method: "session/prompt", params: { sessionId, prompt: [{ type: "text", text: "Write a README for this folder." }], }, }); } if (event.type === "harness.message" && event.sessionId === sessionId) { const { update } = (event.message.params ?? {}) as { update?: { sessionUpdate?: string; content?: { text?: string } }; }; if (update?.sessionUpdate === "agent_message_chunk") { process.stdout.write(update.content?.text ?? ""); } } if (event.type === "harness.artifact") { console.log(`\nartifact v${event.version}: ${event.files.map((file) => file.path).join(", ")}`); }}The first event of the stream says whether the hub is receiving your harness: harness.connected, or harness.disconnected while your tunnel is down. Nothing that happened before the application attached is replayed, which is why the example sends the prompt only after harness.connected. Every attached application reads every event of your harness, so filter by sessionId, match answers by JSON-RPC id, and give each application its own session ID. If the participant leaves the room, the stream ends with harness.detached.
The message payload is plain ACP v1, so every update type in the ACP schema can arrive here. The SDK reference also shows how an application can host harness participants itself.
For a complete application that orchestrates several harness participants with people steering them, see the experiments in gambiarra-lab.
Preview without starting the harness
Section titled “Preview without starting the harness”Use --dry-run to check that the harness is installed and logged in, and to see the resolved room, participant ID, workspace, harness command, and registration payload:
gambi participant join \ --room ABC123 \ --participant-id arthur-opencode \ --harness opencode \ --dry-run \ --format jsonThis preview does not start the harness process, does not create the workspace folder, and does not talk to the hub.
Common failures
Section titled “Common failures”| Symptom | What to do |
|---|---|
exit code 2 and an invalid value for --harness |
use opencode, claude-code, or codex (fake is a deterministic test harness that calls no model) |
exit code 2 for --endpoint or auth headers |
remove model-provider flags from the harness command |
exit code 2 for --workspace |
add --harness; model participants have no workspace |
exit code 3 before registration |
run the install or login command printed by the CLI, then retry |
exit code 4 and VersionMismatch |
install the Gambi version the error names, so your CLI and the hub are on the same minor version |
exit code 3 and TunnelOpenFailed |
confirm that the hub is reachable and every proxy forwards WebSocket upgrades |
reconnecting events that keep coming |
the hub is unreachable; the participant keeps trying, waiting up to 30 seconds between attempts |
left with reason: "refused" and RoomNotFound |
the hub restarted and lost the room. Create the room again and rejoin |
left with reason: "replaced" |
another process joined with the same participant ID. Use a different ID for each process |
left with reason: "removed" |
someone removed the participant through the hub. The runtime stops and the command exits with code 4 |
artifact_skipped with cause: "tooLarge" |
the workspace is larger than 8 MiB; move large files out of it |
an inference request returns HTTP 400 with inference_not_supported |
use client.harness.attach() instead; harness participants are not model endpoints |
Next steps
Section titled “Next steps”- CLI reference lists every harness flag and lifecycle event.
- SDK reference shows how an application attaches to the participant.
- How tunnels work explains what the hub relays and what it does not inspect.