Repository navigation
fix: ACP spawn fails with unknown agent id for raw harness targets - #166908
Conversation
Raw sessions_spawn ACP targets like "codex" were minted and dispatched as agent:codex:acp:*, so the gateway rejected them as unknown agents. Keep the harness as ACP runtime identity and mint/dispatch under the configured requester or explicit OpenClaw alias. Resume requires requester, backend, and persisted ACP runtime identity to match.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 5:36 AM ET / 09:36 UTC (Revision 7). ClawSweeper reviewWhat this changesSeparate an ACP child's OpenClaw owner from its external coding harness while preserving authorized historical resumes and owner-based channel routing. Example: Spawn an ACP task targeting raw-harness from agent qa
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR remains necessary and now has sufficient real behavior proof. The previous account-routing proof gap is resolved, and no blocking patch defect remains. Priority: P1 Before mergeNone. FindingsNone. Provenance
Agent review detailsHow this fits togetherACP connects OpenClaw agents to external coding harnesses. The spawn path selects the session owner, workspace, channel account, and resume authority before initializing the external harness and dispatching the task. flowchart TD
A[Agent requests ACP task] --> B[Resolve harness and OpenClaw owner]
B --> C[Select owner workspace and channel account]
B --> D[Check current resume authority]
C --> E[Initialize external harness]
D --> E
E --> F[Dispatch child task]
F --> G[Deliver reply through owner account]
Technical reviewBest possible solution: Keep owner selection in the existing spawn path and resume authorization at the manager's initialization boundary, preserving historical access until a separately verified Doctor cutover. Do we have a high-confidence way to reproduce the issue? Yes: current-main source still assigns the raw harness as the child owner, and the supplied real Gateway comparison records Unknown agent id "raw-harness" on pinned main. This read-only review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes: separating owner and harness in the existing orchestration path repairs the identity error without adding configuration or a competing dispatcher, and the updated proof covers historical resumes and distinct owner/requester accounts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bd23988e2b9d. Provenance checked
TestingProof path: shipped entry point. Added test files: 5. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +79, Tests +377, Docs +10. Total +466 across 19 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (6 earlier review cycles)
|
Canonical session entries omit acp, so resume now reads and rechecks acp_sessions.agent instead of the stripped entry. Parent-stream diagnostics use the OpenClaw owner store, not the harness id.
|
@clawsweeper re-review Follow-up on Legacy harness-owned recovery is intentionally deferred to the Doctor cutover in #136165. Live Gateway/ACP harness proof is still not in this PR. |
|
🦞👀 Re-review progress:
|
Keep historical harness-owned resume records accessible under the existing requester, backend, and harness checks. Revalidate source authority after preparation and fence source changes until runtime initialization. Resolve configured default targets through the same alias owner as explicit targets. Original fix by @saariuslystoned; maintainer cleanup and authority regression coverage. Co-authored-by: saariuslystoned <[email protected]>
Pass typed resume revalidation from spawn into manager initialization, preserving source-change fencing without ambient authority. Resolve configured-alias thread binding and inline delivery through the OpenClaw owner, including default aliases, and cover distinct owner/requester accounts.
|
Merged via squash.
|
…penclaw#166908) * fix: keep raw ACP harness ids off OpenClaw session ownership Raw sessions_spawn ACP targets like "codex" were minted and dispatched as agent:codex:acp:*, so the gateway rejected them as unknown agents. Keep the harness as ACP runtime identity and mint/dispatch under the configured requester or explicit OpenClaw alias. Resume requires requester, backend, and persisted ACP runtime identity to match. * fix: authorize ACP resume from indexed runtime identity Canonical session entries omit acp, so resume now reads and rechecks acp_sessions.agent instead of the stripped entry. Parent-stream diagnostics use the OpenClaw owner store, not the harness id. * fix(acp): preserve resume ownership through runtime initialization Keep historical harness-owned resume records accessible under the existing requester, backend, and harness checks. Revalidate source authority after preparation and fence source changes until runtime initialization. Resolve configured default targets through the same alias owner as explicit targets. Original fix by @saariuslystoned; maintainer cleanup and authority regression coverage. Co-authored-by: saariuslystoned <[email protected]> * test(acp): use inferred deferred gate types * test(acp): type the bound spawn fixture accurately * refactor(acp): use the initialized session entry for spawn * fix(acp): pass resume authority and route through the owner account Pass typed resume revalidation from spawn into manager initialization, preserving source-change fencing without ambient authority. Resolve configured-alias thread binding and inline delivery through the OpenClaw owner, including default aliases, and cover distinct owner/requester accounts. --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: saariuslystoned <[email protected]>
acp-raw-harness-owner.patch backports OpenClaw's fix for raw ACP harness spawns (openclaw/openclaw#166908): a sessions_spawn with agentId "claude" creates its session under the agent that asked for it, which the gateway accepts as a known agent. The configured `claude` agent goes away, so sessions belong to the agent that starts them. Such a session starts in that agent's workspace when given no cwd, so the Claude Code skill always passes one. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LNTt5yXBj4uDUwJmPGvXLd
Fixes #138580
What Problem This Solves
Fixes:
sessions_spawnwithruntime: "acp"fails withUnknown agent idwhen the requested external harness is not a configured OpenClaw agent.User Impact
Raw ACP children use the requesting OpenClaw agent's session store, workspace, and Gateway route while retaining the external harness as ACP runtime identity. Configured ACP aliases own their children and select their own bound channel account, whether selected explicitly or through
acp.defaultAgent.Previously recorded harness-owned resume IDs remain accessible with matching requester, backend, harness, and lifecycle. Existing histories are not moved or rewritten. Changed or retired source authority cannot authorize a new resume after preparation.
Why This Change Was Made
The original path used one string for the OpenClaw owner and the external harness. This fix carries them separately through creation, initialization, dispatch, registration, cleanup, parent-stream diagnostics, and account selection. Explicit and default targets share one resolver, and spawn consumes the manager's persisted session entry instead of doing a redundant synchronous database read.
The shipped v2026.9.8 resume contract searched canonical harness-owned records. Authorization checks the configured owner's namespace first, then that historical namespace; a found foreign requester rejects without falling through. This preserves access without a migration. Removing historical lookup requires a verified Doctor cutover; this PR does not depend on the open draft #136165.
Resume authority is now an explicit typed
revalidateResume?: () => Promise<() => void>input, threaded from spawn throughinitializeAcpSpawnRuntimeto the manager. After awaited manager preparation, the closure rereads ownership; its returned synchronous guard runs immediately beforeruntime.ensureSession. Storage-owned source-change notifications invalidate the authorization, andfinallyexpires it and unsubscribes. No ambient AsyncLocalStorage, getStore path, or session-key mismatch guard remains. Fresh initialization creates no resume subscription. No public SDK, protocol, schema, or configuration option changes.Original fix by @saariuslystoned; maintainer cleanup adds compatibility, default-alias resolution, owner-based channel-account routing, explicit final-effect authority checks, documentation, and regression coverage. Contributor commits and credit are preserved.
Evidence
Exact head:
a01c04c77d6eb086c514cc3163b430cb28420ec0. No merge performed.Exact-head CI: success, including production/test types, lint, docs, guards, and selected runtime tests. Final independent Codex autoreview: scoped-clean, no actionable P0–P2 findings. Targeted oxfmt, oxlint, and
git diff --checkpassed.All manual execution for this head used one fresh secretless AWS lease
cbx_fabddf4f88e3, actual typer7a.xlarge(explicitly requested; no quota fallback), launched from clean trusted main39f956c4778cca437c3cccc301efbce56e768500throughscripts/crabbox-untrusted-bootstrap.sh. Every run used--fresh-pr openclaw/openclaw#166908,--no-hydrate,CRABBOX_ENV_ALLOW=CI, full-head verification, IMDS no-role verification, public networking/no Tailscale, and an isolated HOME. Contributor code never ran on the maintainer host.Unit, types, and negative controls
pnpm test <file> --maxWorkers=1; aggregate command wall time was 517.53 s.pnpm tsgo:core: passed, 64.28 s. Covering test graphscore-test-agents-root,core-test-agents-sessions, andcore-test-plugins-platform: passed, 190.07 s. No extension source changed.ownerAgentId: targetAgentId, leaving the tests unchanged. Explicit and default alias cases both failed: expected bot-alpha, received bot-beta (40.56 s). Candidate bytes were restored before the passing sweep.bddfdd59022dd71421ce7b6a6b7e6406bf5e69f4, leaving the regression unchanged. It failed for the intended reason: expected agent:main:acp, received agent:codex:acp (33.99 s). Test/support checksums were verified unchanged, candidate bytes restored, and the source diff checked clean.Real Gateway and ACP process proof
A scripted Responses provider (
mock-openai) drives the realsessions_spawntool through isolated Gateway processes. Bundled ACPX launches a separate synthetic stdio ACP adapter whose JSON-RPC log records actualsession/new,session/load, andsession/promptrequests. The Gateway and ACP manager are not mocked. No vendor model credentials are used.The authority/history scenario passed on the exact candidate in 68.96 s:
The separate default-alias account scenario passed in 51.16 s on the same head. Both synthetic accounts were available and healthy. A real
agentRPC requested a threaded ACP child without an explicitagentId, soacp.defaultAgent: reviewerselected ownerreviewerand runtimeraw-harness.Pinned main was independently checked out, installed, and built in a separate remote worktree. The same raw-target user flow failed as expected in 50.49 s:
Two setup attempts exposed fixture mistakes before any ACP request: the two-agent roster first lacked
agents.ownership="explicit"; after that correction, the synthetic channel declared enabled accounts withoutgateway.startAccount, so normal Gateway readiness rejected it. The final fixture supplies the normal ready/abort/stopped lifecycle and an explicitqasystem agent. No product check or readiness gate was bypassed, and no source changes were required. A nonfatal shared-state WAL checkpoint-busy warning was observed on the pinned-main run; owned-process cleanup is checked separately.The authority fixture pauses
resolveRuntimeCwdForAcpSpawnafter the initial resume lookup, then persists reassignment through the existing runtime API or deletes the source through the authenticated operator RPC. It verifies the mutation before continuing. Reassignment caused zero external operations. Authorized deletion performed one cleanup initialization; the continued stale spawn performed zero operations after deletion acknowledgment.The historical fixture reproduces canonical harness-owned state from the released contract and preserves nonempty external history; it does not execute a published OpenClaw binary. The external ACP adapter and channel are synthetic: this proves Gateway/ACPX/process/ownership/account-routing behavior, not vendor authentication or model behavior. Requester-abort interleavings remain covered by persisted/in-process authority suites rather than the external adapter.
Review findings and scope
The requested ClawSweeper review completed at 2026-10-08T08:13:56Z (Revision 5) on
ce6a03f7e9e37f092a5a86e3b6c4cc825d7804d4; its full durable comment was read. It accepted the prior real-process authority/history proof and raised one valid P1: configured aliases could bind and deliver using the requester's channel account. Account/origin resolution now consumesownerAgentId; ACP admission and initialization retain the harness. Explicit/default alias regressions, the production-only negative control, and the live distinct-account scenario cover that finding and both associated proof requests.ClawSweeper also completed Revision 6 on the new head at 2026-10-08T08:46:30Z. Its full body confirms the previous account-routing finding is fixed, finds no remaining concrete code defect, and requests the actual cross-account thread binding/delivery evidence supplied here.
The coordinator's P2 ambient-authority finding is resolved by the explicit typed callback described above. Its lifecycle and retained-callback expiry are exercised by the persisted worker contract. Earlier findings remain addressed: authoritative indexed harness matching, owner-correct diagnostics, bounded historical resume access, and final-effect authority revalidation/invalidation.
Exact
git diff --numstat origin/main...HEADtotals (merge base1f891df2c45f0ac634d23b0fefded80e693a5978):This follow-up removes 23 net production lines relative to
ce6a03f7e9e3. The overall production LOC target remains exceeded: preserving released resume access and fencing live source authority needs a scoped lifetime guard. Removed duplication includes the trivial owner helper, separate default branch, harness comparison, redundant database read, duplicated ownership facts, and ambient-context plumbing. Further reduction would weaken required checks or expand beyond the owner scope.Commands and cost
All remote commands used this trusted bootstrap form, serially on the same lease:
env -u CRABBOX_AWS_INSTANCE_PROFILE CRABBOX_ENV_ALLOW=CI \ crabbox run --provider aws --id cbx_fabddf4f88e3 \ --fresh-pr openclaw/openclaw#166908 --no-hydrate --timing-json \ --script scripts/crabbox-untrusted-bootstrap.sh -- \ a01c04c77d6eb086c514cc3163b430cb28420ec0 bash -c '<proof payload>'Run IDs:
run_629c15794c73da91cacffd52fed5468c(213 units, types, both negative controls, passing authority/history proof, then alias fixture admission failure);run_b9cd44c80dfaf33da252b6ea750dbe9c(alias fixture readiness failure);run_5003fc54d43ec7b4013475d7d80e24e1(corrected channel lifecycle, alias live proof, and pinned-main comparison).acp-spawn-heartbeat.test.tsacp-spawn.test.ts(includes owner support)acp-spawn-resume.worker.test.tsacp-spawn-target.test.tssession-meta-resume.test.tsThe worker case uses canonical persistence, indexed reads, and the real initializer with deferred interleavings; a mock-only test would miss stale snapshots and final-effect defects. No timers, sleeps, serial test config, or test-only production seam was added. Every owned Gateway and external adapter process stopped with zero cleanup errors; no operator state or ports were used. Lease cleanup is not confirmed: the stop request timed out, the last successful listing still showed
cbx_fabddf4f88e3active, and the subsequent reconciliation read timed out. The lease ID is retained for cleanup recovery when the broker responds.Exact module test, typecheck, negative-control, and live commands
Synthetic external-process authority/history proof fixture
Save as
/tmp/acp-adapter-authority-proof.mtson the secretless lease after the QA build. This task-owned fixture creates isolated state and ephemeral ports, uses bundled ACPX, and joins its Gateway and adapter processes.Synthetic default-alias thread/account delivery proof fixture
Save as
/tmp/acp-alias-account-proof.mtson the secretless lease after the QA build. This task-owned fixture creates isolated state and ephemeral ports, uses bundled ACPX, and joins its Gateway and adapter processes.