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
So run_context is passed to these functions already (as a parameter), but it's not forwarded to the
member.continue_run/member.acontinue_runcalls inside. Let's check all four functions and add run_context/dependencies/user_id/session_id passing to member calls.Assistant
Good, run_context is being passed in. Now let's fix the four functions to actually use run_context when calling member.continue_run/acontinue_run.
Assistant
Good,
RunContextalready imported anduuid4too. Now let's look at exact code blocks to modify (4 functions).Assistant
Now let's add a helper function before
_route_requirements_to_members:Assistant
Now let's update each of the 4 call sites to build member_run_context and pass it along.
Assistant
Now let's handle
_route_requirements_to_members_stream(sync streaming), around line 4993-5010.Assistant
Now the async non-streaming
_aroute_requirements_to_members:Assistant
Now the async streaming version
_aroute_requirements_to_members_stream— the one the issue explicitly references.Assistant
Good. Now let's verify the file compiles and check for syntax errors.
Assistant
Good, consistent with existing style (local import). Now let's view the whole helper function and the edited sections for sanity check.
Assistant
Now let's check the four modified call sites once more for correctness:
Assistant
Good. Now the other three:
Assistant
Good. Let's check the async ones similarly.
Assistant
All four call sites look correct. Now let's check the member.continue_run also handles Team members (not just Agent members) since team members can be nested Teams too.
Assistant
Good, Team.continue_run/acontinue_run supports run_context as well (routes to team's own continue_run_dispatch which accepts run_context). Now let's write a reproduction test script to validate the fix.
Assistant
Let's run the existing unit test suite for team continue_run to make sure nothing broke.
Assistant
All existing tests pass. Now let's write a reproduction script to test the actual fix end-to-end with a mocked model, to validate session_state propagation.
Assistant
This confirms the fix addresses the exact issue. Now let's run the broader test suite for agent/team modules to check nothing is broken.
Assistant
Confirmed pre-existing failures unrelated to our change. Now let's also run agent unit tests to make sure nothing broke there (since we didn't modify agent code, should be unaffected, but let's verify quickly).
Assistant
Same pre-existing unrelated failures. Good. Now let's clean up the temporary test file and view the final diff.
Assistant
Good — confirms
run_contextset at the top is threaded through the whole dispatch, including tool calls. The fix is consistent with the existing architecture. Let's also verify final content compiles cleanly and run full unit test suite once more.Assistant
All pass. Now let's review the checklist items.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.