Repository navigation
fix(agents): pass durable session key as visible-spawn parent lineage - #137779
vincentkoc merged 2 commits into
Conversation
|
🦞👀 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 September 6, 2026, 11:52 PM ET / September 7, 2026, 03:52 UTC. ClawSweeper reviewWhat this changesUses durable session keys for subagent creation and listing while preserving sandbox restrictions and access to existing policy-owned background tasks. Merge readiness✅ Ready for maintainer review This remains a useful fix absent from current main. The reviewed head preserves sandbox admission and retained media ownership, and the supplied boundary evidence supports the repair; no blocking introduced defect was found. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw builds agent tools from a durable conversation identity and a separate policy identity. Spawn tools create child sessions through Gateway, while background-task tools use ownership records to list and cancel work. flowchart TD
A[Conversation and policy identities] --> B[Agent tool factory]
B --> C[Durable spawn identity]
C --> D[Sandbox admission]
D --> E[Gateway child session]
B --> F[Durable and policy task owners]
F --> G[Scoped task listing and cancellation]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +37, Tests +366. Total +403 across 9 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. Technical reviewBest possible solution: Keep durable lineage and controller identity aligned while retaining active sandbox classification and existing media-task ownership. Do we have a high-confidence way to reproduce the issue? Yes, from source: distinct policy and durable session keys send the policy key into Gateway parent lookup on current main. Supplied before/after boundary evidence corroborates that path; this read-only review did not execute it. Is this the best way to solve the issue? Yes. Repairing the factory's identity selection addresses the producer, and the accompanying sandbox propagation and dual-key task lookup preserve existing restrictions and retained records. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c27999bcfc37. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (18 earlier review cycles; latest 8 shown)
|
4f6e31d to
aeb5ac1
Compare
524c633 to
691e6ca
Compare
691e6ca to
55a00b9
Compare
d0c027a to
36e6d84
Compare
36e6d84 to
d396f0c
Compare
sessions_spawn's visible-spawn path received the sandbox/policy session key as agentSessionKey, which for Telegram DMs includes an account-id segment (agent:main:telegram:default:direct:<id>). That policy key has no durable store entry, so Gateway's parent-session lookup failed with 'unknown parent session'. All other tools already prefer runSessionKey; this aligns sessions_spawn with that pattern. Fixes openclaw#137690.
d396f0c to
cb12508
Compare
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Additional proof provided in #137690 @clawsweeper re-review |
|
@clawsweeper re-review. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Thanks for the additional proof in #137690 — the in-process split-key evidence there is the stronger boundary proof ClawSweeper noted was optional, and it confirms the same trusted-caller second gate that Adam-Researchh's corrected workaround addresses. For reviewer clarity on scope, #137779 and the corrected workaround in #137690 repair two different segments of the same spawn data flow; they are complementary, not overlapping:
So the two-gate fix Adam-Researchh verified is already on One caveat worth flagging for release routing, not for this PR: Adam-Researchh reproduced the two-gate failure on the 2026.9.2 npm release, but |
|
Merged via squash.
|
…openclaw#137779) * fix(agents): pass durable session key as visible-spawn parent lineage sessions_spawn's visible-spawn path received the sandbox/policy session key as agentSessionKey, which for Telegram DMs includes an account-id segment (agent:main:telegram:default:direct:<id>). That policy key has no durable store entry, so Gateway's parent-session lookup failed with 'unknown parent session'. All other tools already prefer runSessionKey; this aligns sessions_spawn with that pattern. Fixes openclaw#137690. * fix(agents): preserve retained media task ownership --------- Co-authored-by: Vincent Koc <[email protected]>
…ned children match their parent Spawned children persist spawnedBy under the durable run session key, because the Gateway canonicalizes the spawn parent on sessions.create. sessions_send was the one session tool still built with the channel route key, so a parent running from a DM mapped to its main session never matched its own visible child and started the A2A announce flow after a waited reply. Hand sessions_send runSessionKey ?? agentSessionKey like sessions_spawn and the other session tools (see openclaw#137779), add the factory wiring regression, and add the gated real-Gateway product-proof lane that reproduces the visible spawn, waited send, and absence of a follow-up announce run.
Fixes #137690
What Problem This Solves
When a user asks the bot to spawn a sub-agent from a Telegram DM,
sessions_spawnfails withunknown parent sessionbecause the visible-spawn path sends the wrong session key to Gateway. After this fix, Telegram-originated sessions can spawn visible sub-agents the same way web dashboard sessions do.createOpenClawToolsbuilt thesessions_spawntool withagentSessionKey: options?.agentSessionKey— the sandbox/policy key. For Telegram DMs this key includes an account-id segment (agent:main:telegram:default:direct:<id>), but the durable store entry is persisted under a different key, so Gateway's parent-session lookup fails.options?.runSessionKey ?? options?.agentSessionKey(durable key preferred) for parent lineage, matching existing durable-session consumers, and separate lineage from sandbox classification, controller identity, and retained-task ownership so the substitution does not weaken hidden-spawn sandbox admission, lose run visibility, or drop retained task rows.createSessionsSpawnTooluses the durable key for parent lineage. (2) Hidden native spawn forwards the explicitopts.sandboxedflag throughSpawnSubagentContexttoresolveSubagentChildPlan, which prefers it over key-derived status, mirroring the visible/ACP paths. (3)createSubagentsToolreceives the same durable controller key the spawn tool registers runs under. (4) Image/video/music generators preserve existing ownership: the isolated run key for cron, otherwise the policy session key. (5)createSubagentsToolalso receivescallerPolicySessionKey, so both retained and new policy-owned tasks remain visible and cancellable for split-key callers. Plus tests.createSessionsSpawnToolcall already used the durable key.Why This Change Was Made
The durable
runSessionKeywas already available increateOpenClawTools(passed only ascompletionOwnerKey). Using it for parent lineage alignssessions_spawnwith the existingrunSessionKey ?? agentSessionKeypattern. The fix separates concerns: durable key for lineage, explicitsandboxedflag for admission, durable controller key for listing, and dual-key lookup that preserves policy-owned media tasks without migrating their ownership.runSessionKey) are unaffected — the??andSet-based fallbacks are no-ops there.User Impact
Telegram users can once again delegate sub-agent tasks via
sessions_spawnfrom a Telegram DM, without needing to switch to the web dashboard. Retained background media/spawn tasks created before the upgrade stay visible and cancellable.Evidence
Maintainer Repair Validation
The final repair restores the existing cron-specific media owner selection. Changing non-cron media ownership to the durable key hid retained tasks from media status and duplicate detection; dual-key subagent listing/cancel handles those tasks without changing their owner.
openclaw-tools.tts-config.test.ts,openclaw-tools.spawn-session-key.test.ts,subagents-tool.test.ts, andsubagent-spawn.test.ts.createOpenClawTools/ SQLite task-registry proof created a retained policy-owned image task, cleared registry and recent-start memory, closed the database, and reopened it with distinct policy and durable session keys.duplicateGuard: true. Exactly one task remained and no network calls occurred.Earlier Contributor Evidence
Mock-gateway harness (head
4f6e31d85bf): post-fix Telegram DMsessions_spawn visible=truecreates a visible child via Gateway with the durable parent key; pre-fix failedGatewayClientRequestError: unknown parent session.Factory-boundary regression (head
cb1250866f1):openclaw-tools.spawn-session-key.test.ts6/6;subagent-spawn.test.tssplit-key sandboxed requester →forbidden;subagents-tool.test.tssplit-key retained-task list+cancel → pass. All fail on pre-fix.Composed hidden-spawn proof through
spawnSubagentDirect(headcb1250866f1,node --import tsx) — the functionsessions_spawninvokes for hidden native spawns, covering propagation from tool entry through sandbox admission to child persistence/dispatch:Scenario 1 proves post-fix permitted dispatch. Scenario 2 proves rejection before dispatch (0 gateway calls). Scenario 3 confirms the pre-fix bypass.
Production-boundary store-reopen proof (head
cb1250866f1, real SQLite task store):Cron media unchanged (27/27). Telegram Test Server E2E needs credentials not held locally; the above proofs cover all changed paths with pre-fix fail / post-fix pass evidence.
AI Assistance
This PR is AI-assisted. Traced the
agentSessionKeyflow and applied the existingrunSessionKey ?? agentSessionKeypattern. Across review rounds: added mock-gateway harness E2E; separated durable lineage from sandbox classification and controller identity; preserved non-cron policy-owned media tasks and cron run isolation; addedcallerPolicySessionKeyfor retained-task reachability; added production SQLite store-reopen proof; added composed hidden-spawn proof viaspawnSubagentDirectshowing permitted dispatch, forbidden rejection before persistence/dispatch, and the pre-fix bypass reaching dispatch.