Skip to content

Run hive seats on OpenClaw through a shared Gateway - #142

Merged
sanil-23 merged 13 commits into
tinyhumansai:mainfrom
sanil-23:openclaw-seats
Nov 27, 2026
Merged

sanil-23 merged 13 commits into
tinyhumansai:mainfrom
sanil-23:openclaw-seats

Conversation

@sanil-23

@sanil-23 sanil-23 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follows #140 and #141, both merged. This PR's diff is its own two commits:

  • Run hive seats on OpenClaw through a shared Gateway
  • Wait for the OpenClaw Gateway to be usable, not just listening

OpenClaw becomes a hive seat over ACP, beside OpenHuman, Claude Code and Codex.

OpenClaw's ACP bridge (openclaw acp) rejects tool servers passed when a session opens. So each seat's tools go into the config of the Gateway the bridge connects to: one Gateway agent per seat, holding that seat's tool server and bearer token, and allowed only that server's tools. All of OpenClaw's built-in tool groups are denied, and tool search and code mode are off. ADR 0038 said OpenClaw's descriptor would follow "with its shared Gateway supervised beside the bridge"; this is it.

Related issue

None. Listed as a follow-up in #140.

API or behavior changes

New public API in tinyhivemind-acp:

  • openclaw module:
    • GatewayPlan builds the Gateway config from the seats' tool servers. Its Debug hides the token.
    • Gateway runs the Gateway as a supervised Instance. It counts as ready once GET /readyz answers 200, not merely once its port accepts connections.
    • GatewaySeat.
    • Agent::openclaw runs a seat's bridge on its Gateway agent's session, and reads the Gateway token from a file rather than its arguments.
  • Agent::session_mcp (new field): when false, sessions open with no tool servers, and the agent needn't advertise HTTP tool-server support at initialize. Claude Code and Codex keep true, so their behaviour is unchanged.
  • Templates: {seat} (the seat's id) is a new template value, and Agent::args are now documented as templated, which they already were.

Every seat of a Gateway is in its plan when it starts; a seat added later needs a new Gateway. OpenClaw reports no per-turn token usage, which the client already treats as optional.

What this found

  • The Gateway listens before it can serve a bridge. The first readiness check only waited for the port to accept connections. A bridge that connected before the Gateway's startup work settled exited during initialize, failing about one full live run in five. OpenClaw's own docs give /healthz as liveness and /readyz as usable readiness. After switching to /readyz, 10 full live runs passed in a row.
  • docs/specs/harnesses.md still describes OpenClaw through the Gateway's own WebSocket protocol. ADR 0038 now says ACP. Updating the spec fits with its pending split, which Run hive seats on Claude Code and Codex over ACP, beside OpenHuman #140 deferred.

Validation

Run on Linux (all-in), against the pinned agents (OpenClaw 2026.10.33, the version the bridge reports):

  • cargo fmt --all -- --check: OK
  • cargo clippy -p tinyhivemind-acp --all-targets --all-features -- -D warnings: OK. Only the ACP crate, AGENTS.md and ADR 0038 changed; the workspace-wide commands ran on Run hive seats on Claude Code and Codex over ACP, beside OpenHuman #140.
  • RUSTDOCFLAGS="-D warnings" cargo doc -p tinyhivemind-acp --no-deps --all-features: OK
  • cargo test -p tinyhivemind-acp --all-features with every live agent set: 30 unit tests, plus all 12 live tests passing in 10 full runs in a row, with no agent or Gateway process left afterwards.
  • The same with no live agents set: the live tests skip cleanly.
  • Mutations, each run on the OpenClaw seat test:
    • an OpenClaw session that passes the tool server: fails (the start is refused for lack of HTTP tool-server support);
    • a Gateway config without the seat's server: fails (the seat cannot post, and the episode stalls).

Tests

  • Unit (src/openclaw/test.rs):
    • the config per seat (its own server and bearer, the deny list, the provider);
    • ownership with one seat and with two;
    • the hidden token and where bridges find it;
    • the bridge's arguments;
    • the readiness probe answering 200, answering 503, and not listening;
    • a Gateway that exits before it is ready;
    • a relative directory.
  • Unit (protocol): accept with session_mcp off.
  • Live tests, new:
    • an OpenClaw seat alone;
    • a hive of all four harnesses;
    • an OpenClaw writer in the edit test;
    • OpenClaw leading a delegation to the other three, and Codex leading with OpenClaw among the seats it asks.
  • Live tests, moved: the edit test moved to tests/hive/edit.rs, so hive.rs stays under 700 lines. The existing tests keep their three harnesses, so they run without OpenClaw installed.

Deliberately untested in unit tests: a Gateway that becomes ready, and stopping it. Both need a real Gateway, and the live tests cover them. As with #140's seat code, CI runs no live agents, so src/openclaw/mod.rs will be under the 90% per-file line coverage gate. That gate is currently hidden by main's failing deepswe_hive step. A fake ACP agent for the coverage gap is the open follow-up from #140.

Documentation

  • The crate README and src/README.md.
  • The new src/openclaw/README.md.
  • src/agent/README.md.
  • tests/README.md and tests/hive/README.md.
  • ADR 0038's decision.
  • The crate list in AGENTS.md.

Checklist

  • The change is focused on one logical change
  • No new #[allow(...)], #[ignore], or relaxed lints
  • No secrets, tokens, or .env contents in the diff or the description

🤖 Generated with Claude Code

sanil-23 and others added 13 commits November 27, 2026 01:36
Two seats run the pinned openhuman-core through the process runner,
registered with a real coordinator and served hive tools by a real
tinyhivemind-mcp server, one bearer each. A loopback model reads each
rendered turn, posts, retries the same call, then completes. The test
checks each seat posts once under its own name, the retry returns the
first result, the episode settles, and no process is left after stop.

Opted into with THM_OPENHUMAN_CORE, like the crate's other live tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude Code speaks only Anthropic's Messages API, so the kind gets its own
model API and a new capability row: provider anthropic with an explicit
endpoint and no credential, which it alone accepts. An openai endpoint is
rejected for it by the spec; every other row matches codex's. ADR 0037
records the decision as proposed until a conformance run on the pinned
release backs it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One minimal ACP client drove Claude Code, Codex and OpenClaw against the
spike's scripted model and MCP stub. Each called the hive tool as the right
seat, cancelled, resumed after a restart and replayed nothing, once
Claude Code's built-in tools and Codex's auto review were turned off.
OpenClaw reports no per-turn usage over ACP and costs about 2 GB with its
Gateway; the adapters roughly double a Codex seat's memory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One harness client for every agent that speaks the Agent Client Protocol
over stdio, on the host's supervised JSON lines. What differs between
agents is an Agent descriptor of data: command, environment, files,
session metadata and mode. Claude Code and Codex have descriptors, with
the settings the ACP runs found each needs: Claude Code's built-in tools
and tool search off, Codex in read-only mode with a direct-tool catalog.

A permission request for a host tool is allowed by the client, since the
tool server judges hive tools; any other goes to the seat's approver.

Live tests on the pinned agents run a Claude Code seat, a Codex seat, and
a mixed hive of OpenHuman, Claude Code and Codex in one episode with a
real coordinator and tool server: each seat posts once as itself though
it retries, and the episode settles. ADR 0038 records the decision as
proposed until the conformance suite runs on each agent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An OpenHuman, a Claude Code and a Codex seat each write a file with the
host's write_file executable tool, which runs in the seat's own
workspace under the host's access gate. A read-only seat's write is
refused by the host and writes nothing. Agents' own tools stay off, as
the harness spec requires.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The edit test now has every editing seat retry its write, try a path
that climbs out of its workspace and an absolute one, and runs the
Claude Code and Codex seats supervised under a host approver that
records every request. It checks that a retried write runs once and
returns the first result, that both escapes are refused and nothing
lands outside a workspace, that the approver judges exactly the
supervised seats and is not asked again for a retry, and that a seat
the approver denies writes nothing. Editing seats post once, so an
OpenHuman seat's turn stays within its eight model calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From review of tinyhumansai#140:
- refuse an agent whose initialize lacks protocol version 1 or HTTP MCP,
  and resume a session only when the agent offers loadSession;
- keep a session as the seat's before setting its mode, so a failed
  session/set_mode is retried on it;
- keep a process until its stop succeeds, so a failed stop can be retried;
- close a turn's route before its last drain, and on drop answer what it
  still holds; answer a cancelled turn's permission requests `cancelled`;
- treat a prompt result without a stopReason as a broken protocol;
- hold a seat id from start to the end of stop, stopping what a dropped
  start began before freeing it;
- fill templates in one pass and TOML-escape values in .toml files;
- give write_codex_catalog a typed CatalogError;
- bound every wait in the connection tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From review of tinyhumansai#140: the replay row measured only a new agent starting,
not a loaded interrupted session, so it and ADR 0038 now say so; the
conclusion names Claude Code's CLI outliving its adapter; the spike
client decodes stdout as UTF-8 and fails its calls once the agent closes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The test writes a script and runs it at once. When another test forks a
child in between, the child holds the script open for writing until it
execs, and running the script fails with ETXTBSY: about one run in
twenty of the crate's unit tests on a busy machine. The test now tries
again while the script is busy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
OpenHuman appends how long a tool call took (`[took 0.1s]`) to its
result, so a retry the host answers from its record can still read
differently from the first call when the first was slow. Under load the
edit test failed on exactly that. The scripted model now drops that
suffix, as it already drops Codex's timing prefix, before it compares.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A lead on each harness in turn is the only starter: it asks the seats on
the other two harnesses in one conversation, each answers there through
its own model API, the lead completes on a later turn showing both
answers, and a member nobody asked never runs. The round is two wide; at
the default width of one, an ask naming two seats fails the episode.

The scripted model now gives every response and tool call a fresh id.
Claude Code joins a response's stored parts by id and interrupts a tool
call whose id its session has seen, so with fixed ids a seat's second
turn looped until the episode's turn wall.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
OpenClaw's ACP bridge refuses MCP servers per session, so a seat's tool
server goes into the config of the Gateway the bridge connects to: one
Gateway agent per seat, with that seat's server and bearer, allowed only
that server's tools. The new `openclaw` module writes that config and
supervises the Gateway as an `Instance`, ready once it listens, and
`Agent::openclaw` runs a seat's bridge on its Gateway agent's session.

The client gains what that needs: `Agent::session_mcp`, false for an
agent given its tools elsewhere, which then opens sessions with no MCP
servers and need not offer HTTP MCP at `initialize`; and a `{seat}`
template value. The bridge reports no per-turn usage, which the client
already treats as optional.

The live tests now start a hive's Gateway once every seat's tools are
served: an OpenClaw seat alone, a hive of all four harnesses, an
OpenClaw writer in the edit test, and lead-only episodes where OpenClaw
leads and where it is asked. The edit test moves to `hive/edit.rs`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Gateway was taken as ready once its port accepted a connection. It
listens before its startup work settles, and a bridge that connected in
that window exited during `initialize`: about one full live run in five
failed starting an OpenClaw seat. OpenClaw's own probe for this is
`GET /readyz`, which answers 200 once the Gateway is usable, so
`Gateway::start` now waits for that. Ten full live runs then passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 56 billable files and costs up to $14.00.

Or wait 59 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f7fdc7ae-329d-4e5e-8927-939166da76a5
Commits

Reviewing files that changed from the base of the PR and between a01e4cf and 30e3d70.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 56

  • .github/scripts/assert-pure.sh
  • AGENTS.md
  • Cargo.toml
  • crates/tinyhivemind-acp/Cargo.toml
  • crates/tinyhivemind-acp/README.md
  • crates/tinyhivemind-acp/src/README.md
  • crates/tinyhivemind-acp/src/agent/README.md
  • crates/tinyhivemind-acp/src/agent/mod.rs
  • crates/tinyhivemind-acp/src/agent/test.rs
  • crates/tinyhivemind-acp/src/capability/README.md
  • crates/tinyhivemind-acp/src/capability/mod.rs
  • crates/tinyhivemind-acp/src/capability/test.rs
  • crates/tinyhivemind-acp/src/connection/README.md
  • crates/tinyhivemind-acp/src/connection/mod.rs
  • crates/tinyhivemind-acp/src/connection/test.rs
  • crates/tinyhivemind-acp/src/error/README.md
  • crates/tinyhivemind-acp/src/error/mod.rs
  • crates/tinyhivemind-acp/src/error/test.rs
  • crates/tinyhivemind-acp/src/harness/README.md
  • crates/tinyhivemind-acp/src/harness/mod.rs
  • crates/tinyhivemind-acp/src/lib.rs
  • crates/tinyhivemind-acp/src/openclaw/README.md
  • crates/tinyhivemind-acp/src/openclaw/mod.rs
  • crates/tinyhivemind-acp/src/openclaw/test.rs
  • crates/tinyhivemind-acp/src/protocol/README.md
  • crates/tinyhivemind-acp/src/protocol/mod.rs
  • crates/tinyhivemind-acp/src/protocol/test.rs
  • crates/tinyhivemind-acp/src/seat/README.md
  • crates/tinyhivemind-acp/src/seat/mod.rs
  • crates/tinyhivemind-acp/src/seat/turn.rs
  • crates/tinyhivemind-acp/tests/README.md
  • crates/tinyhivemind-acp/tests/hive.rs
  • crates/tinyhivemind-acp/tests/hive/README.md
  • crates/tinyhivemind-acp/tests/hive/delegation.rs
  • crates/tinyhivemind-acp/tests/hive/edit.rs
  • crates/tinyhivemind-acp/tests/hive/model.rs
  • crates/tinyhivemind-lang/src/harness/capability.rs
  • crates/tinyhivemind-lang/src/harness/mod.rs
  • crates/tinyhivemind-lang/src/harness/test.rs
  • crates/tinyhivemind-lang/src/validation/capability/mod.rs
  • crates/tinyhivemind-lang/src/validation/test/harness.rs
  • crates/tinyhivemind-openhuman-process/Cargo.toml
  • crates/tinyhivemind-openhuman-process/tests/README.md
  • crates/tinyhivemind-openhuman-process/tests/hive.rs
  • crates/tinyhivemind-openhuman-process/tests/hive/README.md
  • crates/tinyhivemind-openhuman-process/tests/hive/model.rs
  • docs/adr/0037-claude-code-is-a-fourth-harness-kind.md
  • docs/adr/0038-acp-agents-share-one-client.md
  • docs/adr/README.md
  • docs/experiments/2026-11-26-acp-harnesses.md
  • docs/experiments/2026-11-26-acp-harnesses/README.md
  • docs/experiments/2026-11-26-acp-harnesses/acp.mjs
  • docs/experiments/2026-11-26-acp-harnesses/fixture.mjs
  • docs/experiments/2026-11-26-acp-harnesses/measure.mjs
  • docs/experiments/README.md
  • docs/specs/harnesses.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@sanil-23 sanil-23 changed the title Run hive seats on OpenClaw through a shared Gateway (stacked on #141) Run hive seats on OpenClaw through a shared Gateway Nov 27, 2026
@sanil-23
sanil-23 merged commit e1dd6ec into tinyhumansai:main Nov 27, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant