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
Good, RunContext is already imported. Now let's add a helper function and modify the four routing functions.
Assistant
Not imported yet. Let's add the helper function and the
copyimport.Assistant
Need a blank line between the new function and
_route_requirements_to_members. Let me fix that.Assistant
Now let's update the two
member.continue_runcall sites in_route_requirements_to_membersto pass the built run_context.Assistant
The em dash is causing the mismatch likely due to some tool encoding issue. Let's use
seddirectly for this edit instead.Assistant
Now let's do the async versions. First find their current line numbers.
Assistant
Now the last one,
_aroute_requirements_to_members_stream.Assistant
This is exactly the block mentioned in the issue. Let's fix it using python replace (need to disambiguate from the sync version which is now already modified, so text differs slightly - "await member.acontinue_run" vs "member.acontinue_run" without await, and stream vs no stream).
Assistant
Now let's verify all four sites got updated correctly and check for syntax errors.
Assistant
All 4 sync/async, stream/non-stream sites updated (8 call sites total, 2 each). Let's check syntax validity.
Assistant
All pass. Now let's run the broader integration HITL tests for teams.
Assistant
Let me fix the reproduction script accordingly.
Assistant
Now update the repro script accordingly.
Assistant
Both stream and non-stream async routing functions now correctly propagate
session_stateanddependenciesviarun_context. Now let's also verify the sync versions (_route_requirements_to_members,_route_requirements_to_members_stream).Assistant
All four routing functions now correctly propagate
run_context(session_state, dependencies, metadata, knowledge_filters, user_id) to the member's continue_run call. Now let's run the full unit test suite for the team module to make sure nothing else broke.Assistant
All 414 unit tests pass. Now let's run broader agent unit tests too, since we touched shared logic minimally (only team/_run.py), but let's also check agent unit tests just for sanity, and clean up temp files.
Assistant
All good. Now let's clean up the temp scripts and review the diff.
Assistant
Unrelated missing dependency, not something we need to fix. Let's run the os test_team_runs.py.
Assistant
Confirmed this test fails independent of our changes (pre-existing environment issue). Our changes don't cause any regression. Let's finalize by reviewing the full diff once more.
Assistant
This diff resolves the issue cleanly. Let's run the full unit test suite once more, plus the specific test file for continue_run_requirements to make sure everything's still green.
Assistant
These are unrelated missing optional dependency modules (vectordbs etc.), not related to our change. Let's focus on team/agent related tests specifically, which we already confirmed pass.
Assistant
All relevant tests pass. Now let's go through the checklist.
Assistant
Summary
Root cause: When a team's
continue_run/acontinue_runroutes paused requirements back to a member agent (_route_requirements_to_members,_route_requirements_to_members_stream,_aroute_requirements_to_members,_aroute_requirements_to_members_streamin ), the calls to / never forwarded the team's (which carries , , , , ). This is inconsistent with the initial delegation path ( in ), which explicitly forwards a copy of , , etc. to the member. As a result, tools running inside a member agent after a HITL (confirmation/user-input) continuation saw / as (or stale defaults loaded from the member's own separately-keyed session), exactly as reported in the issue.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.