Skip to content
TheChatArchiveThe Chat Archive
x-ai/grok-4.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION [Bug] team.acontinuerun loss dependencies or sessionstate Description…

  1. User

    ISSUE DESCRIPTION

    [Bug] team.acontinue_run loss dependencies or session_state

    Description

    team.acontinue_run loss dependencies or session_state

    Steps to Reproduce

    requires_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

    session_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)
    

    Agent Configuration (if applicable)

    No response

    Expected Behavior

    in group_del_stock, dependencies["user_token"] or session_state["user_token"] should be not None

    Actual Behavior

    dependencies["user_token"] or session_state["user_token"] is None

    Screenshots or Logs (if applicable)

    No response

    Environment

    agno=2.6.9
    

    Possible Solutions (optional)

    in _aroute_requirements_to_members_stream, The run_context has not been restored https://github.com/agno-agi/agno/blob/55ba3edd1b4ea230afe8a3fcda39582f8a2178ad/libs/agno/agno/team/_run.py#L5145

    Additional Context

    No response

    Interface

    No new interfaces are introduced.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /agno, current file: none) bash-$

  2. Assistant

    I'll start by exploring the repository structure and the code path mentioned in the issue around _aroute_requirements_to_members_stream and acontinue_run.

  3. Assistant

    Let me look at the specific file mentioned in the issue and search for acontinue_run related code.

  4. Assistant

    rg is not available, let me use grep instead.

  5. Assistant

    Let me search for acontinue_run and the specific function mentioned around line 5145.

  6. Assistant

    Let me examine _aroute_requirements_to_members_stream and related functions.

  7. Assistant

    Comparing with non-stream routing and how members receive run_context.

  8. Assistant

    Checking agent continue_run signatures and how run_context is restored.

  9. Assistant

    Let me look at the agent acontinue_run and how team's acontinue_run passes things. Also looking at how team's acontinue_run handles session_state and dependencies.

  10. Assistant

    Looking at how team's acontinue_run sets up run_context and whether it gets passed to routing.

  11. Assistant

    Checking team's acontinue_run signature and how session_state is handled in continue flow.

  12. Assistant

    Checking how member agents receive run_context during normal runs vs continue.

  13. Assistant

    Let me look at how members are called during regular arun/run (delegate), specifically for passing session_state.

  14. Assistant

    Hmm, the _tools.py might delegate through a different mechanism. Let me search more broadly.

  15. Assistant

    Inspecting how member runs get session_state, and comparing continue_run paths.

  16. Assistant

    Looking at how _acontinue_run and _acontinue_run_stream load session state.

  17. Assistant

    Let me continue reading to see where _aroute_requirements is called and how session_state is loaded in _asetup_session.

  18. Assistant

    Checking how agent's acontinue_run uses run_context and session_state.

  19. Assistant

    Let me look at agent acontinue_run_dispatch

  20. Assistant

    Let me continue reading acontinue_run_dispatch for how run_context is built

  21. Assistant

    Understanding how member agents share session state with the team.

  22. Assistant

    Checking related tests and git history for previous similar fixes.

  23. Assistant

    Let me look at unit tests for continue_run_requirements and also check git blame around the routing functions. Also check if agent version of continue from team members handled this before.

  24. Assistant

    Let me read the routing tests in this unit test file.

  25. Assistant

    Let me look at TestAsyncGatherErrorHandling and also the code around line where website run_context is passed to refresh/determine tools etc in continue_run path.

  26. Assistant

    Checking if continuing members merges session_state back and how cerrado similar agent-level codelooks.

  27. Assistant

    Checking the RunContext class structure.

  28. Assistant

    Let me read the RunContext class

  29. Assistant

    Looking at how session_state is typically shared - delegates use copy(run_context.session_state) and then merge back. For continue without merge back, sharing the same dict might actually be better ...

  30. Assistant

    Checking whether session_state is persisted when the team pauses.

  31. Assistant

    Let me read the pause handlers to see if run_context.session_state is saved.

  32. Assistant

    Let me check cleanup_and_store for how session_state is saved.

  33. Assistant

    Also looking at continue_run_dispatch around line 5404 for how it sets up run_context:

  34. Assistant

    Checking if in-memory sessions are cleared on initialize_team.

  35. Assistant

    Let me check read_or_create_session without DB.

  36. Assistant

    Checking how agent continue registers runs.

  37. Assistant

    Checking _initialize_session_state to understand run_id usage.

  38. Assistant

    I'll implement the fix across all four routing functions by passing run_context into member continue calls.

  39. Assistant

    I'll create a helper function to build member run_context的, and use it in all four places. Or simply pass run_context and dependencies. I understand the issue you're facing with team.acontinue_run losing dependencies or session_state in member tools. The problem stems from how RunContext is restored in _aroute_requirements_to_members_stream (and similar methods), where the session state isn't properly propagated to member agents.

    To fix this, I'll implement a helper function to build the RunContext for members, ensuring dependencies and session_state are preserved. I'll also update the calls to acontinue_run to pass the run_context correctly.

    Here's the plan: 1.

  40. Assistant

    Now I'll implement the fix by adding a helper and updating all four routing functions.

  41. Assistant

    Adding a helper and updating all four route functions to pass restored run_context.

  42. Assistant

    Updating _route_requirements_to_members to pass the member run context.

  43. Assistant

    Updating the sync streaming route function.

  44. Assistant

    I'll update the stream version now.

  45. Assistant

    Updating the async non-streaming route function.

  46. Assistant

    Update _aroute_requirements_to_members

  47. Assistant

    Removing the duplicate comment and updating the async stream function.

  48. Assistant

    Updating the async stream routing function next.

  49. Assistant

    Update _aroute_requirements_to_members_stream

  50. Assistant

    I should also check if acontinue_run_dispatch properly loads session_state. Looking at earlier code - it starts with empty session_state and relies on _asetup_session. That's fine for when user had se...I think the core issue is that acontinue_run (and the underlying dispatch) doesn't properly restore session_state from the team's persisted context when the user passes dependencies=session_state as a workaround. The tool code expects run_context.session_state["user_token"], but the streaming path loses the team session's session_state after the pause (especially without DB, or even with DB if _cached_session is cleared).

  51. Assistant

    Interesting - looking at my earlier grep result:

  52. Assistant

    Let me check line 402 in _init.py

  53. Assistant

    Writing a temporary script to verify that run_context is forwarded, and running related unit tests.

  54. Assistant

    Running unit tests for continue_run requirements.

  55. Assistant

    Checking whether agent cleanup strips transient keys from the shared session_state.

  56. Assistant

    The path might be different - list dir

  57. Assistant

    I'm in libs/agno already.

  58. Assistant

    Updating the helper to copy session_state like delegate does, and merging back after member continue.

  59. Assistant

    Need full path or relative from cwd.

  60. Assistant

    Using a session_state copy per member (required for concurrent async) and merging changes back after continue.

  61. Assistant

    Confirming merge_dictionaries import path, then adding merge calls after each member continue.

  62. Assistant

    Adding merge-after-continue in all four route functions.

  63. Assistant

    Let me update each function carefully to merge after continue.

  64. Assistant

    I'll add merge after member_response_handling and before.clear for all 4.

  65. Assistant

    Now stream version - after the stream loop and_before clear.

  66. Assistant

    Add merge to stream version

  67. Assistant

    There's a duplicate ) on line 5068 - I made an error when editing. Let me fix that.

  68. Assistant

    Good. Now fix async non-stream version.

  69. Assistant

    Add merge for async non-stream and async stream

  70. Assistant

    Now async stream version.

  71. Assistant

    Add merge for async stream

  72. Assistant

    Re-running verification and unit tests.

  73. Assistant

    Verifying None run_context still works, then reviewing the final diff.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.