Skip to content

feat: let invited people read, suggest or send in your session within role limits - #204899

Merged
jalehman merged 9 commits into
mainfrom
participate-split/p4-invited-admission
Nov 25, 2026
Merged

jalehman merged 9 commits into
mainfrom
participate-split/p4-invited-admission

Conversation

@jalehman

@jalehman jalehman commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Related: #202552

Part 4 of 6 of the split of #202552 (Participate). The stack:

  1. chore: store session member access levels and add the Participate protocol #204783: storage and protocol (merged)
  2. chore: carry and enforce participant limits on admitted runs #204847: participant limits on admitted runs (merged)
  3. feat: send participant exec approvals to the session creator #204858: participant exec approvals go to the session creator (merged)
  4. This PR
  5. feat: let participants publish through the session's shared GitHub account #204914: publishing through the session's shared GitHub account (stacked on this PR)
  6. The Control UI

This PR depends on #204787 (keep a chat's client capabilities when queued messages resume after a restart), which is already merged into main. The server.participation-restart-control suite fails without it. That fix is not part of this diff.

What Problem This Solves

Today you can only share a whole session: depending on their role, other people can't see it, can read it, or can change it. You can't invite one specific person into your session to read along, suggest, or talk to the agent while staying inside limits you set. Parts 1 to 3 added the storage, the limits on participant runs and the approval routing. Nothing could admit a participant yet, so all of that stays dormant until this PR.

User Impact

Operators can now let a role accept invitations. A role opts in by setting gateway.roles.definitions.<role>.sessions.maxInvitedAccess together with sessions.others: "invited". A session creator can then invite people with that role at one of three levels, up to the role's limit:

  • read: the invitee can see the session.
  • suggest: the invitee can also add suggestions and react.
  • send: the invitee can talk to the agent in your session.
    • Their runs use your session's sandbox and workspace.
    • They are limited to the role's invitedPermission and its participant tools (invitedTools, or the defaults plus invitedAlsoAllow).
    • Their exec approvals go to you (part 3).

Part 1 stored access levels but refused invitations with a level (session.members.add or a mention with access), because nothing enforced levels yet. This PR enforces them and removes those refusals. A level above the invitee role's limit is still refused, and so is any level for a role without maxInvitedAccess.

Other changes for invitations:

  • Creators and admins can change a member's level with session.members.setAccess, or remove the member. Lowering a member's level or removing them cancels their queued inputs.
  • A participant can stop only their own run, and can see their own cancelled or revoked inputs (chat.pendingInputs.own).
  • The OpenClaw ID People page describes roles that allow invitations.

Roles without maxInvitedAccess keep today's sharing behavior, apart from these small visible differences:

  • Read-only callers get a different error. This affects a client with read scopes but no operator.write that calls chat.send, chat.abort, session.typing, session.suggestions.add, or a sessions.patch that only narrows permissions.
    • Before: a missing-scope error naming operator.write.
    • Now: the request passes the scope check, and the session check refuses it with Session "<key>" was not found.
    • The client still can't do anything it couldn't do before.
  • Creating a session from inside someone else's session gives a different error. This applies when a hosted session tool tries to create a session from a foreign session.
    • Before: an "own session" error.
    • Now: Session "<key>" was not found., because the sharing check runs first.
  • Stopping a reserved run from another device. The same signed-in person can now stop their own reserved (not yet started) run from another device. They could already do this for an active run.
  • People page label for "invited" roles. For roles with sessions.others: "invited", the OpenClaw ID People page now reads "Only sessions they’re invited to". Before, the description was missing.

Still inactive until later parts:

  • Participants can't publish to GitHub yet. github_publish only becomes a default participant tool in part 5, so until then the publication path refuses participants.
  • No Control UI for invitations yet. The invite-level picker, levels in the People list and participant controls arrive in part 6. Until then, these flows work only through config and the Gateway protocol.

Why This Change Was Made

The stack follows one rule: restrict before admitting. Parts 2 and 3 act only on runs that carry a participation limit. This PR is the switch that creates that limit, and only for roles that opt in.

Access levels and send admission ship together. The level checks for chat.send, typing and suggestions live in the same admission code as sending. If they were split, a read or suggest member could briefly start turns.

This PR also carries the Gateway end-to-end suites for the whole participant path: spawn, children, descendant restart, restart control, recovery, approval delivery and configured tools. These suites need an invitation that can admit a run, so they can't run before this PR. It also includes four test cases that part 2 left for this PR for the same reason: participant sources, recovery narrowing, the literal-command restore, and the foreign scope-child refusal. Session access resolution reads the caller's connection scopes, so the Talk handler test fixtures now give their fake clients scopes, as real clients always have. Participant test fixtures build operator authority with a turn grant, matching the grant main now requires. The test-line allocation record covers the 5,465 lines above the normal allowance.

One change from the original branch closes a small information leak. When a role sets sandbox: "required", a read-only caller without an invitation limit could tell an existing unsandboxed session from a missing one by the error it got back. Now a refused participation always reports a missing session. session-participation.test.ts covers this, and the test fails without the fix.

Evidence

Upgrade from the released 2026.11.10 (latest stable)

I upgraded a real state directory from [email protected] (npm, commit 6ea542fd97e2) to this branch through the shipped CLI and Gateway entry points. Only the model provider was mocked, with the repository's loopback scripts/e2e/mock-openai-server.mjs. Setup used ordinary onboarding, config set, users.setRole and authenticated Gateway RPCs as an owner and a separate non-admin member. No SQL fixture writes were involved. The candidate was built at 4c7b1e47be90. The current head 69c4268235c1 adds only the test below and its test-line record, with no product code. Tests ran with umask 022 and a private TMPDIR.

On 2026.11.10:

  • The member's role used a released setting, sessions.others: "suggest" (2026.11.10 offers only none, view, suggest and write).
  • The owner added the member to the owner's session without a level.
  • The member completed a turn there and another in a session of their own.
  • The owner added an isolated cron agent-turn job (0 0 1 1 *, UTC) and force-ran it once.
  • The member started a turn that the mock held open and queued a follow-up behind it. The Gateway then shut down with the follow-up stored as queued.
  • The agent database was at schema 42 and the state database at schema 40.

On this branch, same state directory and config, before any opt-in:

  • Startup migrated the agent database 42 → 44 and the state database 40 → 42 through the normal chain.
  • The gateway.roles and cron config sections were unchanged.
  • Members with null access: the membership row kept its identity_id, added_by and added_at, and the migration added access as null. session.members.list returned the same members as on 2026.11.10.
  • Queued input: the follow-up queued on 2026.11.10 ran after startup and completed (agent.wait status ok).
  • History: every 2026.11.10 message in both sessions was unchanged in chat.history.
  • Cron: the job kept its id, name, schedule, session target, payload, delivery, wake mode and enabled state. A forced run after the upgrade completed, and its run history shows both runs as ok.
  • Ordinary member can still send: the unlevelled member's turns completed in the owner's session and in their own session. The shared session's row had no invitedAccess, and no stored session entry gained participationCeiling or delegatedOperatorSource. The member's tool list matched 2026.11.10 except that session_project is now offered. The same difference appears on main (chore: carry and enforce participant limits on admitted runs #204847's upgrade proof), so it isn't from this PR.
  • Database integrity: integrity_check reported ok on the agent and state databases after every phase.

After opting the existing role in (others: "invited", maxInvitedAccess: "send", then a Gateway restart):

  • The unlevelled member could still read the session, but chat.send was refused. An unlevelled member counts as read until the creator sets a level.
  • After session.members.setAccess set send, the member's turn completed with participant tools only. It dropped computer, github_publish, message, openclaw and session_project, which the owner's turn still had.

Version guard: this branch carries package version 2026.11.9, older than the release. The candidate Gateway therefore ran with OPENCLAW_ALLOW_OLDER_BINARY_DESTRUCTIVE_ACTIONS=1, which skips only the version-string guard. The schema migrations ran normally.

Earlier runs: the same flow passed from [email protected], with the agent database migrated 38 → 44. A fresh state directory on this branch also passed: a member invited at suggest was refused for chat.send and could send after setAccess to send.

Stored data this PR writes

  • No schema change. This PR adds no table, column or schema version.
  • session_members.access: part 1 added this column. This PR is the first code that writes a non-null value, and only when an opted-in role's member is invited at a level or given one with setAccess. Existing rows stay null.
  • Role config: this PR adds optional maxInvitedAccess, invitedPermission, invitedTools and invitedAlsoAllow fields under gateway.roles.definitions.<role>.sessions. Released role definitions parse to identical objects; no defaults are injected.
  • Participant runs: an admitted participant's turn stores part 2's optional participationCeiling with that participant's operator source on the session entry (operatorSources.<profileId>.participationCeiling). In the upgrade run, only the session where the participant sent after opt-in gained it.
  • Projections only: invitedAccess and invitedPermission on session rows are computed per viewer and are not stored.

Stored-record compatibility test

session-row-invited-access.test.ts › "keeps stored roles and unlevelled member rows working as they did before invitations":

  • It parses role definitions for every released others value, plus main's ceiling-free invited, through this branch's schema. Each parses back to an identical object.
  • It stores unlevelled members through the unchanged membership writer and reads them back with no access.
  • For shared, suggest and read-only sessions, it records each member's and non-member's sharing role, send ability and workspace read ability for every role.

The same test file, with its assertions unchanged, passes on the merge base 1913f57b9262 and on current main 8616182ae3f2. Stored roles and unlevelled member rows therefore keep main's behavior under this PR.

Checks

All checks ran on this branch, rebased onto main after parts 1 to 3 merged:

  • Typechecks: core, UI, extensions, scripts and every test shard pass.
  • Generated outputs: I regenerated the config doc baseline. The config schema, protocol, validator and worker-inventory checks report everything current.
  • Ratchets: import cycles (madge), session identity, max-lines and test lines pass. The test-line count is 5,941 net lines, covered by the allowance plus the record.
  • Vitest inventory and ownership tests: pass.
  • Formatting: changed files pass.
  • Lint: changed code has no findings. Two max-lines errors come from main, in chat-send-session.ts and a Crabbox test; this PR doesn't touch either file.
  • Tests: all changed or restored test files pass, including the 9 server.participation* Gateway suites and the Talk handler suites. On an earlier stack base, server.participation-admission failed once while the host was under heavy load; it passed on every run since.
  • Compatibility test: the stored-record test above passes on this head, the merge base and current main. The test-line ratchet, lint, format and every core test typecheck shard pass with it.
  • Review: an independent review found no P0 to P2 issues. It compared sharing, typing, reaction, suggestion, mention and sandbox decisions for non-opt-in roles against the base, and checked the split boundaries. Its only non-opt-in finding was the read-only leak above, which this PR fixes.

CI

  • Head 4c7b1e47be90: in attempt 1 of run 45576917173, only checks-node-changed-1 failed. The failing test was server-templates-trusted-plugin-approval.e2e.test.ts with "Tool settled before requesting approval", and the openclaw/ci-gate aggregate failed with it.
    • Classification: flaky, not from this PR. This PR doesn't change the test, the Templates or plugin-approval code, or tools.invoke.
    • Same-head rerun passed: attempt 2 reran the failed jobs on the same head. checks-node-changed-1 passed, openclaw/ci-gate passed, and the run concluded success.
    • Local runs passed: 4 of 4 on this head with every core saturated by busy loops, and 2 of 2 on the merge base.
    • Possible cause (not confirmed): on that runner, Gateway startup import alone took 17 s. The tool call settled about 7 s after startup, before the 10 s approval timeout could have expired. That fits a call answered before the deferred plugin load finished, rather than an approval that was refused.
  • Head 69c4268235c1 (adds only a test and its test-line record): run 45591914107 tested the merge with main 81d69df5dcea. Five test jobs failed, plus the openclaw/ci-gate aggregate. Every job passed except these, including security-fast.

🦞 Made with OpenClaw

@clawsweeper

clawsweeper Bot commented Nov 24, 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 app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling plugin: openclaw-id-access size: XL labels Nov 24, 2026
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Nov 24, 2026
@clawsweeper

clawsweeper Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR lets session creators grant individual invitees read, suggest, or bounded send access within their role limits.

Example: Alice has operator.sessions.read and an invited role capped at send.

  • Before: The Gateway rejects an invitation carrying access: "send".
  • After: The creator can grant Alice send access, and her turns carry the role’s tool and permission limits.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful staged functionality with shipped-entry-point and upgrade evidence, but current-head CI failures remain unattributed.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The body records real shipped CLI/Gateway fresh-install and upgrade scenarios exercising invitation refusal, send admission, participant tool limits, and preserved existing state on the unchanged production revision; inspected screenshots corroborate permission UI states but do not establish execution behavior.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Partial
User problem: Creators cannot invite one person to participate in one session under a bounded role without broader write authority.
Reason: Maintainer direction authorizes this useful admission stage; the body correctly uses Related for the larger feature because publication and invitation UI arrive separately.

Merge readiness

✅ Ready for maintainer review

This PR provides a useful, maintainer-approved invitation capability that current main still lacks; no concrete blocking code defect was established.

Reviewed head: 69c4268235c100257ec48d527967fedfba5d5d89

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway authorization combines authenticated identity, role policy, session membership, and connection scopes to admit bounded agent turns and session interactions.

flowchart TD
  A[Authenticated client] --> B[Method scope admission]
  C[Role policy and membership] --> D[Session access resolution]
  B --> D
  D --> E[Captured participation ceiling]
  E --> F[Agent and queued work]
  D --> G[Session reads and collaboration]
Loading

Technical review

Best possible solution:

Keep bounded admission in the existing sharing and run-authority owners, preserving ordinary membership behavior and the separately staged UI and publication work.

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

This is a feature addition; current-main source independently confirms that explicit invitation levels are still refused.

Is this the best way to solve the issue?

The coherent admission stage reuses existing membership storage and participant enforcement, with distinct coverage for scopes, cancellation, recovery, children, and ordinary-user compatibility.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Josh Lehman: Raw commit d2699a8 adds src/gateway/session-sharing-policy.ts:556 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d2699a825ce7; files: src/gateway/session-sharing-policy.ts)
  • Vincent Koc: Raw commit 62a982b adds src/gateway/human-mention-policy.ts:197 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 62a982bb24b5; files: src/gateway/human-mention-policy.ts)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Optional role settings 4 additions maxInvitedAccess, invitedPermission, invitedTools, and invitedAlsoAllow are optional; existing definitions receive no injected defaults.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (7 earlier review cycles)
  • reviewed 2026-11-24T21:39:23.941Z sha 5c149cf :: blocked before merge. :: [P2] [P2] Update the shared Talk fixture for the new sharing contract | [P2] [P2] Describe the participant defaults available in this stage
  • reviewed 2026-11-24T23:50:51.943Z sha ed48a7c :: needs maintainer review before merge. :: none
  • reviewed 2026-11-25T02:15:44.604Z sha 0fabada :: blocked before merge. :: none
  • reviewed 2026-11-25T05:45:53.436Z sha 817774f :: needs maintainer review before merge. :: none
  • reviewed 2026-11-25T09:40:38.206Z sha 4c7b1e4 :: blocked before merge. :: none
  • reviewed 2026-11-25T09:49:12.424Z sha 4c7b1e4 :: blocked before merge. :: none
  • reviewed 2026-11-25T09:57:57.407Z sha 4c7b1e4 :: needs maintainer review before merge. :: none

Reviewed November 25, 2026, 5:37 AM ET / 10:37 UTC (Revision 8).

@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 24, 2026
@jalehman
jalehman force-pushed the participate-split/p3-creator-approvals branch from 6c74d16 to 3aa15c8 Compare November 25, 2026 00:45
@jalehman
jalehman force-pushed the participate-split/p4-invited-admission branch from ed48a7c to 0fabada Compare November 25, 2026 01:36
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 25, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

CI attribution for head 0fabada34afc. Both failing test jobs are inherited from main at this stack's base (a4be1cee8ea2). main has since fixed both, and neither the failing tests nor the code they test are changed by this PR.

  • checks-node-changed-2, bash-tools.exec-gateway-approval.e2e.test.ts, "withholds the active hook token source from exec children at startup and across reload":
    • It fails the same way locally at the part 3 head 3aa15c84e4b8, which doesn't include this PR.
    • main fixed the test's race in 4a18083 ("fix(test): await the queued hook-token exec across reload"). It passes locally at that commit.
  • checks-node-changed-compact-large-32-5, chat-send-pending-input-withdrawal.test.ts, "settles queued input (restart, restart, discard: false)…":

Both should clear when the stack is rebased onto current main before landing. I'll rerun CI then.

Data-model compatibility: the PR body's "Upgrade from the released 2026.11.8" section covers this. It ran the published [email protected] and then this branch on the same state directory, using real CLI and Gateway entry points.

  • An unlevelled member and a queued follow-up survived the 38 → 44 migration, and every stored history message was unchanged.
  • Roles that haven't opted in kept their behaviour.
  • After opting in, the existing member was read-only until the creator set a level.

This PR adds no schema; the access column comes from #204783, which is already on main.

@clawsweeper clawsweeper Bot added the P2 Normal backlog priority with limited blast radius. label Nov 25, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Nov 25, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Nov 25, 2026
@jalehman
jalehman merged commit 283b6d7 into main Nov 25, 2026
175 of 182 checks passed
@jalehman
jalehman deleted the participate-split/p4-invited-admission branch November 25, 2026 11:01
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

vincentkoc added a commit that referenced this pull request Nov 26, 2026
…ot found (#205698)

#204899 routes chat.send from a session-read personal profile through session
participation, which refuses a session the person can no longer join with the
hidden not-found error instead of a missing operator.write scope. The test
still expected the scope refusal and failed on main.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
… role limits (openclaw#204899)

* feat: let invited people read, suggest or send in your session within role limits

* chore: name the test-line allocation after its pull request

* test: give Talk handler fixture clients their connection scopes

* docs: list only the participant tools available before shared publication

* test: select replayed participant approvals the way the session runtime does

* test: build participant lifetime fixtures with a turn grant

* test: import system turn authority from its admission owner

* test: expect the shared-publication requester to refuse participants before part 5

* test: prove stored roles and unlevelled members keep their sharing behavior
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…ot found (openclaw#205698)

openclaw#204899 routes chat.send from a session-read personal profile through session
participation, which refuses a session the person can no longer join with the
hidden not-found error instead of a missing operator.write scope. The test
still expected the scope refusal and failed on main.
obviyus added a commit that referenced this pull request Nov 29, 2026
…#208578)

The maintainer approved the turn-scoped Stop cascade on 2026-11-29.

## Problem

Pressing Esc in the TUI, Stop on the Wear app, or Stop on a Workboard card without a recorded run stopped the agent's turn, but the subagents that turn had started kept running and spending. These clients send `chat.abort` with only a session key. On main, that call never cancels descendants. Only an exact-run `chat.abort`, `/stop` and `sessions.abort` do.

The docs disagreed with each other. `docs/tools/subagents/nesting.md` promised that explicit cancellation cascades through the descendant tree. The RPC pages (`rpc-session-control.md`, `subagents/operations.md`, `control-ui/chat.md`, `session-controller.md`) documented the run-less exception, which #122909 and #133076 kept to limit the blast radius: "broad session cleanup violates sibling ownership".

## What changes

A `chat.abort` without a `runId` now cancels the descendants of the runs it actually stops, the same way an exact-run Stop cancels its turn's descendants (#122909).

- **Children of the stopped turn:** cancelled. Native harness children are tied to their turn's exec custody, which is captured for every selected run before any parent stops; registry children keep their spawning turn id and are selected after the runs stop.
- **Work the call did not stop keeps its children:** a `/btw` side run kept by `preserveSideRuns`, another person's run, a worker run the call does not cancel, and children an earlier, finished turn started. `sessions.abort` and `/stop` still stop all of those.
- **A yielded parent or a dormant child:** no turn is running, so a run-less `chat.abort` stops nothing there, as before. `sessions.abort` stops that paused work.
- **Invited participants:** a participant may stop only their own runs (#204899). Their Stop, run-less or exact-run, now also cancels those runs' children, and never another member's. Before this change a participant's Stop never cancelled children, even with an exact run id.
- **`/stop` and `sessions.abort`** keep their whole-session cascade. When it is blocked (for example, while a hidden run is active), they now stop at least the stopped turns' children instead of none.
- **Permissions:** unchanged. Anyone who could stop a run before still can, and the cascade reaches only the descendants of runs that caller stopped.

The owner is `abortChatRunsForSessionKeyWithPartials`. For an explicit user Stop (`announceRunStopped`) that is not a whole-session Stop, it captures the exec custody of every run the plan selected, stops the runs, then runs the exact-run descendant cancellation for each run that actually stopped. Native harness children follow their turn's exec custody, which ends when the turn unwinds, so it is captured before any parent stops. Worker-placement reclaim, session drain and queued-input discard do not mark an explicit Stop, so they cancel no descendants. There is no protocol, schema or config change.

Docs: the four RPC pages and `nesting.md` now say the same thing. A run-less Stop is turn-scoped; `sessions.abort` and `/stop` are whole-session.

## Evidence

Tests at the Gateway handler boundary, with real registry children:

- `chat.abort-cascade.test.ts`, "a run-less Stop cancels only the children of the turn it stops": `preserveSideRuns` with a live `/btw`, the stopped turn's child, a child of a worker run the call does not stop, and an earlier turn's child. Only the stopped turn's child is cancelled; the `/btw` is not aborted. **Red on main, green here.** The exact-run case is the control (green on both).
- `chat.abort-cascade.test.ts`, invited member, run-less and exact-run: the member's Stop cancels the child of their own turn and leaves the child of another member's turn running. **Red on main for both, green here.**
- `chat.abort-cascade.test.ts`, native children: a run-less Stop that stops two live turns cancels the native harness children of both. **Red without the custody capture, green here.**
- `chat.abort-cascade.test.ts`, blocked whole-session Stop: with a hidden run active, `sessions.abort`/`/stop` still cancel the stopped turn's child and leave an earlier turn's child running. **Red on main, green here.**
- `sessions.abort-yielded.test.ts`: a run-less `chat.abort` on a yielded parent, and on the dormant child itself, stops nothing and leaves the paused child unchanged (control, green on both).
- Gateway Stop suites: 28 files, 665 tests, plus the real-Gateway `run_stopped` hook e2e, all green.

Live Gateway with a fake provider, main vs this branch, 3 runs each:

| Scenario | main | this branch |
|---|---|---|
| Run-less `chat.abort {sessionKey}` (Wear's exact request, Workboard fallback) with a live child | child keeps running 3/3 | child killed 3/3 |
| Exact-run `chat.abort` / typed `/stop` (controls) | child killed 3/3 | child killed 3/3 |
| TUI Esc (`preserveSideRuns: true`) with a live `/btw`, a child of the stopped turn and a background child of an earlier turn | stopped turn's child keeps running 3/3; earlier child running; `/btw` reaches final | stopped turn's child killed 3/3; earlier child keeps running; `/btw` reaches final |
| Invited send member's run-less Stop, with a child of their turn and a background child of the owner's earlier turn | member's child keeps running 3/3 | member's child killed 3/3; owner's child keeps running |

Not benchmark-shaped: the change is in the one Stop owner, with no client, model or provider branches.

## Merge danger

Two-way door: a revert fully restores the old behavior. Nothing is written, migrated or published differently, and the RPC schema is unchanged. Blast radius: every client that sends a run-less `chat.abort` (TUI Esc, Wear, the Workboard fallback, Android) now also stops the stopped turn's subagents. A user who presses Esc while a turn waits on `sessions_yield` still has to use `/stop` to end those children.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…#208578)

The maintainer approved the turn-scoped Stop cascade on 2026-11-29.

## Problem

Pressing Esc in the TUI, Stop on the Wear app, or Stop on a Workboard card without a recorded run stopped the agent's turn, but the subagents that turn had started kept running and spending. These clients send `chat.abort` with only a session key. On main, that call never cancels descendants. Only an exact-run `chat.abort`, `/stop` and `sessions.abort` do.

The docs disagreed with each other. `docs/tools/subagents/nesting.md` promised that explicit cancellation cascades through the descendant tree. The RPC pages (`rpc-session-control.md`, `subagents/operations.md`, `control-ui/chat.md`, `session-controller.md`) documented the run-less exception, which #122909 and #133076 kept to limit the blast radius: "broad session cleanup violates sibling ownership".

## What changes

A `chat.abort` without a `runId` now cancels the descendants of the runs it actually stops, the same way an exact-run Stop cancels its turn's descendants (#122909).

- **Children of the stopped turn:** cancelled. Native harness children are tied to their turn's exec custody, which is captured for every selected run before any parent stops; registry children keep their spawning turn id and are selected after the runs stop.
- **Work the call did not stop keeps its children:** a `/btw` side run kept by `preserveSideRuns`, another person's run, a worker run the call does not cancel, and children an earlier, finished turn started. `sessions.abort` and `/stop` still stop all of those.
- **A yielded parent or a dormant child:** no turn is running, so a run-less `chat.abort` stops nothing there, as before. `sessions.abort` stops that paused work.
- **Invited participants:** a participant may stop only their own runs (#204899). Their Stop, run-less or exact-run, now also cancels those runs' children, and never another member's. Before this change a participant's Stop never cancelled children, even with an exact run id.
- **`/stop` and `sessions.abort`** keep their whole-session cascade. When it is blocked (for example, while a hidden run is active), they now stop at least the stopped turns' children instead of none.
- **Permissions:** unchanged. Anyone who could stop a run before still can, and the cascade reaches only the descendants of runs that caller stopped.

The owner is `abortChatRunsForSessionKeyWithPartials`. For an explicit user Stop (`announceRunStopped`) that is not a whole-session Stop, it captures the exec custody of every run the plan selected, stops the runs, then runs the exact-run descendant cancellation for each run that actually stopped. Native harness children follow their turn's exec custody, which ends when the turn unwinds, so it is captured before any parent stops. Worker-placement reclaim, session drain and queued-input discard do not mark an explicit Stop, so they cancel no descendants. There is no protocol, schema or config change.

Docs: the four RPC pages and `nesting.md` now say the same thing. A run-less Stop is turn-scoped; `sessions.abort` and `/stop` are whole-session.

## Evidence

Tests at the Gateway handler boundary, with real registry children:

- `chat.abort-cascade.test.ts`, "a run-less Stop cancels only the children of the turn it stops": `preserveSideRuns` with a live `/btw`, the stopped turn's child, a child of a worker run the call does not stop, and an earlier turn's child. Only the stopped turn's child is cancelled; the `/btw` is not aborted. **Red on main, green here.** The exact-run case is the control (green on both).
- `chat.abort-cascade.test.ts`, invited member, run-less and exact-run: the member's Stop cancels the child of their own turn and leaves the child of another member's turn running. **Red on main for both, green here.**
- `chat.abort-cascade.test.ts`, native children: a run-less Stop that stops two live turns cancels the native harness children of both. **Red without the custody capture, green here.**
- `chat.abort-cascade.test.ts`, blocked whole-session Stop: with a hidden run active, `sessions.abort`/`/stop` still cancel the stopped turn's child and leave an earlier turn's child running. **Red on main, green here.**
- `sessions.abort-yielded.test.ts`: a run-less `chat.abort` on a yielded parent, and on the dormant child itself, stops nothing and leaves the paused child unchanged (control, green on both).
- Gateway Stop suites: 28 files, 665 tests, plus the real-Gateway `run_stopped` hook e2e, all green.

Live Gateway with a fake provider, main vs this branch, 3 runs each:

| Scenario | main | this branch |
|---|---|---|
| Run-less `chat.abort {sessionKey}` (Wear's exact request, Workboard fallback) with a live child | child keeps running 3/3 | child killed 3/3 |
| Exact-run `chat.abort` / typed `/stop` (controls) | child killed 3/3 | child killed 3/3 |
| TUI Esc (`preserveSideRuns: true`) with a live `/btw`, a child of the stopped turn and a background child of an earlier turn | stopped turn's child keeps running 3/3; earlier child running; `/btw` reaches final | stopped turn's child killed 3/3; earlier child keeps running; `/btw` reaches final |
| Invited send member's run-less Stop, with a child of their turn and a background child of the owner's earlier turn | member's child keeps running 3/3 | member's child killed 3/3; owner's child keeps running |

Not benchmark-shaped: the change is in the one Stop owner, with no client, model or provider branches.

## Merge danger

Two-way door: a revert fully restores the old behavior. Nothing is written, migrated or published differently, and the RPC schema is unchanged. Blast radius: every client that sends a run-less `chat.abort` (TUI Esc, Wear, the Workboard fallback, Android) now also stops the stopped turn's subagents. A user who presses Esc while a turn waits on `sessions_yield` still has to use `/stop` to end those children.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 9da8ce6)

Release adaptation: keep the stable exact-run owner and use already admitted authorization. Capture direct and native descendants before unwind, deduplicate by canceled turn and cascade only for successful cancellation. Companion audit: search, partial text and digest fixes are independent; TUI stop-all and hint changes are separate behavior.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…#208578)

The maintainer approved the turn-scoped Stop cascade on 2026-11-29.

## Problem

Pressing Esc in the TUI, Stop on the Wear app, or Stop on a Workboard card without a recorded run stopped the agent's turn, but the subagents that turn had started kept running and spending. These clients send `chat.abort` with only a session key. On main, that call never cancels descendants. Only an exact-run `chat.abort`, `/stop` and `sessions.abort` do.

The docs disagreed with each other. `docs/tools/subagents/nesting.md` promised that explicit cancellation cascades through the descendant tree. The RPC pages (`rpc-session-control.md`, `subagents/operations.md`, `control-ui/chat.md`, `session-controller.md`) documented the run-less exception, which #122909 and #133076 kept to limit the blast radius: "broad session cleanup violates sibling ownership".

## What changes

A `chat.abort` without a `runId` now cancels the descendants of the runs it actually stops, the same way an exact-run Stop cancels its turn's descendants (#122909).

- **Children of the stopped turn:** cancelled. Native harness children are tied to their turn's exec custody, which is captured for every selected run before any parent stops; registry children keep their spawning turn id and are selected after the runs stop.
- **Work the call did not stop keeps its children:** a `/btw` side run kept by `preserveSideRuns`, another person's run, a worker run the call does not cancel, and children an earlier, finished turn started. `sessions.abort` and `/stop` still stop all of those.
- **A yielded parent or a dormant child:** no turn is running, so a run-less `chat.abort` stops nothing there, as before. `sessions.abort` stops that paused work.
- **Invited participants:** a participant may stop only their own runs (#204899). Their Stop, run-less or exact-run, now also cancels those runs' children, and never another member's. Before this change a participant's Stop never cancelled children, even with an exact run id.
- **`/stop` and `sessions.abort`** keep their whole-session cascade. When it is blocked (for example, while a hidden run is active), they now stop at least the stopped turns' children instead of none.
- **Permissions:** unchanged. Anyone who could stop a run before still can, and the cascade reaches only the descendants of runs that caller stopped.

The owner is `abortChatRunsForSessionKeyWithPartials`. For an explicit user Stop (`announceRunStopped`) that is not a whole-session Stop, it captures the exec custody of every run the plan selected, stops the runs, then runs the exact-run descendant cancellation for each run that actually stopped. Native harness children follow their turn's exec custody, which ends when the turn unwinds, so it is captured before any parent stops. Worker-placement reclaim, session drain and queued-input discard do not mark an explicit Stop, so they cancel no descendants. There is no protocol, schema or config change.

Docs: the four RPC pages and `nesting.md` now say the same thing. A run-less Stop is turn-scoped; `sessions.abort` and `/stop` are whole-session.

## Evidence

Tests at the Gateway handler boundary, with real registry children:

- `chat.abort-cascade.test.ts`, "a run-less Stop cancels only the children of the turn it stops": `preserveSideRuns` with a live `/btw`, the stopped turn's child, a child of a worker run the call does not stop, and an earlier turn's child. Only the stopped turn's child is cancelled; the `/btw` is not aborted. **Red on main, green here.** The exact-run case is the control (green on both).
- `chat.abort-cascade.test.ts`, invited member, run-less and exact-run: the member's Stop cancels the child of their own turn and leaves the child of another member's turn running. **Red on main for both, green here.**
- `chat.abort-cascade.test.ts`, native children: a run-less Stop that stops two live turns cancels the native harness children of both. **Red without the custody capture, green here.**
- `chat.abort-cascade.test.ts`, blocked whole-session Stop: with a hidden run active, `sessions.abort`/`/stop` still cancel the stopped turn's child and leave an earlier turn's child running. **Red on main, green here.**
- `sessions.abort-yielded.test.ts`: a run-less `chat.abort` on a yielded parent, and on the dormant child itself, stops nothing and leaves the paused child unchanged (control, green on both).
- Gateway Stop suites: 28 files, 665 tests, plus the real-Gateway `run_stopped` hook e2e, all green.

Live Gateway with a fake provider, main vs this branch, 3 runs each:

| Scenario | main | this branch |
|---|---|---|
| Run-less `chat.abort {sessionKey}` (Wear's exact request, Workboard fallback) with a live child | child keeps running 3/3 | child killed 3/3 |
| Exact-run `chat.abort` / typed `/stop` (controls) | child killed 3/3 | child killed 3/3 |
| TUI Esc (`preserveSideRuns: true`) with a live `/btw`, a child of the stopped turn and a background child of an earlier turn | stopped turn's child keeps running 3/3; earlier child running; `/btw` reaches final | stopped turn's child killed 3/3; earlier child keeps running; `/btw` reaches final |
| Invited send member's run-less Stop, with a child of their turn and a background child of the owner's earlier turn | member's child keeps running 3/3 | member's child killed 3/3; owner's child keeps running |

Not benchmark-shaped: the change is in the one Stop owner, with no client, model or provider branches.

## Merge danger

Two-way door: a revert fully restores the old behavior. Nothing is written, migrated or published differently, and the RPC schema is unchanged. Blast radius: every client that sends a run-less `chat.abort` (TUI Esc, Wear, the Workboard fallback, Android) now also stops the stopped turn's subagents. A user who presses Esc while a turn waits on `sessions_yield` still has to use `/stop` to end those children.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 9da8ce6)

Release adaptation: Use the existing Gateway descendant cancellation owner and candidate Stop admission, capture custody before cancellation and cascade only for recorded stopped runs. Do not import the main-only extracted owners or parent-notice feature. Split the new turn-scoped regressions into a sibling test to keep the existing suite below its line cap.

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 30, 2026
…openclaw#208578)

The maintainer approved the turn-scoped Stop cascade on 2026-11-29.

## Problem

Pressing Esc in the TUI, Stop on the Wear app, or Stop on a Workboard card without a recorded run stopped the agent's turn, but the subagents that turn had started kept running and spending. These clients send `chat.abort` with only a session key. On main, that call never cancels descendants. Only an exact-run `chat.abort`, `/stop` and `sessions.abort` do.

The docs disagreed with each other. `docs/tools/subagents/nesting.md` promised that explicit cancellation cascades through the descendant tree. The RPC pages (`rpc-session-control.md`, `subagents/operations.md`, `control-ui/chat.md`, `session-controller.md`) documented the run-less exception, which openclaw#122909 and openclaw#133076 kept to limit the blast radius: "broad session cleanup violates sibling ownership".

## What changes

A `chat.abort` without a `runId` now cancels the descendants of the runs it actually stops, the same way an exact-run Stop cancels its turn's descendants (openclaw#122909).

- **Children of the stopped turn:** cancelled. Native harness children are tied to their turn's exec custody, which is captured for every selected run before any parent stops; registry children keep their spawning turn id and are selected after the runs stop.
- **Work the call did not stop keeps its children:** a `/btw` side run kept by `preserveSideRuns`, another person's run, a worker run the call does not cancel, and children an earlier, finished turn started. `sessions.abort` and `/stop` still stop all of those.
- **A yielded parent or a dormant child:** no turn is running, so a run-less `chat.abort` stops nothing there, as before. `sessions.abort` stops that paused work.
- **Invited participants:** a participant may stop only their own runs (openclaw#204899). Their Stop, run-less or exact-run, now also cancels those runs' children, and never another member's. Before this change a participant's Stop never cancelled children, even with an exact run id.
- **`/stop` and `sessions.abort`** keep their whole-session cascade. When it is blocked (for example, while a hidden run is active), they now stop at least the stopped turns' children instead of none.
- **Permissions:** unchanged. Anyone who could stop a run before still can, and the cascade reaches only the descendants of runs that caller stopped.

The owner is `abortChatRunsForSessionKeyWithPartials`. For an explicit user Stop (`announceRunStopped`) that is not a whole-session Stop, it captures the exec custody of every run the plan selected, stops the runs, then runs the exact-run descendant cancellation for each run that actually stopped. Native harness children follow their turn's exec custody, which ends when the turn unwinds, so it is captured before any parent stops. Worker-placement reclaim, session drain and queued-input discard do not mark an explicit Stop, so they cancel no descendants. There is no protocol, schema or config change.

Docs: the four RPC pages and `nesting.md` now say the same thing. A run-less Stop is turn-scoped; `sessions.abort` and `/stop` are whole-session.

## Evidence

Tests at the Gateway handler boundary, with real registry children:

- `chat.abort-cascade.test.ts`, "a run-less Stop cancels only the children of the turn it stops": `preserveSideRuns` with a live `/btw`, the stopped turn's child, a child of a worker run the call does not stop, and an earlier turn's child. Only the stopped turn's child is cancelled; the `/btw` is not aborted. **Red on main, green here.** The exact-run case is the control (green on both).
- `chat.abort-cascade.test.ts`, invited member, run-less and exact-run: the member's Stop cancels the child of their own turn and leaves the child of another member's turn running. **Red on main for both, green here.**
- `chat.abort-cascade.test.ts`, native children: a run-less Stop that stops two live turns cancels the native harness children of both. **Red without the custody capture, green here.**
- `chat.abort-cascade.test.ts`, blocked whole-session Stop: with a hidden run active, `sessions.abort`/`/stop` still cancel the stopped turn's child and leave an earlier turn's child running. **Red on main, green here.**
- `sessions.abort-yielded.test.ts`: a run-less `chat.abort` on a yielded parent, and on the dormant child itself, stops nothing and leaves the paused child unchanged (control, green on both).
- Gateway Stop suites: 28 files, 665 tests, plus the real-Gateway `run_stopped` hook e2e, all green.

Live Gateway with a fake provider, main vs this branch, 3 runs each:

| Scenario | main | this branch |
|---|---|---|
| Run-less `chat.abort {sessionKey}` (Wear's exact request, Workboard fallback) with a live child | child keeps running 3/3 | child killed 3/3 |
| Exact-run `chat.abort` / typed `/stop` (controls) | child killed 3/3 | child killed 3/3 |
| TUI Esc (`preserveSideRuns: true`) with a live `/btw`, a child of the stopped turn and a background child of an earlier turn | stopped turn's child keeps running 3/3; earlier child running; `/btw` reaches final | stopped turn's child killed 3/3; earlier child keeps running; `/btw` reaches final |
| Invited send member's run-less Stop, with a child of their turn and a background child of the owner's earlier turn | member's child keeps running 3/3 | member's child killed 3/3; owner's child keeps running |

Not benchmark-shaped: the change is in the one Stop owner, with no client, model or provider branches.

## Merge danger

Two-way door: a revert fully restores the old behavior. Nothing is written, migrated or published differently, and the RPC schema is unchanged. Blast radius: every client that sends a run-less `chat.abort` (TUI Esc, Wear, the Workboard fallback, Android) now also stops the stopped turn's subagents. A user who presses Esc while a turn waits on `sessions_yield` still has to use `/stop` to end those children.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. P2 Normal backlog priority with limited blast radius. plugin: openclaw-id-access proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts security-sensitive-changed size: XL 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