Skip to content

feat(agent): let the Bot delegate to sessions it creates - #6538

Merged
liugddx merged 2 commits into
rust-previewfrom
feat/bot-delegate
Nov 1, 2026
Merged

liugddx merged 2 commits into
rust-previewfrom
feat/bot-delegate

Conversation

@liugddx

@liugddx liugddx commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Summary

The Bot can now hand hands-on work to workers it creates itself. This is the first delegation step discussed in #6076: no dependency graph, several independent workers can run in parallel, and control is limited to the Bot's own workers. Worker-completion wake is a separate step.

  • The Bot holds SessionCreate, SessionSend and SessionStop.
  • A Session the Bot creates follows the ordinary creation rules, with the Bot recorded as its parentSessionId (the option M4n5ter described in [DISCUSS] From task execution to an Always-on Agent harness #6076): omitted tools use the ordinary installed-tool defaults, explicit tools are not intersected with the Bot's own list, workspace choice and Host permission/confirmation are the ordinary ones. The worker does not inherit Bot identity, and SendUser/sleep requests are still refused. Ordinary Agent-to-Agent tool inheritance is unchanged.
  • SessionSend and SessionStop from the Bot are checked against parentSessionId. SessionSend to any other conversation returns the new typed result not_your_worker and admits nothing; SessionStop returns requested: false. Callers other than the Bot are unchanged.
  • The standing instructions name the delegation tools only when the Bot holds them, and tell it that a finished worker does not notify it yet, so it reads progress with the read tools and does not claim completion.

Notes for reviewers

  • SessionSend/SessionStop are the general Session tools, so for the Bot they are limited to its own workers for now. Letting the Bot manage the user's other conversations needs the permission and confirmation tiers, which is a separate step.
  • Because a worker follows the ordinary rules, it may hold Session tools a user-created conversation holds; that is the same trust as any ordinary Session.
  • Only newly created Bots get the new tools: a Session's tool list is fixed at creation, so an existing Bot must be archived and reopened.
  • New SendResult::NotYourWorker variant, so packages/plugin-sdk generated contracts changed.

Test plan

  • bot_tests (20, including the new delegation test: Bot creates a worker, omitted and explicit tools follow the ordinary rules, SendUser is still refused, send to a foreign conversation refused, send to its own worker starts it)
  • prompt unit test extended for the delegation tools
  • cargo clippy -p maka-agent-native -p maka-agent-api --no-deps --all-targets, cargo fmt, cargo check --workspace --tests
  • Not verified with a real model yet

🤖 Generated with Claude Code

liugddx and others added 2 commits November 1, 2026 20:01
The Bot holds SessionCreate, SessionSend and SessionStop. A conversation the
Bot creates is an ordinary conversation in the Bot's own workspace, not bounded
by the Bot's coordination-only tool list, so it can do real work. It is never
given the tools that change or message conversations, so delegating is not a
way around the Bot's own limits.

The Bot can send to or stop only the conversations whose parentSessionId is
itself; SessionSend answers not_your_worker for any other conversation and
nothing is admitted. Other callers are unaffected. The instructions name the
delegation tools only when the Bot holds them and say a finished worker does
not notify the Bot yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Following the #6076 discussion: a Session the Bot creates follows the same
creation rules as a user-created one and is only recorded under the Bot as its
parent. Omitted tools use the ordinary defaults, explicit tools are not
intersected with the Bot's own list, and the workspace choice is the ordinary
one. Drops the fixed worker preset and the Bot-workspace restriction. Send and
stop from the Bot stay limited to its own workers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@liugddx liugddx changed the title feat(agent): let the Bot hand work to workers it creates feat(agent): let the Bot delegate to sessions it creates Nov 1, 2026
@liugddx
liugddx merged commit 20cdf6b into rust-preview Nov 1, 2026
13 checks passed
@liugddx
liugddx deleted the feat/bot-delegate branch November 1, 2026 12:58

@Astro-Han Astro-Han 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.

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

I reviewed all eight changed files at 96a4575e172842d1a7089a8455aae3b9d80a3f3b and the surrounding session creation, Bot identity and service-admission paths. The eight submitted blobs match merge commit 20cdf6b8. I found no confirmed P0–P2 defect in this source review.

The final design follows the ordinary-session creation rule clarified in the discussion. In owner.rs:773, only a Bot caller bypasses inheritance of the parent's tool ceiling; the stored parent is derived from the call identity, and normal workspace selection and Host permissions remain in use. These workers are ordinary Sessions and may hold Session tools themselves. The earlier fixed worker preset and Bot-workspace restriction are absent from this final commit.

owner/bot.rs:844 checks that the target belongs to this owner and has the current Bot as its stored parent. service.rs:917 and service.rs:972 apply that check before admitting send or stop; foreign sends return not_your_worker, and foreign stops report requested: false. I also checked the generated SDK alternatives, ACP rejection handling, installed-tool filtering, explicit SendUser/sleep rejection at creation, and the three-language prompt capability selection. Existing Bots retain their stored tool list and need reopening to acquire the new tools. Worker-completion wake is a separate change.

CI 41306002668 succeeded. I independently read its root-test logs and confirmed passes for the_bot_delegates_to_ordinary_sessions_and_controls_only_its_own, the_instructions_name_only_the_tools_the_bot_holds, and the Bot-only sleep/identity checks. Those are hosted executions. I did not run Rust, the Host, a real model, restart recovery or permission dialogs locally, so this is not independent end-to-end acceptance of delegation.

P3 — Missing AI commit attribution. Both material PR commits declare Claude co-authorship but lack the required Generated-by: trailer; the merged squash 20cdf6b8 also lacks it. The PR body identifies Claude Code. Preserve the required trailer in subsequent material commits and record the merged attribution omission through the project's normal correction process. This is an attribution issue, not an identified runtime defect.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

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.

2 participants