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 issue. The bug is about
team.acontinue_runlosing dependencies or session_state. When a team run is paused (e.g., for confirmation), and then continued viaacontinue_run, therun_context.session_stateanddependenciesare lost/None.The issue points to a specific line in the codebase: https://github.com/agno-agi/agno/blob/55ba3edd1b4ea230afe8a3fcda39582f8a2178ad/libs/agno/agno/team/_run.py#L5145
This is in
_aroute_requirements_to_members_streamfunction, where the run_context has not been restored.Let me explore the codebase first.
Assistant
Let me explore the structure, particularly looking for the file mentioned in the issue.
Assistant
Let me find the specific file mentioned in the issue
Assistant
Let me look at the file around line 5145 mentioned in the issue.
Assistant
Let's look at the function
_aroute_requirements_to_members_streamaround line 5145.Assistant
Let me try again with a different approach.
Assistant
Let me look at the function starting at line 5110 to understand the issue
Assistant
Now I can see the issue. When
_aroute_requirements_to_members_streamcallsmember.acontinue_run, it passessession_idbut does NOT passdependenciesorsession_state. Let me look at howacontinue_runis defined on the member agentAssistant
Let me look at the agent's
acontinue_runsignature and the team'sacontinue_runto understand the full parameterAssistant
Let me look at the team's
acontinue_rundefinitionAssistant
Now let me look at the
acontinue_run_dispatchin team/_run.py to see how dependencies and session_state are passed through the call chain.Assistant
Let me look at
_acontinue_run_streamto see how it calls_aroute_requirements_to_members_stream.Assistant
Let me look at
_acontinue_run_streamstarting at line 6953.Assistant
Let me look at the agent's
acontinue_run_dispatchto see how it handles the missing dependencies.Assistant
Let me check if there's a corresponding non-streaming function and also look at how the
run_contextflows.Assistant
Let me look at the non-streaming version too.
Assistant
Let me understand how the tool receives
run_context- let me look at how tools are invoked and how the run context flows to them.Assistant
Let me look at how tools receive
run_context, particularly how they getsession_stateanddependencies.Assistant
Let me look at how tools get the
run_contextduring execution.Assistant
Let me search for where tool execution happens with run_context.
Assistant
Let me search for where tools are called with run_context.
Assistant
Let me look for the tool execution mechanism.
Assistant
Let me check how
session_stateflows througharunand into the run_context in the team's_arunor related functions.Assistant
Let me check how
_asetup_sessionloads session_state.Assistant
Let me look at
_asetup_sessionto understand how session_state is handled.Assistant
Now I have a clear understanding of the issue. Let me verify by looking at the exact lines where
member.acontinue_runis called in both functionsAssistant
Now let me look at the streaming version's call sites
Assistant
Let me also check the initial delegation function
adelegate_task_to_memberto see if it has the same issue.Assistant
Let me search for the actual delegation function that calls
member.arunwith dependencies.Assistant
Let me check the delegation flow to see how dependencies are passed in
adelegate_task_to_member.Assistant
Let me check how the agent handles dependencies in its run - whether they get merged into session_state.
Assistant
Let me check how the agent's
_acontinue_run_streamhandles dependencies and session_state.Assistant
Let me look at the agent's
_acontinue_run_streamto see how it handles dependencies.Assistant
Now I have a thorough understanding of the bug. Let me implement the fix. The issue is that in both
_aroute_requirements_to_membersand_aroute_requirements_to_members_stream, the calls tomember.acontinue_rundon't passdependenciesfrom the team'srun_context. Compare this toadelegate_task_to_memberwhich correctly passes bothdependencies=run_context.dependenciesandsession_state=member_session_state_copy.Let me fix both functions.
First, let me fix
_aroute_requirements_to_members(non-streamAssistant
Now let me fix the non-streaming function
_aroute_requirements_to_membersAssistant
Let me open the file first and then make the edits.
Assistant
Now let me fix the first call in the non-streaming function:
Assistant
Let me use sed to make the edits instead
Assistant
Let me try using the edit command with line numbers.
Assistant
Now fix the second call in the non-streaming function
Assistant
Now let me fix the streaming function. Let me look at the current lines.
Assistant
Now fix the first call in the streaming function
Assistant
There's a duplicate closing paren on line 5180. Let me fix that.
Assistant
Remove the extra closing paren
Assistant
There's a duplicate
else:on lines 5180-5181. Let me fix that.Assistant
Fix the duplicate
member_run_idline.Assistant
Let me fix the duplicate
member_response_streamline.Assistant
Let me fix this with a larger block replacement to clean everything up
Assistant
The block is missing the
if isinstance(...)lines. Let me fix this properly.Assistant
Let me verify the full streaming function now looks correct.
Assistant
The streaming function looks correct now. Let me also verify the non-streaming function.
Assistant
Let me check if there are synchronous versions that also need fixing.
Assistant
Let me check the synchronous versions too.
Assistant
Let me check the sync streaming version too.
Assistant
Let me fix the synchronous versions too. First, the non-streaming sync version.
Assistant
Now fix the sync non-streaming version.
Assistant
Now fix the sync streaming version.
Assistant
Fix the sync streaming version.
Assistant
There's an extra
)on line 4981. Let me fix itAssistant
Fix the duplicate comment line.
Assistant
Fix duplicate
for eventlines.Assistant
Let me verify the sync streaming function is correct now.
Assistant
Let me verify the agent's
continue_runacceptsdependenciesparameter.Assistant
Let me run the grep on the correct file
Assistant
Let me check the
continue_runsignature.Assistant
The
continue_runandacontinue_runboth acceptdependencies. Let me verify the Python syntax is correctAssistant
Syntax is correct. Let me verify all changes with
git diff.Assistant
The diff looks clean. Let me now run any existing tests to make sure nothing is broken
Assistant
Let me check the team dependencies test.
Assistant
Let me check if there are HITL/approval related tests.
Assistant
Let me look at the team confirmation flows test which is likely the most relevant.
Assistant
Let me check the unit tests for continue_run to see if there are dependency-specific tests
Assistant
Let me also check if there's anything else I need to consider. Let me look at the
_acontinue_runfunction to see how it handles the routing and if there are additional places where dependencies might be lost.Assistant
Let me verify the sync path also passes
run_contextto the routing functions.Assistant
Let me verify the calls at lines 5517 and 5527 pass
run_context.Assistant
The fix is complete. Let me do a final syntax check and submit
Assistant
Let me do a final review of the diff before submitting.
Assistant
The changes look correct and clean. Let me submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.