Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· 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 to understand the codebase and locate the relevant files.

  3. Assistant

    Let me explore the structure more systematically.

  4. Assistant

    Let me explore the libs directory to find the agno package.

  5. Assistant

    Let me explore the agno package structure.

  6. Assistant

    Now let me look at the issue mentioned in the bug report - the _aroute_requirements_to_members_stream function in _run.py. Let me first check what line 5145 contains:

  7. Assistant

    Let me look at the function mentioned in the issue: _aroute_requirements_to_members_stream around line 5145.

  8. Assistant

    Let me see more context around this function. Let me search for the function name:

  9. Assistant

    Let me see the full function definition:

  10. Assistant

    Now let me look at the acontinue_run method in the Team class:

  11. Assistant

    Let me look at the acontinue_run method in team.py.

  12. Assistant

    Now let me look at acontinue_run_dispatch in _run.py:

  13. Assistant

    Let me check the acontinue_run_dispatch function.

  14. Assistant

    Let me see more of this function and then look at _acontinue_run_stream:

  15. Assistant

    Now let me look at _acontinue_run_stream:

  16. Assistant

    Let me look at the _acontinue_run_stream function.

  17. Assistant

    Let me look at the RunContext class to understand the structure:

  18. Assistant

    Let me check the RunContext class.

  19. Assistant

    Now let me look at how the initial arun handles session_state:

  20. Assistant

    Let me check the arun method to see how it handles session_state.

  21. Assistant

    Let me look at how arun_dispatch handles session_state:

  22. Assistant

    Let me check the arun_dispatch function.

  23. Assistant

    Now let me look at _aroute_requirements_to_members_stream more carefully to see how it calls member acontinue_run:

  24. Assistant

    Let me look at the member.acontinue_run() call in the function to see what parameters are being passed:

  25. Assistant

    Now I can see the issue! In _aroute_requirements_to_members_stream, when calling member.acontinue_run(), the run_context is not being passed. Let me also check the synchronous version:

  26. Assistant

    Let me check the synchronous version to see if it has the same issue:

  27. Assistant

    Now I can see the issue. In both _aroute_requirements_to_members_stream and _route_requirements_to_members_stream, when calling member.acontinue_run() or member.continue_run(), the run_context (which contains session_state and dependencies) is NOT being passed. Let me also check the non-streaming versions:

  28. Assistant

    Let me check the non-streaming versions too:

  29. Assistant

    Let me also check the async non-streaming version:

  30. Assistant

    Let me check the async non-streaming version:

  31. Assistant

    Now I understand the issue clearly. In all four _route_requirements_to_members* functions, when calling member.continue_run() or member.acontinue_run(), they don't pass run_context. This means that when the member agent executes a tool that needs access to session_state or dependencies, it won't have them. Let me also check the continue_run method signature in agent.py:

  32. Assistant

    Let me check the agent's continue_run method to see if it accepts run_context:

  33. Assistant

    Let me check the agent's acontinue_run method signature:

  34. Assistant

    Now I understand the issue! The run_context (which contains session_state and dependencies) is not being passed to the member agents when routing requirements. Let me also check the continue_run_dispatch for sync version:

  35. Assistant

    Let me also check the acontinue_run signature on the team:

  36. Assistant

    Now I have a clear picture of the issue. Let me also check if there's a session_state parameter on the team acontinue_run (the user example uses session_state):

  37. Assistant

    Now I need to understand the full picture. Let me also check how the initial arun sets up the session state and how it gets stored:

  38. Assistant

    Let me look at how adelegate_task_to_member passes context to member agents during normal runs:

  39. Assistant

    Let me find where adelegate_task_to_member is defined to see how it passes context.

  40. Assistant

    Let me search in the _task_tools.py file instead.

  41. Assistant

    Let me search more broadly.

  42. Assistant

    Let me look at adelegate_task_to_member to see how it passes dependencies/session_state:

  43. Assistant

    Now I can see the fix needed. In adelegate_task_to_member, the code properly passes run_context.session_state, run_context.dependencies, etc. to the member agent. But in _aroute_requirements_to_members_stream, the run_context is not being passed to member.acontinue_run().

    Let me now look at how acontinue_run_dispatch initializes the run_context when a session already exists (the session_state may need to be loaded from storage):

  44. Assistant

    Let me look at _asetup_session to understand how session_state is loaded:

  45. Assistant

    Now let me understand the flow. When acontinue_run_dispatch creates the RunContext, it sets session_state={}. But the user passes dependencies=session_state. The issue is that when routing to member agents in _aroute_requirements_to_members_stream, the run_context (which has dependencies and session_state) is NOT being passed. Let me verify this by looking at the acontinue_run_dispatch function more carefully:

  46. Assistant

    Let me also check how _acontinue_run_stream is called and how it uses run_context:

  47. Assistant

    Now I understand the complete picture. The issue is that in _aroute_requirements_to_members_stream (and its sync counterpart), the run_context (which contains session_state and dependencies) is NOT being passed to the member agent's acontinue_run() call. The run_context is properly passed to the function, but not forwarded to the member agent.

    Let me also check how this is done in the adelegate_task_to_member function to understand the correct pattern:

  48. Assistant

    Now I have a clear understanding of the issue. Let me create a simple test to verify the bug:

  49. Assistant

    The test confirms the issue. When _aroute_requirements_to_members_stream calls member.acontinue_run(), it does NOT pass run_context, dependencies, or session_state. This is the root cause of the bug.

    Now let me fix all four routing functions. I need to pass run_context to the member's continue_run()/acontinue_run() calls. Let me first fix the async streaming version:

  50. Assistant

    Now let me apply the fix. I'll edit _aroute_requirements_to_members_stream to pass run_context to member's acontinue_run():

  51. Assistant

    Now let me fix the first member.acontinue_run() call to pass run_context:

  52. Assistant

    Now let me fix the second member.acontinue_run() call (the else branch):

  53. Assistant

    Now I need to fix the sync streaming version _route_requirements_to_members_stream:

  54. Assistant

    Now let me fix the sync streaming version. First the run_response branch:

  55. Assistant

    Now let me fix the sync streaming version:

  56. Assistant

    Now I need to also fix the non-streaming versions. Let me look at _aroute_requirements_to_members (async non-streaming):

  57. Assistant

    Now let me fix the async non-streaming version. First the run_response branch:

  58. Assistant

    Now let me fix the async non-streaming version:

  59. Assistant

    Now I need to fix the sync non-streaming version _route_requirements_to_members:

  60. Assistant

    Now let me fix the sync non-streaming version:

  61. Assistant

    Now let me fix the sync non-streaming version:

  62. Assistant

    Now let me also check the acontinue_run_dispatch to see if we need to fix the session_state initialization there. Let me look at how session_state is handled:

  63. Assistant

    Let me look at the RunContext creation in acontinue_run_dispatch:

  64. Assistant

    Let me check how the session_state is handled in acontinue_run_dispatch. I need to look at the code that initializes the run_context there.

  65. Assistant

    Now I need to also look at the acontinue_run_dispatch function. I see that session_state={} is initialized as empty. This means that when a team run continues, the session state from the initial arun call isn't being loaded. Let me check how _asetup_session handles session state loading.

  66. Assistant

    Now let me run the test again to verify the fix:

  67. Assistant

    Let me fix the test script:

  68. Assistant

    Let me find the correct import path for RunOutput

  69. Assistant

    Let me fix the test script with the correct import.

  70. Assistant

    The async streaming fix is working. Now let me verify the sync streaming fix:

  71. Assistant

    Now let me verify the non-streaming async version:

  72. Assistant

    Now let me verify the sync non-streaming version:

  73. Assistant

    Now I need to also address the second part of the issue. Looking at acontinue_run_dispatch, I see that when run_context is created, session_state={}. But the user passes dependencies=session_state. This means that:

    1. run_context.session_state starts as {}
    2. run_context.dependencies gets set to the user's session_state dict
    3. When _asetup_session is called, it loads session_state from the database

    The issue is that the user's session_state dict is passed as dependencies, not as session_state. But the tool accesses run_context.session_state["user_token"]. Let me check if we also need to handle the session_state parameter in acontinue_run_dispatch:

  74. Assistant

    Now let me also check how the session_state is loaded in _asetup_session:

  75. Assistant

    Let me check how the session_state is loaded:

  76. Assistant

    Now let me check how _acontinue_run_stream calls _asetup_session and when _aroute_requirements_to_members_stream is called relative to it:

  77. Assistant

    Good, I can see that _asetup_session is called before _aroute_requirements_to_members_stream, which means the session_state should be loaded from the DB. But there might be a second issue - the user's session_state is passed as dependencies, not session_state. Let me also check if we need to handle the session_state parameter in acontinue_run_dispatch:

  78. Assistant

    Now I need to understand the second part of the issue. The acontinue_run method doesn't have a session_state parameter. Let me check if we need to add it:

  79. Assistant

    Now let me also check the _acontinue_run non-streaming version to see if it also routes to members:

  80. Assistant

    Let me check how _aroute_requirements_to_members is called to make sure it passes run_context:

  81. Assistant

    Let me also check the sync non-streaming call site:

  82. Assistant

    Let me check the call site for the sync non-streaming version:

  83. Assistant

    Good. Now let me run the existing tests to make sure my changes don't break anything:

  84. Assistant

    Let me find tests related to team or continue_run:

  85. Assistant

    Let me look for unit tests related to team or continue_run.

  86. Assistant

    Let me run the unit tests related to team continue_run:

  87. Assistant

    All tests pass. Let me also run the other team tests:

  88. Assistant

    The 2 failures are pre-existing and related to SQLite/Postgres DB configuration, not related to my changes. Let me also run the background stream test:

  89. Assistant

    Let me also check if there's a sync version of the streaming dispatch that needs fixing:

  90. Assistant

    Let me also check the sync continue_run_dispatch to see if it has the same session_state={} issue:

  91. Assistant

    Let me see how the sync continue_run_dispatch creates the RunContext:

  92. Assistant

    I see the sync version properly loads session_state from the DB. Now let me verify the final state of all the fixes I've made by looking at the git diff:

  93. Assistant

    Let me see the full diff to verify all the changes:

  94. Assistant

    The diff looks clean. Let me run the full unit test suite to ensure nothing is broken:

  95. Assistant

    The errors are due to missing dependencies, not my changes. Let me run just the team tests and agent tests to verify:

  96. Assistant

    All failures are pre-existing (DB configuration tests failing). Let me also run the workflow tests:

  97. Assistant

    Let me run the specific workflow HITL tests:

  98. Assistant

    The failures are all pre-existing - related to missing sqlalchemy module or DB config issues, not my changes. Let me clean up the temporary test files:

  99. Assistant

    Let me also check if there's a _acontinue_run_background_stream function that also needs the same fix:

  100. Assistant

    Let me check if the background stream function also routes to members:

  101. Assistant

    The background stream function calls _acontinue_run_stream, which in turn calls _aroute_requirements_to_members_stream. My fix covers this case.

    Now let me also check if there's an issue with the session_state not being loaded properly in the async path. Looking at the issue description again, the user mentions that the run_context has not been restored. Let me check if we need to also pass session_state through to acontinue_run_dispatch:

  102. Assistant

    The fix is complete. Let me now create a final comprehensive test to verify the fix:

  103. Assistant

    All tests pass. Let me clean up and run the existing tests one more time:

  104. Assistant

    All 55 tests pass. Let me now verify my checklist:

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