Skip to content

feat(agents): allow bounded recursive session spawning by default - #138059

Merged
fuller-stack-dev merged 20 commits into
mainfrom
fix/unlimited-recursive-session-spawn
Sep 5, 2026
Merged

fuller-stack-dev merged 20 commits into
mainfrom
fix/unlimited-recursive-session-spawn

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

Summary

  • let child sessions recursively delegate by default through a bounded depth of 5
  • keep agents.defaults.subagents.maxSpawnDepth configurable from 1 through 5, with sessions at the boundary retaining leaf behavior
  • recompute stored subagent capabilities from current policy so sessions created under the old depth-1 default are no longer permanently stuck as leaves
  • preserve global concurrency, per-session child limits, inherited tool restrictions, sandbox inheritance, and target-agent allowlists
  • document the bounded default and recursive announce/cancellation behavior

Why

The old default made every direct child a leaf, preventing visible and hidden child sessions from delegating independent work. A finite default of 5 enables practical orchestration without allowing a serial self-replenishing chain to grow without a depth bound.

Authority and compatibility

  • existing depth-1 child sessions gain recursive orchestration tools under the new default, up to depth 5
  • operators can retain leaf-only children with maxSpawnDepth: 1 or choose any lower boundary from 1 through 5
  • production-boundary tests prove that a finite depth cap, denied target-agent policy, revoked delegated authority, and closed admission prevent both child-session persistence and agent dispatch
  • an allowed upgraded descendant crosses the real Gateway instance facade and in-process dispatch boundary with signed execution lineage, then persists its depth-2 session and running registry ownership; only model execution is stubbed after turn construction
  • sandbox workspace confinement continues to reject recursively delegating workers

Verification

  • pnpm check:changed
  • focused Vitest runs: 423 tests passed across the changed session/spawn suites and cloud-worker executor
  • dedicated authority-chain suites: 19 tests passed, including the real agent-turn service with model-only substitution

Worked on by

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 4, 2026
@fuller-stack-dev
fuller-stack-dev requested a review from a team as a code owner September 4, 2026 08:18
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 5, 2026, 2:39 AM ET / 06:39 UTC.

ClawSweeper review

What this changes

Enables child sessions to delegate through depth five by default, recalculates existing sessions’ capabilities from current policy, and updates documentation and isolated test routing.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains useful, maintainer-sponsored work: current main and the latest release retain the depth-one default. No blocking introduced defect was found, and the supplied authority proof supports the changed boundary.

Priority: P2
Reviewed head: 6d862160dfaaa3e57f84bea888f19e1374ef8d1c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused runtime change with meaningful production-boundary authority coverage and an explicitly acknowledged compatibility tradeoff.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The reported production-boundary run exercises sessions_spawn through real Gateway admission and child persistence, observing an accepted depth-two child and owned run; complementary cases reject denied targets and stale authority before dispatch and verify rollback after delayed preparation. This satisfies the scoped authority proof for this MEMBER-authored PR; it is not a live-provider or UI demonstration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The reported production-boundary run exercises sessions_spawn through real Gateway admission and child persistence, observing an accepted depth-two child and owned run; complementary cases reject denied targets and stale authority before dispatch and verify rollback after delayed preparation. This satisfies the scoped authority proof for this MEMBER-authored PR; it is not a live-provider or UI demonstration.
Evidence reviewed 11 items Pinned introduction and review continuity: The introduced delta was inspected from the verified merge base to the pinned head. Since the previous reviewed head, only the prepared-runtime test harness and production-boundary test changed; the default and capability changes are unchanged. The supplied previous review has no outstanding findings or published rank-up moves. The stale test merge was not used to infer removal of main-branch behavior.
Current main still uses the old default: Current main sets the maximum spawn depth to one and still prefers persisted role/control-scope values when resolving stored subagent capabilities.
Latest release comparison: The supplied latest stable release, v2026.9.1, also sets the maximum spawn depth to one; the proposed default has not been established as shipped.
Findings None None.
Security None None.

How this fits together

OpenClaw’s session-spawning tools turn an agent’s delegation request into a child session and scheduled run. Shared admission and capability policies control nesting, permitted targets, inherited restrictions, and child ownership.

flowchart TD
  A[Agent delegation request] --> B[Current depth and tool policy]
  B --> C[Depth and target admission]
  C --> D[Live authority validation]
  D --> E[Persist child session]
  E --> F[Gateway run dispatch]
  F --> G[Child ownership and completion]
  C --> H[Visible rejection]
  D --> H
Loading

Before merge

  • Resolve merge risk (P1) - Upgrades with maxSpawnDepth omitted expand existing children’s delegation and control capabilities. Workflows requiring flat collectors or workspace confinement may need explicit maxSpawnDepth: 1 or a tool-policy denial; the maintainer-authored PR acknowledges this tradeoff.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
Agent review details

Security

None.

PR surface

Source +6, Tests +625, Docs -2, Other +9. Total +638 across 31 files.

View PR surface stats
Area Files Added Removed Net
Source 7 28 22 +6
Tests 19 665 40 +625
Docs 4 36 38 -2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 10 1 +9
Total 31 739 101 +638

Review metrics

Metric Value Why it matters
Default and configuration surface 1 default changed: depth 1 → 5; 0 new options The existing setting remains valid, while omission changes behavior for fresh and existing sessions.
Runtime versus validation growth Runtime +6 net; tests and CI support +634 net; docs −2 net Runtime growth centralizes a shared depth predicate; most added code exercises authority boundaries and isolates their test execution.

Merge-risk options

Maintainer options:

  1. Accept the documented default expansion (recommended)
    Adopt bounded recursion with the existing explicit depth-one setting preserving leaf-only workflows.
  2. Retain opt-in recursion
    Keep the depth-one default if existing omitted-cap configurations must retain their previous capability boundary.

Technical review

Best possible solution:

Retain the shared current-policy depth boundary, tested explicit-cap compatibility, and documented upgrade tradeoff without introducing another spawn path or configuration option.

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

Not applicable as a bug reproduction: depth-one leaf behavior is the established current-main and release default that this feature intentionally changes.

Is this the best way to solve the issue?

Yes, for the stated direction: the patch updates the existing policy owner and removes stale stored-role precedence. Keeping the existing opt-in alone would not provide the requested default experience.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against bfbf880320bf.

Labels

Label justifications:

  • P2: This is a bounded orchestration improvement without evidence of an urgent current user outage.
  • merge-risk: 🚨 compatibility: Existing sessions with an omitted depth setting gain capabilities, potentially changing flat-collector and workspace-confinement workflows.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The reported production-boundary run exercises sessions_spawn through real Gateway admission and child persistence, observing an accepted depth-two child and owned run; complementary cases reject denied targets and stale authority before dispatch and verify rollback after delayed preparation. This satisfies the scoped authority proof for this MEMBER-authored PR; it is not a live-provider or UI demonstration.
  • proof: sufficient: Contributor real behavior proof is sufficient. The reported production-boundary run exercises sessions_spawn through real Gateway admission and child persistence, observing an accepted depth-two child and owned run; complementary cases reject denied targets and stale authority before dispatch and verify rollback after delayed preparation. This satisfies the scoped authority proof for this MEMBER-authored PR; it is not a live-provider or UI demonstration.

Evidence

What I checked:

  • Pinned introduction and review continuity: The introduced delta was inspected from the verified merge base to the pinned head. Since the previous reviewed head, only the prepared-runtime test harness and production-boundary test changed; the default and capability changes are unchanged. The supplied previous review has no outstanding findings or published rank-up moves. The stale test merge was not used to infer removal of main-branch behavior. (6d862160dfaa)
  • Current main still uses the old default: Current main sets the maximum spawn depth to one and still prefers persisted role/control-scope values when resolving stored subagent capabilities. (src/config/agent-limits.ts:30, bfbf880320bf)
  • Latest release comparison: The supplied latest stable release, v2026.9.1, also sets the maximum spawn depth to one; the proposed default has not been established as shipped. (src/config/agent-limits.ts:30, ad6fe23aecb9)
  • Capability owner and upgrade behavior: Stored capabilities now derive from persisted depth and current configuration. Tests cover a formerly leaf depth-one session gaining orchestration tools when the cap is omitted and remaining a leaf with explicit maxSpawnDepth: 1. (src/agents/subagents/spawn/subagent-capabilities.ts:401, 6d862160dfaa)
  • Entry points and sibling boundaries: sessions_spawn reaches native spawn admission or visible-session creation; ACP child admission reuses resolveSpawnAdmission, and cloud workers invoke the visible-session tool path. These OpenClaw-owned policies retain depth, target, sandbox, and inherited-tool checks. No changed behavior or proof depends on a Codex runtime contract. (src/agents/spawn-plan.ts:286, 6d862160dfaa)
  • Allowed final-effect proof: The inspected production-boundary harness invokes the real spawn tool, Gateway instance facade, method registry, and authority validator. It observes model-entry dispatch, a depth-two persisted child, registry ownership, and eventual run cleanup. Model execution and supporting catalog/registry services are substituted; authorization and child persistence are exercised. (src/agents/subagents/spawn/subagent-spawn.production-boundary.test.ts:237, 6d862160dfaa)

Likely related people:

  • Dallin Romney: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-09-04T09:26:21.648Z sha bb5a225 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-04T23:02:19.685Z sha fddf69c :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-04T23:49:15.868Z sha ea58d9e :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-05T00:46:42.310Z sha 2973f0e :: blocked before merge. :: none
  • reviewed 2026-09-05T01:15:28.426Z sha 6eaa41d :: blocked before merge. :: none
  • reviewed 2026-09-05T01:31:20.684Z sha 536cdc6 :: blocked before merge. :: none
  • reviewed 2026-09-05T03:05:00.843Z sha eb58431 :: blocked before merge. :: none

@fuller-stack-dev fuller-stack-dev changed the title feat(agents): allow recursive session spawning by default feat(agents): allow bounded recursive session spawning by default Sep 4, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Addressed on fddf69c6322eb4fec43b92cb6e33473db9e2adfa:

  • replaced the unlimited omitted-cap behavior with a bounded default of 5; maxSpawnDepth: 1 still preserves leaf-only children
  • added production-boundary descendant tests proving that a finite cap, target-agent denial, delegated-authority revocation, and closed admission leave the session store unchanged and perform no agent dispatch or registry ownership transfer
  • retained the confinement rejection for recursively delegating workers
  • updated the PR body and docs with the compatibility and authority behavior

Exact-head local verification: pnpm check:changed passed; 422 focused tests passed, including the 18-test authority-chain suite.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed 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. labels Sep 4, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

The exact head now includes the requested allowed-path proof through the production Gateway instance facade and in-process dispatcher. It asserts signed sessions_spawn lineage, persisted depth-2 session state, and running registry ownership; the model turn is stubbed only after production authorization and turn construction. Exact-head verification: pnpm check:changed; 423 focused tests; 19 authority-chain tests.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper assist: This needs a full correctness re-review of 6eaa41d933c70d903e7d09bdfb3072a98220b059. The supplied diff supports the serialization change, but does not establish that the hosted Linux race is resolved.

Evidence:

Suggested next action: Put the completed exact-head Linux Testbox result, artifact, and race-fix evidence in the main PR body, then request @clawsweeper review.


Source: #138059 (comment)
Assist reasoning: high.

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Sep 5, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head 8dd93f1d9f4c1cbc19df365f0245a2ea10f21b41 keeps the accepted bounded-depth production behavior and stabilizes only the production-boundary test harness with canonical prepared-runtime setup/cleanup. Exact-head scoped evidence: pnpm check:changed green; 965 focused tests green, including 19/19 authority tests and the production dispatch boundary. Fresh sharded hosted CI is active for this SHA.

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Exact head 4d8f604b58accedc4006106d386f87b282d28d34 merges current main and preserves the bounded recursive-spawn design (default depth 5, explicit 1–5 override, existing concurrency/tool/sandbox/allowlist controls). The sole merge conflict retained upstream’s rewritten authority fixture. Exact-head local results: pnpm check:changed passed; 1,017 focused tests passed; 110 authority/depth/policy/capability tests passed; dedicated production-boundary model-dispatch proof passed. Fresh hosted CI is active on this SHA.

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@fuller-stack-dev
fuller-stack-dev merged commit 9986044 into main Sep 5, 2026
173 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the fix/unlimited-recursive-session-spawn branch September 5, 2026 13:22
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…enclaw#138059)

* Agents: allow recursive session spawning by default

* test: preserve sandbox delegation confinement

* test: accept serialized authority rejection

* test(agents): prove recursive production dispatch

* test(agents): exercise recursive spawn admission

* test(agents): isolate recursive spawn authority suites

* test(agents): avoid duplicate recursive spawn dispatch mocks

* test(agents): serialize isolated runtime mocks

* test(agents): isolate recursive spawn boundary proof

* test(agents): bound recursive spawn proof stages

* test(agents): diagnose spawn boundary admission stalls

* test(agents): use deterministic spawn fixture config

* test(agents): trace spawn proof setup stages

* test(agents): defer gateway graph in spawn proof

* test(agents): defer production proof runtime imports

* test: stabilize recursive spawn production proof

* test: stabilize recursive spawn production proof

* test(agents): track gateway execution in spawn proof
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 gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant