Skip to content
TheChatArchiveThe Chat Archive
MiniMaxminimax/minimax-m3· 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. MiniMax Assistant

    Let me start by exploring the repository structure to understand the codebase.

  3. MiniMax Assistant

    Now let me look at the _acontinue_run_stream function to see the full context and where run_context is created:

  4. MiniMax Assistant

    Now let me look at the acontinue_run_dispatch function to understand how the run_context is initialized:

  5. MiniMax Assistant

    Now let me look at the _asetup_session function to understand how the run_context is used:

  6. MiniMax Assistant

    Now let me find the corresponding sync version continue_run_dispatch to see how it correctly handles this:

  7. MiniMax Assistant

    Now let me look at how the continue_run_dispatch passes the run_context:

  8. MiniMax Assistant

    Now let me understand the issue. The user reported that in _aroute_requirements_to_members_stream, the run_context is not being passed properly. Let me look at the original arun and arun_stream for comparison:

  9. MiniMax Assistant

    Now I can see how adelegate_task_to_member correctly passes session_state, dependencies, etc. to the member_agent.arun(...) call. Let me look at the _aroute_requirements_to_members_stream again carefully:

  10. MiniMax Assistant

    Now let me check the acontinue_run method on the agent to see how it can accept dependencies, session_state, etc.:

  11. MiniMax Assistant

    Now I understand. The acontinue_run method on a member agent accepts run_context as a parameter. So the issue is in _aroute_requirements_to_members_stream and _aroute_requirements_to_members (also probably the sync version) where run_context is not being passed to member.acontinue_run(...).

    Let me also check the sync version's continue_run method to confirm:

  12. MiniMax Assistant

    Now let me see how the agent's arun correctly passes dependencies. Let me look at the agent's run method (which would be the equivalent for non-HITL flow):

  13. MiniMax Assistant

    Now I understand. The arun calls do pass session_state and dependencies from the run_context, but the acontinue_run calls in _aroute_requirements_to_members_stream and _route_requirements_to_members_stream (and probably sync versions too) do not.

    Let me look at the sync version _route_requirements_to_members_stream more carefully:

  14. MiniMax Assistant

    Now let me also look at the non-streaming version _route_requirements_to_members:

  15. MiniMax Assistant

    Now let me also check the async non-streaming version _aroute_requirements_to_members:

  16. MiniMax Assistant

    Now I see the pattern. In _aroute_requirements_to_members_stream, _aroute_requirements_to_members, _route_requirements_to_members, and _route_requirements_to_members_stream, the call to member.continue_run() / member.acontinue_run() does NOT pass the run_context.

    The fix should pass run_context to these calls. Let me first verify the agent's acontinue_run method accepts run_context:

  17. MiniMax Assistant

    Now let me check the agent's arun to see how it uses run_context:

  18. MiniMax Assistant

    Good, the arun_dispatch of agent also supports passing run_context. Now let me also check how _propagate_member_pause works and how _aroute_requirements_to_members_stream should pass the run_context. First, let me understand the flow better by looking at a few more functions:

  19. MiniMax Assistant

    Now let me reproduce the issue first to understand it better. Let me first look at the existing tests to understand patterns:

  20. MiniMax Assistant

    Let me see the actual run.py content to understand what _aroute_requirements_to_members_stream does and how run_context is needed. Let me also see what agent.acontinue_run does with run_context:

  21. MiniMax Assistant

    Now I understand. The agent's _acontinue_run_stream uses run_context to know about session_state and dependencies. So when we call member.acontinue_run(...) from _aroute_requirements_to_members_stream and don't pass the run_context, the agent's acontinue_run_dispatch will create a new run_context with empty session state and dependencies.

    Let me also check acontinue_run_dispatch once more:

  22. MiniMax Assistant

    Good. Now I have full clarity. The fix is to pass run_context to the member.continue_run / member.acontinue_run calls in:

    1. _route_requirements_to_members (sync, non-streaming)
    2. _route_requirements_to_members_stream (sync, streaming)
    3. _aroute_requirements_to_members (async, non-streaming)
    4. _aroute_requirements_to_members_stream (async, streaming)

    Now let me reproduce the issue first. Let me set up a simple reproduction:

  23. MiniMax Assistant

    Now let me write a reproduction script:

  24. MiniMax Assistant

    Now let me look at the existing tests for confirmation flows to understand the test pattern:

  25. MiniMax Assistant

    Let me look for tests of _aroute_requirements_to_members or similar:

  26. MiniMax Assistant

    Now let me create a small reproduction script to confirm the issue:

  27. MiniMax Assistant

    It's imported locally. Let me update the script:

  28. MiniMax Assistant

    I need to make the mock return an async iterator, not a coroutine. Let me fix:

  29. MiniMax Assistant

    I've reproduced the issue. The member.acontinue_run call is not receiving the run_context. Now let me fix the code. I need to pass the run_context to all 4 functions:

    1. _route_requirements_to_members (sync, non-streaming)
    2. _route_requirements_to_members_stream (sync, streaming)
    3. _aroute_requirements_to_members (async, non-streaming)
    4. _aroute_requirements_to_members_stream (async, streaming)

    Let me start by applying the fix to _aroute_requirements_to_members_stream:

  30. MiniMax Assistant

    Now let me see how the existing arun() pattern works (which DOES pass session_state, dependencies):

  31. MiniMax Assistant

    Now let me apply the fix. The cleanest approach is to pass run_context to member.acontinue_run(). Let me start with _aroute_requirements_to_members_stream:

  32. MiniMax Assistant

    Now let me apply the fix. I'll add run_context=run_context to both calls in _aroute_requirements_to_members_stream:

  33. MiniMax Assistant

    Now let me apply the fix to _aroute_requirements_to_members_stream:

  34. MiniMax Assistant

    Now let me apply the same fix to the async non-streaming version _aroute_requirements_to_members:

  35. MiniMax Assistant

    Now let me apply the same fix to the sync versions:

  36. MiniMax Assistant

    Now let me apply the fix to the sync streaming version _route_requirements_to_members_stream:

  37. MiniMax Assistant

    Now let me verify all the changes:

  38. MiniMax Assistant

    Let me verify each one of these has run_context=run_context:

  39. MiniMax Assistant

    All 8 calls now have run_context=run_context. Now let me run the reproduction script to confirm the fix:

  40. MiniMax Assistant

    The fix is working. Now let me write a more comprehensive test to verify all 4 routing functions pass the run_context:

  41. MiniMax Assistant

    I need to be more careful with the mock. The acontinue_run should not be a coroutine but should return either a coroutine (for non-streaming) or an async iterator (for streaming). Let me fix the test:

  42. MiniMax Assistant

    The issue is that the async_continue_run returns a coroutine for stream=True case (because of the inner function). Let me simplify:

  43. MiniMax Assistant

    It seems my test is only catching the sync version's calls. Let me investigate why my mock wasn't called by the async versions:

  44. MiniMax Assistant

    The fix works correctly for _aroute_requirements_to_members_stream. The earlier test issue was the mock construction - the issue is that when I do member.acontinue_run = make_async_continue_run(captured_kwargs_list), the function returns a coroutine (since it has await). But for streaming, the function should return an async iterator. Let me run a cleaner test:

  45. MiniMax Assistant

    The issue is that acontinue_run for streaming returns a coroutine containing the async iterator. Let me look at how acontinue_run is defined for streaming. Looking back at the _aroute_requirements_to_members_stream code, the call is:

    member_response_stream = member.acontinue_run(...)
    async for event in member_response_stream:
    

    So when member.acontinue_run() is called with stream=True, the result should be directly an async iterator (not a coroutine).

    The issue is that the actual acontinue_run method on an Agent returns a generator-like object via the _acontinue_run_stream function which is decorated with AsyncIterator. Let me look more carefully:

  46. MiniMax Assistant

    OK, so when stream=True, the agent's acontinue_run returns an AsyncIterator. So when the team calls member.acontinue_run(stream=True, ...), the result is an AsyncIterator directly. My mock needs to return an AsyncIterator directly, not a coroutine.

    Let me make the test mock simpler by having two separate methods - one for stream=True and one for stream=False:

  47. MiniMax Assistant

    All 4 routing functions correctly pass run_context with session_state and dependencies. Now let me also look at the case where member_run_output is None - that uses run_id to look up the run, which we also covered. But let me also verify by looking at the case:

  48. MiniMax Assistant

    The fallback case also works. Now let me also check if there's a similar issue elsewhere by searching for any other continue_run calls in the codebase that should pass run_context:

  49. MiniMax Assistant

    Let me also check os/interfaces/slack/hitl.py since it's similar context:

  50. MiniMax Assistant

    This is a top-level acontinue_run call from an external system, so it's not relevant.

    Let me also check the team/team.py file for any other places that might call continue_run:

  51. MiniMax Assistant

    Now let me run the existing tests to make sure nothing is broken:

  52. MiniMax Assistant

    All 49 unit tests pass. Let me also run other tests related to the routing:

  53. MiniMax Assistant

    These are integration tests that need API keys. Let me check what tests exist that don't require API keys:

  54. MiniMax Assistant

    These 3 failures are unrelated to my changes (they're about sqlite db and skills snippets). Let me check that my changes haven't broken anything specific by running tests directly related to continue_run:

  55. MiniMax Assistant

    All 55 tests pass. Now let me also run the agent tests for continue_run:

  56. MiniMax Assistant

    All agent run regression tests pass. Let me also look at the team flow more carefully. I want to verify my understanding is correct by checking the flow once more. Let me re-read the issue:

    The user says:

    • They have a team with a member agent
    • The member agent has a tool group_del_stock that uses run_context.session_state["user_token"]
    • They use acontinue_run after confirming a paused run
    • But session_state["user_token"] is None

    The root cause is that the team was passing session_state to team.arun(...), but when acontinue_run was called, the team didn't pass the run_context to the member's acontinue_run(). So the member agent would create a fresh RunContext with empty session_state (loaded from the DB only).

    Wait, actually, the agent's _acontinue_run_stream DOES load session_state from the DB in line 4313:

    run_context.session_state = load_session_state(
        agent,
        session=agent_session,
        session_state=run_context.session_state if run_context.session_state is not None else {},
    )
    

    So even if session_state is empty, it should be loaded from DB. But the issue is dependencies, which is NOT loaded from DB. Let me verify:

  57. MiniMax Assistant

    OK, so session_state is loaded from the database. But dependencies is NOT stored in the database, it's runtime only. So if the user is passing dependencies={"user_token": "Bearer ..."} to team.arun(...), and then calling team.acontinue_run(dependencies=session_state), the dependencies would not be loaded from DB.

    The user's example code uses dependencies=session_state which is just the dict {"user_token": "Bearer "}. So when they call acontinue_run(dependencies=session_state), that dict goes into run_context.dependencies, but then when the member's acontinue_run is called, the member gets a fresh run_context with dependencies=None.

    Now with my fix, the run_context is passed through, so the member agent's acontinue_run will receive the dependencies from the team's run_context.

    Let me also check that the issue isn't in another layer - specifically, in the _aroute_requirements_to_members_stream calling pattern. Let me also look at if there's a way the run_context might need to be modified before being passed:

  58. MiniMax Assistant

    Let me see how the agent's acontinue_run_dispatch handles an existing run_context to make sure passing it doesn't break anything:

  59. MiniMax Assistant

    Good, the agent's acontinue_run_dispatch will use the provided run_context if it exists. So passing our run_context from the team is fine.

    Now let me also verify the issue is indeed resolved by running an actual integration-style test:

  60. MiniMax Assistant

    The issue is resolved. Let me also verify with the issue's actual scenario - where the user uses team.arun(session_state=...) and then team.acontinue_run(dependencies=session_state).

    Let me trace through the flow:

    1. team.arun(input="...", session_state={"user_token": "Bearer"})

      • This creates a run_context with session_state={"user_token": "Bearer"}
      • When delegating to member agent, member_agent.arun(session_state=copy_of_run_context.session_state) is called
      • So the member has the session_state
    2. During execution, the member calls group_del_stock(...) which uses run_context.session_state["user_token"]

      • The tool execution pauses for confirmation
    3. User calls team.acontinue_run(dependencies=session_state)

      • The team's acontinue_run_dispatch creates a new run_context with dependencies=session_state (which is {"user_token": "Bearer"})
      • Then it routes to the member's acontinue_run
      • BEFORE FIX: The member's acontinue_run is called WITHOUT run_context, so it creates a fresh RunContext with no dependencies (and empty session_state from DB)
      • AFTER FIX: The member's acontinue_run receives the team's run_context with dependencies={"user_token": "Bearer"}

    Now let me also write a test that simulates the actual end-to-end flow (without actual LLM calls):

  61. MiniMax Assistant

    Let me fix the test:

  62. MiniMax Assistant

    The fix is verified end-to-end. The run_context with both session_state and dependencies is now correctly passed to the member agent's acontinue_run.

    Now let me also check the case where the user calls the function via the team's acontinue_run directly. Let me also look at how the issue would manifest if there's a member agent that calls another team. The _find_member_route_by_id function returns a tuple with the path. Let me look at it:

  63. MiniMax Assistant

    Now I want to also check the case where the member is itself a Team. In that case, member.acontinue_run would be the team's acontinue_run, which already accepts run_context. So the fix should work for nested teams too.

    Let me look at the team class to confirm:

  64. MiniMax Assistant

    Both Agent and Team accept run_context in their acontinue_run method. So my fix works for both.

    Now let me look at what other tests might be affected. Let me also run a quick sanity check on all the tests:

  65. MiniMax Assistant

    All 347 tests pass. Let me also run the agent tests to make sure I didn't break anything:

  66. MiniMax Assistant

    Only the 2 unrelated sqlite/postgres db tests fail. These are not related to my changes.

    Let me also check that the workflow tests pass:

  67. MiniMax Assistant

    This is a missing dependency, unrelated to my changes. Let me skip those:

  68. MiniMax Assistant

    These are also due to missing sqlalchemy. They're not related to my changes. Let me also check the os folder:

  69. MiniMax Assistant

    Also unrelated to my changes. Now let me look at the test_run_regressions.py to see if there's a pattern I can use to add a regression test:

  70. MiniMax Assistant

    Let me check the existing tests in test_team_run_regressions.py:

  71. MiniMax Assistant

    Now let me also look at one of those tests to understand the pattern:

  72. MiniMax Assistant

    Now let me also think about edge cases. What about when the member is a sub-Team? Let me see how that works:

  73. MiniMax Assistant

    OK, so when a member is a sub-Team, it returns the sub-team and the sub-team's acontinue_run is called, which would also receive the run_context correctly with my fix.

    Let me also confirm my changes are syntactically correct by re-checking the file:

  74. MiniMax Assistant

    All 4 functions still accept run_context. Now let me verify the code compiles correctly:

  75. MiniMax Assistant

    Let me also see the full diff of my changes:

  76. MiniMax Assistant

    The changes are clean and minimal - just adding run_context=run_context to all 8 calls (2 in each of the 4 functions). Let me also verify the whole file still loads and the tests still pass:

  77. MiniMax Assistant

    All 67 tests pass. Now let me also run the full agent test suite to be safe:

  78. MiniMax Assistant

    All 339 tests pass. Now let me also look at one more edge case. Let me check the actual call patterns when member_run_output is None (fallback case) - I want to make sure the run_context is also passed in the fallback path.

    Let me also check if there are integration tests for dependencies passing through:

  79. MiniMax Assistant

    No existing tests for this scenario. Let me also verify the cleanup - remove temp files:

  80. MiniMax Assistant

    Let me run the reproduction script once more to make sure everything works:

  81. MiniMax Assistant

    Let me also check what happens when run_context=None is passed to the agent's acontinue_run_dispatch:

  82. MiniMax Assistant

    Good. The acontinue_run_dispatch handles the run_context=None case by creating a new RunContext with appropriate defaults. So passing run_context=None is safe.

    Now let me also clean up the reproduction script:

  83. MiniMax Assistant

    Now let me also do a final check of the diff:

  84. MiniMax Assistant

    The changes are minimal - 8 lines added, one for each of the 8 continue_run / acontinue_run calls in the routing functions.

    Let me also do one final comprehensive check by reviewing the diff:

  85. MiniMax Assistant

    The diff is clean and focused. Now let me address the checklist:

    Checklist Review:

    1. If an error was reported in the issue description, I have successfully reproduced it.

      • ✅ I reproduced the issue by creating a script that calls _aroute_requirements_to_members_stream and verified that the run_context was NOT being passed to the member's acontinue_run() call.
    2. If an error was reported in the issue description, I have confirmed that my fix resolves the error.

      • ✅ After applying the fix, the same reproduction script confirms that run_context is now correctly passed with session_state and dependencies.
    3. I have thought about edge cases and made sure my fix handles them as well.

      • ✅ I considered:
        • The fallback case (when member_run_output is None and run_id is used) - both calls in each function have the fix
        • All 4 routing functions (sync/async × stream/non-stream) are fixed
        • The case where run_context=None (the agent's acontinue_run_dispatch handles this)
        • When the member is a sub-Team (Team.acontinue_run also accepts run_context)
    4. I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.

      • ✅ I ran the following tests, all pass:
        • tests/unit/team/test_continue_run_requirements.py (49 tests)
        • tests/unit/team/test_acontinue_run_background_stream.py (6 tests)
        • tests/unit/team/test_team_run_regressions.py (12 tests)
        • tests/unit/agent/test_run_regressions.py (29 tests)
        • All other unit/team/agent tests except 2 unrelated sqlite/postgres db tests

    Let me submit the changes:

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