ISSUE DESCRIPTION [Bug] team.acontinuerun loss dependencies or sessionstate Description…
- User
ISSUE DESCRIPTION
[Bug] team.acontinue_run loss dependencies or session_state
Description
team.acontinue_run loss dependencies or session_state
Steps to Reproduce
requires_confirmation_tools = [ "group_del", "group_del_stock", ] async def group_del_stock(self, group_id: str, stock_list: list[dict], run_context: RunContext) -> Dict[str, Any]: url = f"{self.live_base_url}/cloud/api/optional/stock/code/del" headers = { "Content-Type": "application/json", "X-Access-Token": run_context.session_state["user_token"] } data = {"targetStockGroupId":group_id,"delVoList":stock_list}example code
session_id = str(uuid.uuid4()) user_id= '00bgh2' session_state = {"user_token":"Bearer "} asyncio.run(main()) async def main(): async for run_event in stock_team.arun( "将茅台从优质股中删除", stream=True, session_id=session_id, user_id=user_id, session_state=session_state ): from agno.run.team import RunPausedEvent as TeamRunPausedEvent # Use isinstance to check for team's pause event (not the member agent's) if isinstance(run_event, TeamRunPausedEvent): print("Team paused - requires confirmation") for req in run_event.active_requirements: if req.needs_confirmation: print(f" Tool: {req.tool_execution.tool_name}") print(f" Args: {req.tool_execution.tool_args}") req.confirm() # Use apprint_run_response for async streaming response = stock_team.acontinue_run( run_id=run_event.run_id, session_id=run_event.session_id, requirements=run_event.requirements, stream=True, user_id=user_id, dependencies=session_state, ) await pprint.apprint_run_response(response)Agent Configuration (if applicable)
No response
Expected Behavior
in group_del_stock, dependencies["user_token"] or session_state["user_token"] should be not None
Actual Behavior
dependencies["user_token"] or session_state["user_token"] is None
Screenshots or Logs (if applicable)
No response
Environment
agno=2.6.9Possible Solutions (optional)
in _aroute_requirements_to_members_stream, The run_context has not been restored https://github.com/agno-agi/agno/blob/55ba3edd1b4ea230afe8a3fcda39582f8a2178ad/libs/agno/agno/team/_run.py#L5145
Assistant
Let me start by understanding the repository structure and the issue. The issue is about
team.acontinue_runlosing dependencies or session_state. The user reports that when usingacontinue_run(async continue_run), thedependenciesorsession_stateare lost - they become None.The issue points to a specific location in the code: https://github.com/agno-agi/agno/blob/55ba3edd1b4ea230afe8a3fcda39582f8a2178ad/libs/agno/agno/team/_run.py#L5145
The suggestion is that in
_aroute_requirements_to_members_stream, therun_contexthas not been restored.Let me explore the repository structure first.
Assistant
Let me find the main agno library directory.
Assistant
The main library is at
/agno/libs/agno/agno. Let me find the team_run.pyfileAssistant
Let me look at the file around line 5145 as mentioned in the issue.
Assistant
Let me look at the area around line 5145.
Assistant
Let me try again with the open command.
Assistant
Now let me look at the
acontinue_runmethod signature in the agent or team.Assistant
Let me find the agent's acontinue_run method
Assistant
Let me find the Agent's acontinue_run.
Assistant
Let me look at the agent's acontinue_run signature
Assistant
Now I can see the issue clearly. The
_aroute_requirements_to_members_streamfunction callsmember.acontinue_runat lines 5171-5187 without passingdependenciesorrun_context. Let me look at how similar calls handle this elsewhereAssistant
Let me search for delegate patterns
Assistant
Let me search for the function that uses
member.acontinue_runelsewhereAssistant
Let me look at the non-streaming version around line 5069
Assistant
Let me try using bash instead.
Assistant
Let me look at how
_aroute_requirements_to_members_streamis calledAssistant
Let me look at the callers around those lines
Assistant
Let me look at the streaming caller at line 7068
Assistant
Now I can see the issue.
_aroute_requirements_to_members_streamreceivesrun_contextbut never passes it tomember.acontinue_run(). Same for the non-streaming version. Let me look at howrun_contextflows to the agent'sacontinue_runin the agent's_run.pyAssistant
Let me look at the
acontinue_run_dispatchfunction in agent/_run.pyAssistant
Let me look at that function
Assistant
Let me continue reading to see how
run_contextanddependenciesare handledAssistant
Let me understand how dependencies flow from Team to member agents. Let me look at how team delegates tasks to members
Assistant
Let me look around line 745
Assistant
Let me look at how team delegates tasks to members - how member.arun and member.acontinue_run are called
Assistant
Let me look at how member.arun is called to see what parameters are passed
Assistant
Let me search more broadly for how the team calls member run functions
Assistant
Let me look at how member delegation is handled - look for "delegate" in the team run file
Assistant
Let me look at how
delegate_task_to_membercalls the member to understand the proper patternAssistant
Let me search for where task delegation to member agents happens
Assistant
Let me look at the team tools file for member delegation
Assistant
Let me look at the team
_tools.pyfor how member delegation worksAssistant
Let me look at how members are resolved and how dependencies flow to them
Assistant
Let me search for these functions in the broader codebase
Assistant
Let me look at the callables utility
Assistant
Let me search for where member agents are actually invoked in the team code
Assistant
Let me look at where members are actually called - around line 1062
Assistant
Let me understand the
apply_to_contextmethod and howrun_contextis handledAssistant
Let me find the RunContext
Assistant
Let me look at the team's
_acontinue_runfunction to understand how run_context is builtAssistant
Let me look at how
acontinue_run_dispatchfor team builds the run_contextAssistant
Let me trace how member agents are invoked from the team. Let me search for where member.arun is actually called
Assistant
Let me look at how delegate functions pass dependencies/run_context to members
Assistant
Now I understand the issue. Let me look at how the member agent loads session_state in acontinue_run
Assistant
Let me look at the async agent run setup to understand session_state
Assistant
Let me look at the agent's
_acontinue_run_streamAssistant
Let me look at the agent's
_acontinue_run_streamAssistant
Let me check how
add_dependencies_to_contextworks and how dependencies relate to session_stateAssistant
Let me look at how
add_dependencies_to_contextis used in the message preparationAssistant
Let me look at
load_session_stateto understand how session_state is mergedAssistant
Let me look at load_session_state
Assistant
Let me look at
_initialize_session_stateto see if it merges dependencies into session_stateAssistant
Let me look at _initialize_session
Assistant
Let me look at how the agent handles pauses and if sessions are saved before pausing
Assistant
Let me look at the agent's run flow where it checks is_paused - around line 1634
Assistant
Let me look at
ahandle_agent_run_pausedAssistant
Let me search correctly
Assistant
Let me look at ahandle_agent_run_p
Assistant
Let me look at
acleanup_and_storeto confirm it saves the sessionAssistant
Let me look at acleanup_and_store
Assistant
Let me check
aread_or_create_sessionto understand how sessions are loadedAssistant
Let me look at aread_or_create
Assistant
Let me look at how
add_dependencies_to_contextworks in run messagesAssistant
Let me look at
aget_run_messagesto see how dependencies are added to contextAssistant
Let me look at
apply_to_contextmethodAssistant
Let me search for apply_to_context in the codebase
Assistant
Let me look at apply_to_context
Assistant
Now I have a thorough understanding of the issue. Let me create a script to reproduce it first.
Assistant
Now let me fix the code. I'll edit all four places where
member.acontinue_runis called without `dependenciesAssistant
Now let me fix all four places. First, the non-streaming version (lines 5069-5072):
Assistant
Let me use sed to make the edits
Assistant
Let me check the streaming version lines
Assistant
Now let me make the four edits. Starting with the non-streaming version
Assistant
Now the second non-streaming edit (originally 5078, now 5079 due to the first
Assistant
Let me verify the current line numbers
Assistant
Now the third edit (streaming version, first call)
Assistant
Fourth edit (streaming version, second call)
Assistant
Let me verify all edits
Assistant
All four edits look correct. Let me verify the fix
Assistant
Let me also check if there's a sync version with the same issue
Assistant
There are also sync versions. Let me check them
Assistant
Let me also check the sync streaming version and fix both
Assistant
Let me check the sync version's
continue_runsignature to confirm it acceptsdependenciesAssistant
Let me check the sync continue_run signature
Assistant
Let me fix the sync versions too. First let me find current line numbers
Assistant
Let me search more broadly for the sync continue_run
Assistant
Let me look at the context of the sync versions
Assistant
Now let me fix the sync versions too. Edit 1 at line 4872:
Assistant
Edit 2: second sync call, after line 4880 (shifted)
Assistant
Let me check current line numbers for sync streaming
Assistant
Let me check context around 4963 and 4972
Assistant
Edit 3: sync streaming first call, after line 4965
Assistant
Edit 4: sync streaming second call, after line 4976 (shifted
Assistant
Now let me verify all edits together
Assistant
Let me verify the full context around each edit
Assistant
I see one issue: the second sync call has dependencies before session_id instead of after. Let me fix this
Assistant
Let me fix this - remove line 4881 and reinsert after session_id
Assistant
I messed up the ordering. Let me fix this properly
Assistant
Let me fix this: remove the misplaced line and re-insert correctly
Assistant
Let me verify the sync edits now
Assistant
Now let me verify the async edits are still fine
Assistant
All edits look correct. Now let me run existing tests to make sure nothing is broken
Assistant
Let me run the most relevant tests
Assistant
Good. Let me run more relevant tests
Assistant
Let me also run the agent run regressions test
Assistant
Let me run the full team unit tests
Assistant
All tests pass except 2 pre-existing failures. Let me also check if there's a
session_stateparameter I should also handle. Let me look at theacontinue_runsignature more carefully to see ifsession_statecould also be passedAssistant
My fix correctly passes
dependenciesfrom the team'srun_contextto the member'sacontinue_run(). This ensures that when users callteam.acontinue_run(dependencies=...), those dependencies flow through to the member agents.Let me verify the final state of the changes with
git diffAssistant
Let me run the full team unit tests one more time to confirm nothing is
Assistant
All 412 tests pass. Let me also run the agent tests quickly
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.