Skip to content

fix(agent-tools): let a parent stop its child after its grant shrinks - #4673

Merged
devswha merged 6 commits into
mainfrom
fix/delegation-stop-always-allowed
Nov 25, 2026
Merged

devswha merged 6 commits into
mainfrom
fix/delegation-stop-always-allowed

Conversation

@devswha

@devswha devswha commented Nov 25, 2026

Copy link
Copy Markdown
Owner

What

A parent agent can always stop a child it started, even after its grant shrinks: the switch goes to look-only (view), the depth is lowered, or the child's harness is removed from "Agents they may call". agent_stop now needs only a valid run token and ownership of the child, not the start/send grant. Revocation (off), ownership and a person's hold still apply. Learned from T3 Code issue #40175 (stop gated by a permission-escalation check).

Part E of the owner-approved delegation convenience package (2026-11-25).

Tests

  • New server/agent-tools/stop.contract.test.ts: the three shrink cases each answered not_granted on main and stop the child after the fix; the owner routes POST /api/pane/turn/cancel and cancel-children work with the setting off (already true, now pinned).
  • server/agent-tools/hub.test.ts: the view-level test no longer expects stop to be not_granted; it now reaches the target check (behaviour changed on purpose).

Validation

  • bun run check fast: typecheck, build, generated files ok; unit 27941 pass, 2 fail: server/ssh-account-add.test.ts and scripts/plugin-tui.test.ts, the same environment failures this machine shows on other branches (long TMPDIR socket path, .env HOME fallback), unrelated to this diff.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • A parent agent can stop a child it started even after its delegation permissions are reduced.
    • A driving device can cancel child work through agent tools when those tools are turned off.
  • Documentation
    • Clarified when parent agents and driving devices can stop or cancel child work.

The agent tool hub now permits a run to stop its own child after delegation permissions are reduced. Tests cover policy changes and cancellation requests when agent tools are disabled.

Changes: Delegated child stopping

Layer / File(s) Summary
Stop authorization and policy-change coverage
server/agent-tools/hub.ts, server/agent-tools/hub.test.ts, server/agent-tools/stop.contract.test.ts
The hub includes stop in scope when a run started a child and allows that authenticated stop action even if the run’s verbs omit it. Tests cover authorization checks and child stopping after policy changes.
Cancellation with tools disabled
server/agent-tools/stop.contract.test.ts, docs/harness-tool.md, changelog.d/delegation-stop-after-grant-change.md
Tests check cancel and cancel-children requests with agent tools disabled. The documentation and changelog describe stopping a child after grant reduction and cancelling through agent tools.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • devswha/ovis#4624: Adds the settings and grant model for agent harness tool levels and ACP child ownership.
  • devswha/ovis#4603: Introduces the agent harness tool, including its run-only verbs, stop behavior, and cancellation routes.
Merge Risk: Minimal · previous review e6d4f

This change lets a parent agent stop a child it started after its delegation permissions are reduced. Revocation and ownership checks still apply. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main behavior change: a parent can stop its child after its delegation grant shrinks. It matches the hub.ts stop-permission change and the new stop tests. It is specific and single…
Description check Passed The description follows the template. It has a Change section that explains the problem, the resulting behavior, and the linked issue (T3 Code #40175). It has a Validation section that lists the comma…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main behavior change: a parent can stop its child after its delegation grant shrinks. It matches the hub.ts stop-permission change and the new stop tests. It is specific and single-sentence, and it uses the conventional fix(scope) prefix.

Full details: Description check

Explanation

The description follows the template. It has a Change section that explains the problem, the resulting behavior, and the linked issue (T3 Code #40175). It has a Validation section that lists the commands run, their results, and the two unrelated failing tests. It does not explicitly confirm HTTP/WS contract-test coverage in words, but the Tests section describes the contract tests for the owner cancel routes, so the requirement is substantially met.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 355248f and e6d4fd4.

Files selected for processing: 5

  • changelog.d/delegation-stop-after-grant-change.md
  • docs/harness-tool.md
  • server/agent-tools/hub.test.ts
  • server/agent-tools/hub.ts
  • server/agent-tools/stop.contract.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.

@devswha
devswha force-pushed the fix/delegation-stop-always-allowed branch from 7e33a89 to 00d1999 Compare November 25, 2026 06:18
@devswha
devswha merged commit cf01829 into main Nov 25, 2026
21 checks passed
@devswha

devswha commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head c636afddf. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit said it did not review (a limit or a skip) since this head.

Owner approved the convenience package (2026-11-25). CodeRabbit did not review this head (limit). Reviews: omo gate reviewer (BLOCK: stop refused while the child waits on an approval card, reproduced with a real keeper; docs LOW) and Codex gpt-6.2-sol-fast xhigh adversarial review (CLEAR; CI skip MEDIUM, docs LOW); all fixed in the keeper-cancel commit plus the CI test list and its pinned expectation. Follow-up: #4677 (bulk stop misses an opening child).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant