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
I’ll trace the team pause/continue flow, compare how run context is created and restored for normal runs versus resumed requirement runs, then patch the narrowest restoration point. I’ll inspect related tests and run targeted checks without modifying repository tests.
- Assistant
The defect is confirmed: team continuation builds a fresh
RunContextwithsession_state={}, and both member-routing paths callmember.acontinue_run()without passing the team context at all. Thus member tools cannot see either the resumed dependencies or session state. I’ll restore persisted run state when constructing the continuation context, expose an explicitsession_statecontinuation argument, and pass the context through both streaming and non-streaming member routes. - Assistant
The patch now covers both async routing modes and also the synchronous equivalents for consistency. I additionally made
session_statea first-classacon tinue_runargument, while preserving the existingdependenciesbehavior. The code compiles; I’m running the focused team continuation tests and checking the final diff for accidental API changes. - Assistant
Verification is complete: the focused 49-test team continuation suite passes, compilation succeeds, and
git diff --checkreports no whitespace errors. I also corrected an intermediate accidental sync-signature change so the public synchronous API remains unchanged; only async continuation gains the explicit state parameter. The final fix restores paused response state, supports explicit resumed state, and propagates the context into all member continuation paths.Implemented the fix for teamacontinue_runlosing dependencies and session state.Changes:
- Propagate
run_contextwhen continuing member agents, for both streaming and non-streaming paths. - Restore
session_statefrom the pausedTeamRunOutput. - Add an explicit
session_stateparameter to asyncTeam.acontinue_run. - Preserve explicit continuation state when provided.
- Keep synchronous continuation APIs unchanged.
- Propagate
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.