Repository navigation
fix: nested session tools retain caller scope on multi-agent hosts - #126221
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
216bde2 to
649077e
Compare
649077e to
0496918
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 3:58 AM ET / 07:58 UTC. ClawSweeper reviewWhat this changesThe PR makes Code Mode session list, search, and history tools derive their caller identity from the durable run session rather than an ownerless sandbox policy key. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open. Current main still resolves nested session-tool ownership from the sandbox policy key, while this PR consistently uses the durable run key and retains the existing visibility checks. No blocking patch defect was found; the protected maintainer label and active exact-head checks leave it for maintainer review. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherEmbedded OpenClaw agent runs carry both a sandbox policy session and a durable run session. The core tool factory turns those into session lookup tools, which then apply visibility and agent-to-agent policy before sending Gateway requests. flowchart LR
A[Embedded agent attempt] --> B[Sandbox policy key]
A --> C[Durable run session key]
B --> D[Core tool factory]
C --> D
D --> E[Session caller context]
E --> F[List search history tools]
F --> G[Visibility and agent policy]
G --> H[Gateway session requests]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +167. Total +167 across 2 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the single durable-run caller context for session lookups, with existing visibility and agent-to-agent checks continuing to authorize every foreign or global target. Do we have a high-confidence way to reproduce the issue? Yes, in source: construct a multi-agent roster with agentSessionKey "global" and a scoped runSessionKey; current main resolves ownership from the global key and fails before the lookup tools are built. This read-only review did not execute that regression. Is this the best way to solve the issue? Yes. Resolving both the factory agent and lookup requester from the already-threaded durable run key fixes the owner boundary at its producer, while the existing session visibility and agent-to-agent checks remain the authorization authority. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c2b61a40beb5. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer decision: approved. Extend the established durable |
|
Landing proof note: the required Telegram changed-path lane was attempted repeatedly on exact head |
…26221) Use the durable run-session identity for nested session lookups on multi-agent hosts while retaining existing visibility and agent-to-agent authorization. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes an issue where Code Mode calls to
sessions_listandsessions_searchcould fail on multi-agent hosts when the model omitted an explicit scope:Related session lookups could also use the sandbox policy key instead of the durable originating session.
Why This Change Was Made
The tool factory resolved the caller agent from the sandbox/policy key before it built the session tools. A policy key such as
globalis ownerless on an explicit multi-agent roster, even though the same attempt already carries an agent-scopedrunSessionKey. The factory now uses that durable run key for both owner resolution and list/search/history requester context. Gateway discovery remains unscoped where visibility policy requires it, so existing visibility and agent-to-agent checks still govern authorized foreign/global results.Maintainer decision: @obviyus explicitly requested and approved preserving the originating caller identity while retaining authorization for explicit cross-agent/global queries. Configured
visibility: "all"discovery remains unchanged.No overlapping open PR fixes this invariant. #126177 touches the embedded search stub for result modes only; #111101 and #114194 address different session visibility/history behavior.
Production LOC: +2/-2 (net 0) | Tests: +167
User Impact
Nested session discovery and history now authorize from the originating run on multi-agent hosts instead of failing during owner resolution. Authorized all-agent discovery and explicit cross-agent/global queries continue to work.
Evidence
AgentSelectionRequiredError: Multiple agents are configured, but session agent resolution has no explicit owner.visibility: "all"plus agent-to-agent coverage proves implicit foreign discovery remains authorized.git diff --checkpnpm tsgo:corepnpm check:test-typesRedacted two-agent owner-boundary red/green trace
Before the production substitution, the first regression test failed through the real session lookup owner boundary:
Exact-head rerun:
Exact-head CI run
32229894840passed all 172 jobs at049691803e488d2f579cf61ac952ca7abc194ac5.Provenance: the split between sandbox policy identity and
runSessionKeywas introduced in #76995 by @amknight and intentionally applied tosession_status; the session lookup trio retained the policy key. The PR was squash-merged byclawsweeper[bot]after/clawsweeper automergefrom @amknight on 2026-05-04. This patch completes that owner-boundary split for list, search, and history.