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
pythonrequires_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
pythonsession_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) Assistant
Let me analyze the issue:
- The bug is about
team.acontinue_runlosing dependencies or session_state - When using
acontinue_runafter a paused event, thesession_state(passed asdependencies) is not being restored in therun_context - The user points to a specific location in the code:
libs/agno/agno/team/_run.pyaround line 5145, in the_aroute_requirements_to_members_streamfunction
Let me start by exploring the repository structure and finding the relevant code.
- The bug is about
Assistant
Let me explore the repository structure and find the file mentioned in the issue.
Assistant
The file is quite large. Let me look at the specific line mentioned in the issue (around line 5145).
Assistant
Now I can see the
_aroute_requirements_to_members_streamfunction. The issue is that when callingmember.acontinue_run(), it doesn't passdependenciesorrun_context. Let me look at theacontinue_runmethod for member agents to understand what parameters it accepts.Assistant
Now I can see that
member.acontinue_run()acceptsdependenciesandrun_contextparameters. Let me look back at the_aroute_requirements_to_members_streamfunction to see that it's NOT passing these parameters.Assistant
I see the issue now. The
_aroute_requirements_to_members_streamfunction receivesrun_contextas a parameter, but it's not passing it tomember.acontinue_run(). Let me also check the non-streaming version to see if it has the same issue.Assistant
Now I see the pattern. There are multiple functions that route requirements to members:
_route_requirements_to_members(sync, non-streaming) - line 4810_route_requirements_to_members_stream(sync, streaming) - line 4903_aroute_requirements_to_members_stream(async, streaming) - line 5110
All of them receive
run_contextas a parameter but none of them pass it to the member'scontinue_run()oracontinue_run()call.Let me also check the sync streaming version:
Assistant
Now I can see there are four routing functions that have the same issue - they all receive
run_contextbut don't pass it to the member'scontinue_run()oracontinue_run()calls:_route_requirements_to_members(sync, non-streaming) - lines 4810-4901_route_requirements_to_members_stream(sync, streaming) - lines 4903-5009_aroute_requirements_to_members(async, non-streaming) - lines 5012-5108_aroute_requirements_to_members_stream(async, streaming) - lines 5110-5224
Let me check what
run_contextcontains - specifically looking at theRunContextclass:Assistant
Now I understand the issue. The
RunContextcontains bothdependenciesandsession_state, and when callingmember.acontinue_run()in the routing functions, therun_contextis not being passed. This means the member agent doesn't have access to these values.Let me now fix all four routing functions by passing
run_contextto the member'scontinue_run()oracontinue_run()calls.Assistant
The open command doesn't support line_number as a named argument. Let me try a different format.
Assistant
Now I can see the first function that needs fixing. Let me fix all four functions. I'll need to add
run_context=run_contextto eachcontinue_run()oracontinue_run()call.Let me fix them one by one:
1. Fix
_route_requirements_to_members(sync, non-streaming)Assistant
I made a mistake with the edit command syntax. The line range and replacement text need to be separate arguments, not combined. Let me fix the syntax.
Assistant
Now I need to fix the sync streaming function
_route_requirements_to_members_stream. Let me fix the twocontinue_runcalls on lines 4963-4979:Assistant
Now fix the second continue_run call in the sync streaming function:
Assistant
Now let me fix the third function
_aroute_requirements_to_members(async, non-streaming):Assistant
Now let me fix the fourth and final function
_aroute_requirements_to_members_stream(async, streaming):Assistant
I need to fix the two
acontinue_runcalls in_aroute_requirements_to_members_streamfunction. The first one is at lines 5177-5183 and the second one is at lines 5185-5192.Assistant
Now let me fix the second
acontinue_runcall in the same function:Assistant
All four routing functions have been fixed. Let me verify all my changes by looking at the git diff:
Assistant
The diff shows exactly the changes I intended:
_route_requirements_to_members(sync, non-streaming): Addedrun_context=run_contextto bothcontinue_run()calls (lines 4873 and 4882)_route_requirements_to_members_stream(sync, streaming): Addedrun_context=run_contextto bothcontinue_run()calls (lines 4969 and 4980)_aroute_requirements_to_members(async, non-streaming): Addedrun_context=run_contextto bothacontinue_run()calls (lines 5076 and 5084)_aroute_requirements_to_members_stream(async, streaming): Addedrun_context=run_contextto bothacontinue_run()calls (lines 5183 and 5194)
Now let me verify the existing tests pass. First, let me find relevant tests:
Assistant
Empty message to preserve thinking density.
Assistant
Let me run the relevant unit tests to make sure my changes don't break anything.
Assistant
I made a mistake with the edit command syntax. The line range and replacement text need to be properly formatted. Let me fix it.
Assistant
All 49 tests passed. Let me also run a few more related unit tests:
Assistant
The 2 failing tests are related to missing database dependencies (sqlite, postgres), not my changes. Let me run more specific tests related to the team continue_run functionality:
Assistant
All tests pass. Let me also look for any tests that specifically test the routing functions I modified:
Assistant
The tests don't directly test the routing functions but they do test the related functionality and they pass. Let me also run a quick syntax check on the file to make sure there are no issues:
Assistant
Now let me verify my changes are correct by reviewing the final diff one more time:
Assistant
I made a mistake with the edit command syntax. Let me fix it properly.
Assistant
All 8 member run calls (2 per function × 4 functions) now have
run_context=run_contextpassed. My changes are correct and complete.Let me verify by checking one of the fixed blocks:
Assistant
Let me properly submit the changes or continue verifying.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.