Skip to content

fix(agents): declare visible-session constraints upfront in sessions_spawn - #111502

Merged
steipete merged 1 commit into
mainfrom
claude/sessions-spawn-ergonomics
Jul 19, 2026
Merged

steipete merged 1 commit into
mainfrom
claude/sessions-spawn-ergonomics

Conversation

@steipete

@steipete steipete commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

An agent on a shared gateway asked to create sidebar sessions burned 8 failed sessions_spawn calls discovering constraints one rejection at a time: visible:true unsupported on its runtime path, mode:"run" invalid for persistent visible sessions, lightContext/attachments unsupported — and only then the real blocker, "Visible sessions unavailable with inherited tool restrictions." Every constraint was enforced correctly but communicated one failure at a time, and none of it was in the tool schema the model reads before calling.

Why This Change Was Made

Communication-only fix — nothing about what is allowed changes:

  • The sessions_spawn tool description and per-parameter docs now declare the visible-session contract upfront: persistent (no mode:"run"), unsupported params enumerated, the inherited allow/denylist rule (spawn-time, no config override), and tools.sessions.visibility scoping (default tree).
  • Incompatible-parameter rejections aggregate into one ToolInputError naming every violation (both visible-only params used without visible:true and vice versa); genuinely sequential gates (depth, agent-id) stay sequential.
  • The inherited-restriction forbidden now carries an actionable hint so agents stop retrying parameter shapes against a permission wall.
  • docs/tools/subagents.md aligned; prompt snapshot fixtures regenerated (pnpm prompt:snapshots:check green).

User Impact

Agents (and the humans watching them) get one clear error instead of a trial-and-error spiral; sidebar-session requests either work or fail with the real reason on the first call.

Evidence

  • All 8 sessions-spawn suites: 151 tests green, including a new multi-violation aggregation test and schema assertions.
  • Prompt snapshot suite 13/13; pnpm prompt:snapshots:check 7 files current (regenerated; Linux CI is canonical truth).
  • Docs MDX 745 files + markdown lint 729 files clean.
  • Structured autoreview (codex/gpt-5.6-sol, xhigh): clean — "improves guidance and aggregates diagnostics without changing admission or spawning behavior" (0.95).

Redacted current-head runtime tool-call proof

Directly invoking the production sessions_spawn tool implementation at c9102640d2580b7f6a438ac9ac4cc2d5bc51cb92 produced:

multi-violation tool result:
ToolInputError: Parameters unavailable with visible=true: runtime: supports runtime="subagent" only; thinking: thinking overrides are not wired to the sessions.create path; thread: visible sessions route to the dashboard, not a channel thread; mode: visible sessions are persistent dashboard sessions; lightContext: bootstrap staging is not wired to the sessions.create path; attachments: attachment staging is not wired to the sessions.create path; attachAs: attachment staging is not wired to the sessions.create path

inherited-restriction tool result:
{"status":"forbidden","error":"Visible sessions unavailable with inherited tool restrictions. This session was spawned with a tool allow/denylist; visible sessions require an unrestricted session."}

Inputs were limited to a redacted task plus the listed invalid parameters; the inherited-restriction invocation used a redacted denylist entry. No session was created in either case.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Jul 19, 2026
@steipete steipete self-assigned this Jul 19, 2026
@steipete
steipete marked this pull request as ready for review July 19, 2026 18:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9102640d2

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +165 to +166
error:
"Visible sessions unavailable with inherited tool restrictions. This session was spawned with a tool allow/denylist; visible sessions require an unrestricted session.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Correct the restriction source in the error

When a top-level session has an effective policy such as tools.deny: ["exec"], this branch also runs even though the session was never spawned with a tool list: src/agents/agent-tools.ts:826-833 seeds these arrays from effective profile/owner policy, and src/agents/agent-tools.ts:1150-1153 similarly captures configured allow policies. The new error and matching docs therefore misdiagnose a configurable policy restriction as immutable spawn-time state, which can send users looking for a nonexistent parent spawn instead of the applicable tool configuration; describe this generically as an effective allow/deny restriction or preserve its provenance.

Useful? React with 👍 / 👎.

? '`mode="run"` one-shot; `mode="session"` persistent/thread-bound only on supporting requester channel.'
: '`mode="run"` one-shot background.',
'`visible=true`: persistent dashboard session; subagent only; omit `mode` (no `mode="run"`), `thread`, `thinking`, `lightContext`, `attachments`, `attachAs`; inherited tool allow/denylist blocks it at spawn with no config override.',
"Session listing/addressing obeys `tools.sessions.visibility` (`tree` default: current + own spawn subtree).",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid advertising recursive tree visibility

When a child spawns a grandchild, the root cannot list or address that grandchild under the default visibility: src/plugin-sdk/session-visibility.ts:301-306 recognizes only rows whose ownership fields equal the current requester, and direct-key lookup filters by that exact requester at src/plugin-sdk/session-visibility.ts:60-67. The grandchild points to the child, so it is rejected by the tree guard rather than belonging to the root's full subtree. This new model-facing claim can therefore cause failed nested-session targeting; say “directly spawned sessions” unless visibility is made recursively transitive.

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 19, 2026, 2:31 PM ET / 18:31 UTC.

Summary
The PR expands sessions_spawn schema and documentation guidance for visible sessions, aggregates incompatible-parameter errors, and updates prompt snapshots and tests.

PR surface: Source +32, Tests +53, Docs +1. Total +86 across 11 files.

Reproducibility: yes. from source: invoke sessions_spawn with visible:true plus several incompatible parameters, or with inherited tool restrictions, to exercise the changed diagnostics. A live current-head run was not attached to the PR body.

Review metrics: 1 noteworthy metric.

  • Prompt budget: +981 to +1,016 chars; +245 to +254 rough tokens in sampled snapshots. The added model-facing contract is intentional but permanently increases the dynamic tool payload on the covered runtime paths.

Stored data model
Persistent data-model change detected: serialized state: src/agents/tools/sessions-spawn-tool.test.ts, serialized state: src/agents/tools/sessions-spawn-tool.ts, serialized state: src/agents/tools/sessions-spawn-visible.ts, unknown-data-model-change: src/agents/tools/sessions-spawn-tool.test.ts, unknown-data-model-change: src/agents/tools/sessions-spawn-tool.ts, unknown-data-model-change: src/agents/tools/sessions-spawn-visible.ts, and 3 more. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add a redacted terminal or live-output transcript showing one visible-session call with multiple invalid parameters returns the combined ToolInputError and another inherited-restriction call returns the actionable hint.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body reports focused tests, snapshots, docs checks, and autoreview, but does not include a redacted after-fix runtime tool-call transcript or other live output showing the combined visible-session diagnostic. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The larger model-facing description consumes roughly 245–254 additional rough tokens in sampled prompt snapshots; maintainers should confirm this diagnostic value remains worth the persistent context cost.
  • [P1] The PR body provides test and snapshot claims but no redacted after-fix runtime transcript demonstrating that a multi-violation visible spawn returns the combined diagnostic and that inherited restrictions return the new actionable hint.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the existing visible-session admission rules, land the clearer schema and aggregated diagnostics only after a redacted live tool-call transcript confirms the stated first-call behavior.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] This is a draft with the protected maintainer label; it needs normal maintainer review and contributor-supplied real behavior proof rather than automated repair.

Security
Cleared: The diff changes agent-tool descriptions, validation diagnostics, tests, docs, and snapshots without adding dependencies, permissions, execution paths, secrets handling, or supply-chain inputs.

Review details

Best possible solution:

Keep the existing visible-session admission rules, land the clearer schema and aggregated diagnostics only after a redacted live tool-call transcript confirms the stated first-call behavior.

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

Yes, from source: invoke sessions_spawn with visible:true plus several incompatible parameters, or with inherited tool restrictions, to exercise the changed diagnostics. A live current-head run was not attached to the PR body.

Is this the best way to solve the issue?

Yes, provisionally: declaring the existing constraints in the model-visible schema and aggregating same-stage input violations is narrower and more maintainable than changing admission policy or adding configuration.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P3: This is a bounded diagnostics and ergonomics improvement to an existing agent tool, with no evidence of a current user-facing regression.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.

Label justifications:

  • P3: This is a bounded diagnostics and ergonomics improvement to an existing agent tool, with no evidence of a current user-facing regression.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
Evidence reviewed

PR surface:

Source +32, Tests +53, Docs +1. Total +86 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 3 56 24 +32
Tests 7 88 35 +53
Docs 1 2 1 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 146 60 +86

What I checked:

  • Current visible-session boundary: Current main already rejects visible-session worktree options without visible, rejects non-subagent runtime and the first unsupported visible parameter, and denies visible sessions when inherited tool allow/deny lists exist; the branch targets diagnostics around those established gates. (src/agents/tools/sessions-spawn-visible.ts:3, 40d31f34813c)
  • Model-facing contract coverage: The branch adds the visible-session constraints to the shared model-facing description and individual schema parameter descriptions, while its focused test asserts the generated schema and tool description include those constraints. (src/agents/tools/sessions-spawn-tool.test.ts:382, c9102640d258)
  • Prompt-budget impact is bounded and explicit: The regenerated snapshots show the expanded model-facing tool contract adds roughly 981–1,016 characters (about 245–254 rough tokens) in the sampled Codex tool payloads; this is a deliberate tradeoff for avoiding repeated invalid calls. (test/fixtures/agents/prompt-snapshots/codex-runtime-happy-path/telegram-direct-codex-message-tool.md:216, c9102640d258)
  • Repository policy applied: The repository policy requires review of the changed agent tool, callers/callees, tests, docs, and prompt-snapshot determinism; this review found the branch stays within the existing agent-tool ownership boundary and does not add config, storage, or plugin API surface. (AGENTS.md:1, 40d31f34813c)

Likely related people:

  • steipete: The proposed change is authored on the current agent-session tooling path, and recent repository activity shows continued work across core agent/runtime behavior. (role: recent agent-runtime contributor; confidence: medium; commits: c9102640d258; files: src/agents/tools/sessions-spawn-tool.ts, src/agents/tools/sessions-spawn-visible.ts, src/agents/tool-description-presets.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@steipete
steipete merged commit 163a6c6 into main Jul 19, 2026
211 of 216 checks passed
@steipete
steipete deleted the claude/sessions-spawn-ergonomics branch July 19, 2026 18:42
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant