fix(runtime): resolve transfer_task caller from pinned session agent - #3893
Open
yangtuooc wants to merge 1 commit into
Open
fix(runtime): resolve transfer_task caller from pinned session agent#3893yangtuooc wants to merge 1 commit into
yangtuooc wants to merge 1 commit into
Conversation
transfer_task inside a background sub-session failed because handleTaskTransfer resolved the calling agent via CurrentAgent(), which returns the shared current-agent (the root coordinator) rather than the agent pinned to the sub-session. Background sub-sessions pin their agent (PinAgent) without mutating currentAgent, so a pipeline dispatched via run_background_agent could not delegate to its own sub-agents. Resolve the caller via resolveSessionAgent(sess), which returns the pinned agent when the session pins one and falls back to CurrentAgent otherwise. Adds a regression test reproducing the background delegation failure. Closes docker#3886
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.
What
Fixes
transfer_taskfailing inside arun_background_agentsub-session. See issue #3886.Problem
A coordinator (
root) fans out work viarun_background_agentto a composite agent (pipeline) that has its ownsub_agents(e.g.director). Whenpipelinecallstransfer_task(agent="director"), it fails with:The error names root as the caller even though the call originates from
pipeline, whose sub-agents do includedirector.Root cause
handleTaskTransferresolves the calling agent viar.CurrentAgent(), which returns the runtime's shared current-agent field. Background sub-sessions are created withPinAgent: true+WithAgentName(cfg.AgentName)(RunAgent→runCollecting), which pins the session topipelinebut deliberately does not mutatecurrentAgent(it staysroot). So validation runs againstroot.SubAgents() = [pipeline]and rejectsdirector.agentRouter.ResolveSessionalready handles pinned sessions ("when sess pins a specific agent (e.g. background agent tasks), that agent is returned directly"), buthandleTaskTransferwasn't using it.Fix
Resolve the caller via
resolveSessionAgent(sess)instead ofCurrentAgent(). This returns the pinned agent when the session pins one, and falls back toCurrentAgent()otherwise — so ordinarytransfer_taskbehavior is unchanged.Tests
Adds
TestHandleTaskTransfer_UsesPinnedSessionAgent: a session pinned topipeline(asrun_background_agentdoes) transfers todirectorwhile the runtime's current-agent isroot.go test ./pkg/runtime/passes.Closes #3886