Skip to content

feat(delegation): a delegated run inherits its parent's caller - #448

Merged
TonsOfFun merged 5 commits into
mainfrom
feat/delegation-actor
Sep 12, 2026
Merged

feat(delegation): a delegated run inherits its parent's caller#448
TonsOfFun merged 5 commits into
mainfrom
feat/delegation-actor

Conversation

@TonsOfFun

Copy link
Copy Markdown
Contributor

Stacked on #443 (the caller seam); retarget to main once that merges.

Delegation::Runner#generate built the sub-agent with the parent's params and trace id but not its caller, so SupportHubAgent.as(user) delegating to TicketAgent ran the specialist unattributed — and a host scope written correctly against Pundit answered "no tickets" to a user with plenty. Found in a host app that had to forward the user through params: by hand to work around it.

Change

The sub-agent gets the parent's current_user before its action runs (inherit_actor), so its own before_action callbacks and any SchemaTools scope its tools read through decide against the same person. A parent with no caller still delegates an unattributed run — never someone else's. Hosts on a framework without the seam are left as they were (the assignment is guarded on respond_to?).

Testing

  • test/authorization_test.rb (+2): a delegated run sees the parent's caller; a parent with no caller delegates nil.
  • bin/test test/authorization_test.rb test/delegation_test.rb — 12 runs, 20 assertions, 0 failures.
  • bin/rubocop clean on the changed files.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XMSRnSxYS9mRx1hSjytB9Z

delegate_to hands the sub-agent the parent's current_user before its action
runs, so its own before_action callbacks and any scope its tools read
through decide against the same person. A parent authorized as one user no
longer hands its specialists an unattributed run — which a correctly written
host scope reads as "no access". A parent with no caller still delegates an
unattributed run, never someone else's.

Builds on the caller seam (#443).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XMSRnSxYS9mRx1hSjytB9Z
@TonsOfFun
TonsOfFun changed the base branch from claude/zealous-turing-4afxvn to main September 12, 2026 19:24
@TonsOfFun
TonsOfFun merged commit 90c0d04 into main Sep 12, 2026
8 checks passed
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