feat(delegation): a delegated run inherits its parent's caller - #448
Merged
Conversation
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
changed the base branch from
claude/zealous-turing-4afxvn
to
main
September 12, 2026 19:24
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #443 (the caller seam); retarget to
mainonce that merges.Delegation::Runner#generatebuilt the sub-agent with the parent's params and trace id but not its caller, soSupportHubAgent.as(user)delegating toTicketAgentran 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 throughparams:by hand to work around it.Change
The sub-agent gets the parent's
current_userbefore its action runs (inherit_actor), so its ownbefore_actioncallbacks and anySchemaToolsscope 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 onrespond_to?).Testing
test/authorization_test.rb(+2): a delegated run sees the parent's caller; a parent with no caller delegatesnil.bin/test test/authorization_test.rb test/delegation_test.rb— 12 runs, 20 assertions, 0 failures.bin/rubocopclean on the changed files.🤖 Generated with Claude Code
https://claude.ai/code/session_01XMSRnSxYS9mRx1hSjytB9Z