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 start by exploring the repository structure and the code path mentioned in the issue around
_aroute_requirements_to_members_streamandacontinue_run. - Assistant
Let me examine the relevant code around the mentioned line and how
acontinue_runrestores run context. - Assistant
rg is not found, let me use grep instead.
- Assistant
Let me look more specifically at acontinue_run and continue_run functions, and the route requirements code.
- Assistant
Let me search for continue_run specifically.
- Assistant
Need to use recursive correctly
- Assistant
I'll read the routing and acontinue_run code paths to see how
run_contextis restored. - Assistant
The member
acontinue_runcall is missing run context/deps — I'll compare how the other route variants and agent continue_run handle that. - Assistant
I'll inspect team and agent continue_run setups to see where session_state and dependencies should be wired through.
- Assistant
Interesting - in acontinue_run_dispatch, session_state is initialized as
{}if not from run_context. The user's example passesdependencies=session_statenotsession_state. Let me look at more o... - Assistant
I'll inspect
_acontinue_run/_acontinue_run_streamfor session restore and compare them to the agent side. - Assistant
Let me continue reading to see how member routing is done and whether run_context is passed.
- Assistant
I'll next compare how agents restore run_context and session_state during continue_run.
- Assistant
I'll inspect
_asetup_sessionand how session_state is persisted, then check related tests. - Assistant
I'll search for existing tests and how members receive session_state/dependencies during delegate and continue flows.
- Assistant
Let me look at the full
_aroute_requirements_to_membersand also how members are typically called with session_state during delegate. - Assistant
Confirmed - none of the member.acontinue_run / continue_run calls pass session_state, dependencies, or run_context.
- Assistant
Let me look at how delegate_task_to_member passes session_state and dependencies.
- Assistant
So when delegating, members get
session_state=member_session_state_copy. But continue_run does not pass session_state. - Assistant
There's a discrepancy - the grep showed delegate functions at line 538 but when I open the file it ends at 623 with the find member methods. The _tools.py might be different - perhaps the delegate cod...
- Assistant
It's in _default_tools.py
- Assistant
I'll check the public continue_run APIs and whether session_state is accepted (and if agent continue_run already forwards it).
- Assistant
I'll check how session_state is saved on pause and whether agent continue_run accepts session_state.
- Assistant
Let me look at agent continue_run_dispatch for session_state parameter
- Assistant
Agent and team continue_run accept run_context and dependencies, but not session_state as a top-level arg. So when routing, we could pass run_context, or pass session_state via... wait, kwargs might w...
- Assistant
Interesting - agent continue_run always loads session_state from the agent session DB with empty initial state. For team members, they typically share the team's session. Let me check how agent sessio...
- Assistant
If we pass run_context with session_state into member.acontinue_run, it should merge correctly — I'll verify that in
load_session_state. - Assistant
For team members without their own DB, agent_session is in-memory and likely empty session_state. So we need to pass the session_state from the team run_context.
- Assistant
_cleanup_and_storeshould save session_state. When continuing,_asetup_sessionshould restore it to the team's run_context. Then we need to pass it to members. - Assistant
I'll inspect agent
acontinue_run_dispatchand whethersession_statecan be supplied via kwargs. - Assistant
Let me continue reading how run_context is built
- Assistant
I'll review the continue_run unit tests and check for any recent related git history or open PRs.
- Assistant
There's a relevant commit that may have fixed agent but not team continue routing — I'll inspect it.
- Assistant
I'll inspect
_load_session_stateand how in-memory team sessions behave without a DB. - Assistant
I'll check whether
initialize_teamclears the session cache and what happens when saving without a DB. - Assistant
I'll check async agent continue for session_state loading and whether sharing the team run_context is safe.
- Assistant
I'll also check whether paused TeamRunOutput retains session_state and how continue_run of the team initializes.
- Assistant
I'll look at the full streaming route function and how member session_state is merged after continue, then implement the fix.
- Assistant
I'll implement a helper to forward session_state/dependencies into member continue_run, then update all four routing functions.
- Assistant
Let me check the imports at the top of _run.py for RunContext and copy, merge_dictionaries.
- Assistant
I'll add a helper and wire it into all four route functions so members get session_state and dependencies.
- Assistant
I'll fix the blank line and update
_route_requirements_to_membersto forward run context. - Assistant
I introduced a duplicate line — fixing that and updating the continue_run call sites next.
- Assistant
I may have broken the else branch — checking the current state carefully.
- Assistant
Restoring the missing
session.upsert_runand finishing the first function fix. - Assistant
Updating the sync streaming route next.
- Assistant
Now update the stream function.
- Assistant
Now update the async non-streaming routing function.
- Assistant
Update async non-stream
- Assistant
I'll fix that comment and update the async stream route next.
- Assistant
Now updating the async stream version mentioned in the issue.
- Assistant
Update the async stream version.
- Assistant
I'll verify
merge_dictionariesimport path and check for any similar agent-side routing. - Assistant
I'll write a temporary script to verify members receive session_state and dependencies on continue.
- Assistant
Need to fix the patch path only.
- Assistant
All our fix tests passed. Next I'll run the existing continue_run unit tests.
- Assistant
I'll check whether pause events carry session_state and whether continue_run can restore it from run_response.
- Assistant
Weird path issue
- Assistant
We're still in libs/agno from the previous cd
- Assistant
I'll seed session_state from the paused run_response in both continue_run dispatch paths.
- Assistant
Let me look at acontinue run_context init again
- Assistant
I'll review the full diff to ensure the change is clean and complete.
- Assistant
The change looks complete. Cleaning up temp files and submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.