Repository navigation
fix(sessions): expose batch lifecycle actions to gateway-bound agents - #120850
clawsweeper wants to merge 1 commit into
Conversation
|
Codex review: needs changes before merge. Reviewed August 9, 2026, 7:52 AM ET / 11:52 UTC. ClawSweeper reviewWhat this changesThe PR exposes bounded archive and delete batches through the model-facing sessions tool for trusted Gateway-bound agents, sharing lifecycle execution with the CLI. Merge readinessKeep open. The prior UTF-8 result-budget blocker is addressed, but batch delete now obtains a synthetic Priority: P1 Review scores
Verification
How this fits togetherA Gateway-bound agent invokes the sessions tool, which resolves visible session targets and asks the Gateway to archive or delete authoritative session records. The tool returns ordered, bounded outcomes to the model while Gateway scope and session-sharing checks enforce the mutation boundary. flowchart LR
A[Gateway-bound agent] --> B[Sessions tool]
B --> C[Visibility and identity checks]
C --> D[Batch lifecycle adapter]
D --> E[Gateway archive or delete]
E --> F[Ordered bounded outcomes]
F --> G[Model-visible result]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The new destructive agent path obtains an unnecessary synthetic admin scope because its identity-fence fields are absent from the write-scope envelope. PR surfaceSource +431, Tests +634, Docs +1. Total +1066 across 21 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the shared lifecycle adapter, allow only expected session identity fields on the archived-only write-scoped delete envelope, and verify the Codex dynamic-tool snapshot contract from the required sibling source before landing. Do we have a high-confidence way to reproduce the issue? Yes, from source: invoke a batch delete with a resolved target identity; the new adapter sends expectedSessionId, while the current scope classifier upgrades that archived-only request to operator.admin. This review did not execute the path because the checkout is read-only. Is this the best way to solve the issue? No. The shared batch lifecycle owner is the right design, but its delete call must preserve the archive-only write scope rather than obtaining admin scope for its safety identity fields. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 11e897a63035. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
Acceptance criteria:
What 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
HistoryReview history (2 earlier review cycles) |
2c0607c to
0177258
Compare
0177258 to
bd8a7f1
Compare
|
Related update: #160296 is merged on main with a restricted agent-facing archive/restore/Stop surface for eligible |
|
Thanks for the PR. We're closing older pull requests that have gone stale against current This branch has had no commits since August 9, and #160296 has since landed a restricted agent-facing archive/restore/stop surface for sessions. Batch delete through the agent tool would need a fresh, narrowly scoped proposal. If this change is still needed, please open a fresh PR against current |
What Problem This Solves
Fixes an issue where Gateway-bound embedded agents could list and spawn sessions but could not use the model-facing
sessionslifecycle tool, forcing shell/CLI fallback for archive and delete work. It also closes lifecycle drift where the CLI supported ordered batch dry-runs and generation fencing while the agent tool handled only one target at a time.Why This Change Was Made
The
sessionstool now follows the same trusted Gateway-bound registration gate assessions_spawn. Archive batching reuses the Gateway-ownedsessions.patchManylifecycle path; a shared adapter retains ordered CLI results and generation-safe delete orchestration. CLI confirmation and agent owner/visibility authorization remain caller-owned boundaries.Lifecycle inputs are action-validated, every mutation requires authoritative generation identity, current-session targets fail independently, and model-visible batches are limited to eight indexed outcomes under the existing 3,840-byte result budget. Archived targets are revalidated through
sessions.patchMany; errors are bounded by UTF-8 bytes with a fixed-size fallback.sessionsis hard-denied for leaf, orchestrator, and ACP child inventories. Existing deferred self-archive remains the canonical path for archiving the running session.The policy catalog and Codex prompt snapshots now advertise the same current session surface. Standalone local embedded mode remains excluded.
Production growth provides the new bounded batch capability and shared lifecycle owner; the obsolete CLI-only mutation loop is removed.
User Impact
Main agents can preview and archive or delete ordered session batches through
sessionswithout invoking the CLI. Results preserve input order, continue after individual failures, remain complete within the model-result budget, and fence mutations to the selected session generation. Delegated child agents cannot access destructive session lifecycle actions.Evidence
origin/mainaftersessions.patchManylanded.pnpm checkpnpm check:test-typespnpm check:docspnpm prompt:snapshots:checkpnpm deadcode:dependenciespnpm deadcode:exportssessions.patchManyauthorization/fencing, policy catalog parity, and Codex prompt snapshots: 237 tests across 7 shards.sessions.patchMany.