GeezerVison is showing github.com — Follow-up (#2229): expose sessions_spawn to headless/CLI OpenClaw sessions (packaging patch) · Issue #2257 · developing-today/code
Follow-up (#2229): expose sessions_spawn to headless/CLI OpenClaw sessions (packaging patch) #2257DescriptionFollow-up to #2229 (method 2 of 3). Method 3 — the opencode-route provider front — shipped as the priority build (PR #2250, live-proven). This method was descoped by Drew on 2026-10-29 to a follow-up: sometime soon / when an OpenClaw-origin workload needs to spawn subagents from headless/CLI sessions.
What it adds
sessions_spawn exposed to headless/CLI OpenClaw sessions, so a CLI-driven agent turn can spawn subagents — including ACP-runtime targets such as the opencode-acp entry (the method-1 follow-up), whose live proof depends on this surface.
Determination (already made, 2026-10-29 — this is a packaging patch, not config)
- In the pinned OpenClaw 2026.10.7 dist,
createSessionsSpawnTool is gated by !embedded || options?.allowGatewaySubagentBinding === true (chunk openclaw-tools-QaFYBVQi.mjs). isEmbeddedMode() is a process-local flag set only by EmbeddedTuiBackend.start(), and openclaw agent CLI turns run through that embedded backend even when gateway-attached. allowGatewaySubagentBinding: true is passed only by gateway/channel-side runners. No config key or tool profile feeds either flag — the tool sits in the "sessions" group with profiles ["coding","messaging"]; profile is not the blocker.
- Empirically absent on every surface tried: CLI via the live gateway, CLI
--local, and a server-side chat.send turn (the agent reported sessions_spawn is not in its loadable tool set; the deferred-tool layer answers select:sessions_spawn with "No deferred tool matched").
- Route: nix-openclaw's instance options expose
gatewayPath + gatewayPnpmDepsHash; when gatewayPath is set, the module builds the gateway from that source. So: commit a .patch against the pinned upstream source flipping the gate condition, wire gatewayPath to a patched-source derivation in the fleet config, and document plainly that it is a source patch carried by the packaging, not an upstream config option.
Proof when built
Patch a copied dist tree first for a fast mechanism proof (spawn with agentId="opencode" and agentId="opencode-acp" → check acp_sessions in the OpenClaw state plus a new row in OpenCode session_v2), then land the durable source patch. Activitydeveloping-today commented on Oct 29, 2026 dezren39 commented on Oct 30, 2026 Drew's directive (2026-10-29 21:44 CDT, main chat): "I want the other options built and functional." This issue (headless/CLI sessions_spawn exposure) is one of those options — build it and prove it functional alongside #2256. Scope note (Drew, 21:45 CDT): sessions_spawn is explicit task dispatch, so OpenCode running the task is correct there; the routing-only principle applies to the opencode-route model door (see the new follow-up issue), not to dispatch paths. dezren39 commented on Nov 3, 2026
Triage @ current main (2026-11-03) — still live, fix path re-confirmed
Verdict: the gap is real on the pinned package and on upstream main. Nothing has shipped since the 2026-10-29 determination; this issue is a scoped, buildable packaging task, not a config task.
Evidence (fresh at this triage)
- Pinned dist still gates the tool. Installed gateway
openclaw-2026.10.7:
/nix/store/f2crizywkx7d7k8831xmnhjx4kcm2ki4-openclaw-gateway-2026.10.7/lib/node_modules/openclaw/dist/openclaw-tools-QaFYBVQi.mjs:16699
still reads !embedded || options?.allowGatewaySubagentBinding === true ? createSessionsSpawnTool({…}) : null.
- Upstream main still gates it the same way.
src/agents/openclaw-tools.ts:646-647 (raw main, fetched 2026-11-03) carries the identical condition.
- Still no config key feeds it.
allowGatewaySubagentBinding is an internal option param (src/plugins/tools.ts:89,111, src/agents/runtime-plugins.ts:61,86,188), not a config keyspace entry. A settings/profile workaround does not exist — as the issue body already concluded.
- Version bump does not fix it. npm
openclaw latest is 2026.10.10; pinned nix package is 2026.10.7; upstream main is unchanged, so a plain bump buys nothing.
- The packaging escape hatch is still the only one.
nix-openclaw pin 4b261b08c173467dc41db7b43d8265529c435055 (2026-10-30) is the repo HEAD today; gatewayPath + gatewayPnpmDepsHash remain the only source override (nix/modules/home-manager/openclaw/options-instance.nix:61-71).
- No competing work. No open PR/branch claims Follow-up (#2229): expose sessions_spawn to headless/CLI OpenClaw sessions (packaging patch) #2257 (searched issues, PRs, branches). The only adjacent open work is draft PR Wire OpenClaw ACP adapters to Nix runtime plugin #3275 (ACP adapter wiring, Nix-package the Claude/Codex ACP adapters — repoint OpenClaw acpx off tmp/plugin-captures #1711) — it touches adapters, not this gate; do not fold this into it.
One design decision blocks implementation
gatewayPath is typed nullOr str, documented "dev only", and consumed as builtins.path { path = inst.gatewayPath; } (instance.nix:60-63) — it must be a real filesystem path at evaluation time. A pkgs.applyPatches-derived store path is therefore IFD-fragile: it only exists after it is realized, so home-manager switch would fail on a cold store and succeed on a warm one. Options, in order of cleanliness:
- Upstream
nix-openclaw: add a gatewayPatches (or gatewaySrc) option to the instance module — then this repo carries only a .patch file. Needs a PR to openclaw/nix-openclaw + a pin bump. Cleanest, slowest.
- Follow-able fork pin: point the
nix-openclaw flake input at a developing-today fork carrying the patch + option, owned by us, maintained with the fork-sync discipline. No upstream dependency. Recommended for this week.
- Pre-realized store path: build the patched source first, then point
gatewayPath at its store path. Works, but makes the rebuild order-dependent and rejects one-command rebuilds. Not recommended.
Recommendation: (2) now, (1) as upstream follow-through. This is a packaging-mechanism call inside the worker's remit, so it is not escalated; the follow-up build task below carries the decision.
Implementation scope when built
patches/openclaw/sessions-spawn-headless.patch — one hunk on src/agents/openclaw-openclaw-tools.ts at the !embedded || gate (exact hunk context: openclaw-tools.ts:646). Simplest faithful change for this fleet: drop the embedded exclusion at build time, keeping options?.allowGatewaySubagentBinding intact. Patch header must state it is carried by packaging, not an upstream config, and name the upstream lines it targets.
- Packaging wiring per option (2) above: fork pin in
flake.nix/flake.lock + programs.openclaw.instance.gatewayPath/gatewayPnpmDepsHash in home/openclaw/default.nix (currently neither is set).
- Proof (mechanism-first, per the issue body): patched tree → CLI turn spawning
agentId="opencode" and agentId="opencode-acp" → acp_sessions rows in OpenClaw state + new rows in OpenCode session_v2; also confirm select:sessions_spawn no longer answers "No deferred tool matched" and the tool appears in the CLI turn's loadable set (/tools).
Ordering, blockers, risks
developing-today commented on Nov 3, 2026 agent-note:v1
state: triaged (coverage pass)
Coverage pass 2026-11-03: reviewed in the fleet-wide per-issue pass (drift / overlap / already-handled / stale / blockers / ordering). Verdict: still live; queued in repo-health-code-pilot as triage at priority 30 (priority/none). If this is already handled at current main, the triage closes it with evidence; if it needs splitting, the triage files the split.
Found via: coverage pass 2026-11-03 dezren39 commented on Nov 15, 2026
🤖 Agent note · done — live proof recorded, PR #5056 merging
- Agent: repo-worker-code (Muse lane code-c)
- Session / ID: task 8042
- Host deployment (this shift): PR feat(openclaw): pin nix-openclaw fork carrying the sessions_spawn headless patch (#2257) #5056 branch rebased on current main (final head dfba981 on main ea122b5), amd toplevel built clean (
/nix/store/29szfcgygdndgb6269a8cxyj9238h0qm-nixos-system-amd-26.11.20261102.f9887a8), host switched (system generation 554 → 555), openclaw-gateway restarted 2026-11-14 23:11 CST onto the fork-built gateway (/nix/store/6qzzf57p3vwkmc2wkzsxg0qjrh66w6bg-openclaw-gateway-unstable-157d8c2b, dist verified: createSessionsSpawnTool is in the tool list unconditionally — the !embedded gate is gone).
- Proof 1 — tool present in an embedded/CLI turn (the exact path the gate blocked):
openclaw agent --local turn called sessions_spawn and received a policy answer (agentId is not allowed for sessions_spawn (allowed: main) for the subagent runtime). Before the patch the tool was absent from this turn's loadable set entirely ("No deferred tool matched").
- Proof 2 — full dispatch, agentId=opencode: gateway turn →
sessions_spawn with runtime: "acp", agentId: "opencode" returned status: "accepted", childSessionKey: "agent:main:acp:d6db94ac-1da2-47bd-b221-9125695ba4cd", runId: "281f5105-290f-4384-a34b-f0f89a07c634". Resulting acp_sessions row in OpenClaw state: session_id d7cd029a-5a5c-48a9-8fe4-48b474025acf, backend acpx, agent opencode. The spawned OpenCode serve session was created and its turn ran; the child turn itself ended AcpRuntimeError [ACP_TURN_FAILED]: serve session error: Free usage limit reached — a provider quota wall in the spawned session's model route, not a mechanism failure (the dispatch chain OpenClaw → acpx → OpenCode serve completed end to end).
- opencode-acp half: superseded by Drew's 2026-11-05 adjudication on Follow-up (#2229): ACP-runtime agent entry for OpenClaw→OpenCode dispatch (opencode-acp) #2256 (the opencode-acp standing agent entry will not be restored; embedded is the standing runtime; a bounded ACP capability proof is tracked separately). No config change made for it here.
- Blockers removed en route (both pre-existing on main, both fixed in their own PRs): mcpx buildcheck: TestVersionHasOneSourceOfTruth still requires the Containerfile retired by #5771 — mcpx (and the amd toplevel) no longer builds on main #10420 (mcpx buildcheck still required the Containerfile retired by Containers: Nix-build audit — mcpx Containerfile, duplicate lab-ops Dockerfile, amd-crd definition-or-waiver #5771 — fixed by PR fix(mcpx): buildcheck version guard follows the Containerfile retirement (#10420) #10421) and pkgs/id buildcheck: command-list guard fails on main — publish/unpublish/publications (added by #2147 slice 3b) missing from cli/mod.rs doc list and README table; amd toplevel does not build #10424 (pkgs/id command-list guard missing publish/unpublish/publications from id(serve): dynamic publish/unpublish — bind and unbind programs and pages to ports, interfaces, and paths at runtime #2147 — fixed by PR fix(id): list publish/unpublish/publications in cli doc list and README (#10424) #10426). The earlier zig blocker pkgs/id: build.zig fails on zig 0.16 (OptimizeMode.small) — blocks nixos-rebuild switch #10313 was already fixed on main.
dezren39 commented on Nov 15, 2026 Closed via PR #5056 (merged fc585f3) with live proof recorded in the agent note above (comment 6889906175): host switched to the fork-built gateway (generation 555), sessions_spawn present in embedded/CLI turns and dispatched agentId=opencode over ACP (acp_sessions row d7cd029a-5a5c-48a9-8fe4-48b474025acf). The opencode-acp half is superseded by Drew's 2026-11-05 adjudication on #2256.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|