Skip to content

fix: subagent completions fail for session-scoped requesters - #185569

Merged
steipete merged 2 commits into
mainfrom
codex/announce-operator-scope
Oct 27, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/announce-operator-scope

Conversation

@steipete

@steipete steipete commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes subagent completion delivery failing with missing scope: operator.write when the requester has session-scoped write access.

The 2026-10-26 Team Gateway report counted 29 direct announce scope failures in 24 hours. The supplied excerpt contains 13 error lines across six ordinary run IDs, none prefixed subagent-restart-recovery:. A separate aggregate reported 46 Subagent completion requester is unavailable cleanup warnings; the supplied excerpt contains no occurrences of that warning, so this change does not attribute or alter that separate path.

User Impact

A completed child can return its result to an existing requester using the requester's retained operator.sessions.write authority. Private completions retain their original requester-incarnation checks, and public completion routing can still select the parent of a vanished nested requester. No configuration or persisted-data migration is required.

Why This Change Was Made

Registration retains the requester's operator identity and scopes. Direct completion delivery then dispatches the in-process Gateway method agent. Ordinary public completions omitted the host-owned session-run binding, so scope projection could not use the existing session-write alternative and Gateway rejected the call for lacking global operator.write.

Bind a public completion to the already-selected, already-existing requester session ID and lifecycle revision. Private and settle requests continue binding their captured incarnation after the existing checks. The binding owner supplies the expected-existing fields, removing the duplicate request-field spread.

The binding records target identity in a host-held WeakMap; it does not mint authority, widen scopes, or make wire fields trustworthy. Gateway continues checking the retained source's current authority, role, and ownership of the selected session. A foreign session remains forbidden even when the request is host-bound. Public delivery uses the selected fallback target rather than transferring the vanished nested requester's captured ID to another session. A target replaced during preparation is rejected by existing admission fencing.

Evidence

  • Current exact-head CI 40476144840, head d2dc4ab7eb6a2e9c45ad95d6fa3e3394b2f07368: SUCCESS, 35 jobs passed and 28 planner skips. Both the required openclaw/ci-gate job and aggregate publisher are SUCCESS. The inherited settle failure below is resolved by the included fix: preserve required child results during completion handoffs #185667.

  • Added two cases through direct completion delivery and real Gateway admission: retained session-write authority reaches an owned selected requester, while a foreign requester fails the own-session guard. The original captured requester ID deliberately differs from the selected target. Only the downstream agent preflight consumer is replaced; the projected scopes must remain exactly operator.sessions.write.

  • PASS: node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.agents-sessions.json --incremental.

  • PASS: node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/subagents/announce/subagent-announce-direct-delivery.ts src/agents/subagents/announce/subagent-announce-delivery.runtime.test.ts.

  • PASS: touched-file oxfmt --check, node scripts/check-docs-mdx.mjs docs/tools/subagents/announce.md, and git diff --check.

  • P1 autoreview: scoped-clean on the final committed branch, with frozen Gateway authority and session-sharing source context. TMPDIR used the private Darwin user temporary directory; TMP and TEMP were unset.

  • Previous-head CI 40463586944, head 3c9a6340a8c6a1f60f009e5f23f5c7ce7168087f: both new admission regressions PASS. The runtime file passed 4/4 tests in 24.11s (new owned case 9410ms, foreign case 659ms; wrapper 25.80s). Direct-delivery tests passed 42/42 and private-completion tests 7/7. The run completed with 33 successful jobs, 28 planner skips, and two failed jobs: checks-node-changed-2 and aggregate openclaw/ci-gate. That head's required openclaw/ci-gate was FAILURE.

  • First-head CI run 40461290445 completed with failure: the owned-requester regression passed, but the foreign fixture concealed its row before the ownership guard. The repair makes that synthetic row visible while retaining exactly operator.sessions.write; the ownership assertion remains unchanged.

  • Both runs failed only the unchanged requester-settle case one undelivered, NO_REPLY in changed-2 (expected false, received true). Source attribution: landed fix(agents): settle silent subagent completions quietly #185388 (1aba44bf4281) settles successful silent subagent_settle results, while the unchanged test still expects retry. This patch preserves the settle call's binding and parameters. The CI table had no matching main job; the identical failure is now independently reproduced on clean main as described below. Classification and its assertion remain with that owner.

  • Real main baseline proof: isolated Blacksmith Testbox tbx_01m5y5b18fw4jy4njnt5v2ykht, allocation run 40469404545, source main commit b112a9ec2304954636b74f4446c8ba520a885888 (after fix(agents): settle silent subagent completions quietly #185388, without this PR). The wrapper verified the source tree and three explicit classifier/delivery/test SHA-256 checks. Command: CI=1 OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_TESTBOX=1 OPENCLAW_TESTBOX_REMOTE_RUN=1 pnpm test src/agents/subagents/announce/subagent-announce.requester-settle-dispatch.test.ts -- -t "one undelivered, NO_REPLY". Result: the one selected test FAILED at line 316, expected true to be false; 24 tests skipped by the name filter, selected case 134ms, test process 66.36s, wrapper exit 1. This is real matching inherited-failure evidence, not a green CI claim. Testbox lifecycle status may show canceled after owned lease cleanup; the wrapper's verified source and payload result are the proof.

  • The local Mac is oversubscribed and earlier attempts did not produce a valid scope-error red result. A Testbox was requested, but its runner was queued; the allocation was stopped without running tests, per the proof policy. Scope-regression red-on-base proof and full requester execution/revocation/reassignment proof remain unavailable. No timeout, budget, baseline, or assertion was weakened. The admission regression stops at downstream agent preflight and does not demonstrate provider or transcript effects.

  • Recovery and completion-classification code are unchanged. Related classification work: fix(agents): settle silent subagent completions quietly #185388.

This authorization-boundary correction grants no new scopes. The inherited settle failure was repaired by #185667, merged as b3b0f1bb8105cf784f87f47a8f31a9564888f2e3. This branch now includes that fix at head d2dc4ab7eb6a2e9c45ad95d6fa3e3394b2f07368; git range-diff confirms both scope commits remain patch-identical. Targeted typecheck, lint, format, and diff checks passed after integration. Fresh exact-head CI is green. The runtime proof limits above remain explicit.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Oct 27, 2026
@steipete
steipete marked this pull request as ready for review October 27, 2026 06:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T08:50:39.820442Z d2dc4ab New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR binds public subagent completion requests to the selected existing requester session so session-scoped operators can receive results.

Example: An operator with only operator.sessions.write receives a child completion in the owned selected-parent session.

  • Before: The public completion lacks the host-held session binding and fails with missing scope: operator.write.
  • After: Gateway admission can use the existing own-session scope alternative while retaining ownership and lifecycle checks.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch has no identified discrete defect and fixes the prior fixture concern, but admission-only tests do not satisfy the authority-chain proof requirement.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A child finishes, but its session-scoped requester does not receive the completion because Gateway requires global write scope.
Reason: The maintainer-authored direction restores an existing delegated-work contract with a focused change to the established binding owner.

Merge readiness

⛔ Blocked before merge - 4 items remain

This PR addresses a concrete completion-delivery failure that remains on main. The prior fixture finding is fixed, and no new discrete code defect was found; final-effect authorization evidence and the failing required CI gate remain unresolved.

Priority: P1
Reviewed head: 3c9a6340a8c6a1f60f009e5f23f5c7ce7168087f

Before merge

  • Add real behavior proof - Authority-chain proof required: exercise public completion through requester execution, showing an owned session-scoped requester succeeds and foreign, revoked, or reassigned authority is rejected before transcript/provider effects, including queued execution; provide redacted logs, terminal output, or an authorized production-path artifact with IPs, API keys, phone numbers, and non-public endpoints removed. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security concern: Public completion admission expands the exercised authority path - The tests establish scope projection and foreign-owner admission rejection, then replace agent preflight; they cannot establish whether authority revocation or ownership reassignment prevents later transcript and provider effects.
  • Resolve merge risk - Before merge, the PR owner must establish that public target rebinding preserves live requester authorization through queued execution.
  • Resolve merge risk - Before merge, a maintainer must resolve the failed required CI gate or establish an authorized inherited-failure disposition.

Findings

  • [medium] Public completion admission expands the exercised authority path — src/agents/subagents/announce/subagent-announce-direct-delivery.ts:467

Tests

  • Missing end-to-end proof: The supplied evidence lacks a valid red-on-base result and requester execution showing owned success plus foreign, revoked, and reassigned authority rejection before transcript/provider effects.
Agent review details

How this fits together

The subagent announce owner turns a completed child's result into a requester follow-up, then sends it through in-process Gateway authorization and agent execution.

flowchart TD
  A[Completed child] --> B[Select requester session]
  B --> C[Bind existing session identity]
  C --> D[Retained requester authority]
  D --> E[Gateway scope and ownership checks]
  E --> F[Requester execution]
  F --> G[Transcript and reply]
Loading

Technical review

Best possible solution:

Reuse the existing session-run binding for the selected public requester while preserving captured private identities and current authorization checks.

Do we have a high-confidence way to reproduce the issue?

Source shows that public completions omit the binding required for session-scoped agent admission; the report names the matching scope error, but a failing base execution was not supplied.

Is this the best way to solve the issue?

The patch uses the existing authorization owner, binds the selected fallback target correctly, and removes redundant field construction without adding another state or policy owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b5135f069610.

Merge-risk options

Maintainer options:

  1. Complete authorization evidence and resolve CI (recommended)
    The PR owner demonstrates allowed execution and forbidden, revoked, and reassigned requester rejection before effects; a maintainer resolves the failed CI gate.
  2. Keep the authorization change paused
    Retain this PR without merging while the required authority evidence and CI disposition remain unavailable.

Provenance checked

  • Host-held session-run binding keeps the original intent (8b7a118: Permit owned hidden subagent launch and private completion with session-scoped authority while preserving live authorization and session identity.)
  • Captured private and settle requester incarnation keeps the original intent (9564dd6: Resume yielded private work under the original requester identity and conversation reply policy without delivering to replaced sessions.)

Testing

Proof path: in-process harness.

Security

Needs attention: No concrete authorization bypass was found, but final-effect coverage for the newly admitted public completion path remains incomplete.

Evidence

Security concerns:

  • [medium] Public completion admission expands the exercised authority path — src/agents/subagents/announce/subagent-announce-direct-delivery.ts:467
    The tests establish scope projection and foreign-owner admission rejection, then replace agent preflight; they cannot establish whether authority revocation or ownership reassignment prevents later transcript and provider effects.
    Confidence: 0.98

What I checked:

PR surface

Source +3, Tests +109, Docs +4. Total +116 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 13 10 +3
Tests 1 112 3 +109
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 129 13 +116

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The reported scope failures prevent completed delegated work from returning to real session-scoped requesters.
  • merge-risk: 🚨 security-boundary: The change enables public completion admission through a narrower scope alternative, requiring evidence that live requester authority still governs final effects.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof that an owned completion succeeds while foreign, revoked, or reassigned requester authority is rejected before transcript/provider I/O.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-27T06:45:53.160Z sha 1777365 :: needs real behavior proof before merge. :: [P2] Assert the concealed-session rejection in the foreign-owner case

Reviewed October 27, 2026, 3:11 AM ET / 07:11 UTC (Revision 2).

@steipete

Copy link
Copy Markdown
Contributor Author

Addressed the fixture finding at 3c9a6340a8c6a1f60f009e5f23f5c7ce7168087f: the synthetic foreign row is now visible, while the principal still has exactly operator.sessions.write. The assertion still requires the own-session rejection and verifies that agent preflight is never reached.

Exact-head CI run 40463586944 passed both new cases (9410ms owned, 659ms foreign), all four runtime-file tests, 42 direct-delivery tests, and seven private-completion tests. Static checks and fresh P1 autoreview pass. The PR body now records these results.

The run remains red only for the unchanged settle case one undelivered, NO_REPLY (expected false, received true), plus its aggregate gate. Source attribution is documented against #185388's silent-settlement classifier change; there is no matching main job/base execution, and this lane preserves settle parameters and captured binding. Classification and its test remain with that owner.

Full requester execution and revocation/reassignment before transcript/provider effects remain disclosed proof gaps. An isolated Testbox allocation queued and was canceled; local runtime tests were excluded under the maintainer's host constraint. No concrete bypass was identified, and this patch adds no new authorization gate. This authorization change remains open for coordinator/maintainer review, with no merge authorized.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
Bind public completion requests to the selected existing requester session while preserving private incarnation checks and nested fallback. Child results no longer require global operator.write when the retained requester has operator.sessions.write.
@steipete
steipete force-pushed the codex/announce-operator-scope branch from 3c9a634 to d2dc4ab Compare October 27, 2026 08:48
@steipete
steipete merged commit 5c0201b into main Oct 27, 2026
129 checks passed
@steipete
steipete deleted the codex/announce-operator-scope branch October 27, 2026 09:06
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 27, 2026
…lds into one helper call

Upstream (openclaw#185569, openclaw#185667) grew subagent-announce-direct-delivery.ts to
exactly the 700-line cap, so the fork's `continuationTrigger` and
`traceparent` lines on the direct agent request put it at 702.

Fold, not extract (bootstrap#1727 comment 6449160126). The new
continuation-owned sibling subagent-announce-direct-delivery.continuation.ts
exports withDirectAnnounceContinuationFields. It returns upstream's
source-reply spread, then `continuationTrigger` and `traceparent`, each only
when present. The request keeps one call in place of upstream's 3-line
spread, so a later upstream edit to that spread conflicts on that one line.
Field order is unchanged.

Deviation from the workorder, measured (TROUBLE posted): passing upstream's
92-character expression itself as the argument cannot fit. At indent 8 with
its trailing comma it needs 101 columns, so the formatter breaks it over 3+
lines, and the import costs a fourth. Counted lines with oxfmt and max-lines:
verbatim argument 704; wrapping upstream's object literal with every inner
byte unchanged 701; taking `completionSourceReplyDeliveryMode` 699. The
helper therefore takes the operand, and upstream's expression moves verbatim
into its body.

Behaviour: unchanged for every consumer. The request used to carry
`continuationTrigger: undefined` when there was no trigger. The key is now
absent, like the sibling producers (announce delivery, restart sentinel,
continuation wake). The Gateway `agent` validator treats an optional
undefined as absent, and readers only read the value.

Counted lines (U8 -> 3c834c7 -> this): 700 -> 702 -> 699. No cap moved.

RED (3c834c7, bare and --base 7fdf69f): check:line-cap-ratchet
  subagent-announce-direct-delivery.ts: 700 -> 702 counted lines (cap 700).
GREEN: check:line-cap-ratchet bare and --base 7fdf69f OK (806 changed
  files); tsgo:core exit 0.
  subagent-announce-direct-delivery.continuation.test.ts 2/2: upstream's
  fields unchanged for every mode, continuation fields only when present,
  order kept.
  subagent-announce-direct-delivery, -direct-completion-media and
  -delivery.completion-contract (continuation trigger and trace on the direct
  path) 61/61; subagent-announce-delivery{,.origin,.discord-thread,
  .yielded-settle,.runtime}, continuation-drain.chain-cost and
  media-generate-background trace-context 157/157.

Refs karmaterminal/openclaw-bootstrap#1727

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 28, 2026
…w#185569)

* fix(agents): deliver subagent completions with session-scoped access

Bind public completion requests to the selected existing requester session while preserving private incarnation checks and nested fallback. Child results no longer require global operator.write when the retained requester has operator.sessions.write.

* test(agents): exercise completion session ownership guard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant