Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging 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. Claude Assistant

    Now let's implement the fix. I'll write a small helper function to build a member-scoped RunContext and use it in all four functions.

  3. Claude Assistant

    Let's add a helper function right before _route_requirements_to_members, then modify the 4 functions to use it.

  4. Claude Assistant

    Now let's update each of the four functions to use this helper and pass run_context to member calls.

  5. Claude Assistant

    Now the streaming sync version. Let's view it.

  6. Claude Assistant

    Now the async non-streaming variant _aroute_requirements_to_members:

  7. Claude Assistant

    Now the async streaming variant _aroute_requirements_to_members_stream:

  8. Claude Assistant

    This is the exact one mentioned in the issue. Let's patch it.

  9. Claude Assistant

    Now let's check that RunContext is imported already (yes, from agno.run import RunContext at top). Let's view the helper function context to confirm correctness.

  10. Claude Assistant

    These are just logic tests, not calling actual functions with mocks that check call args. Let's run the full unit test file to be safe.

  11. Claude Assistant

    All pass. Now let's write a reproduction script simulating team with member requiring confirmation and session_state to verify the fix end-to-end.

  12. Claude Assistant

    The fix works as expected. Now let's revert this test to also confirm the "before fix" behavior (i.e., git stash to compare), then run broader test suite.

  13. Claude Assistant

    This confirms the bug existed before, and is fixed now. Let's also apply similar tests for the other 3 functions (sync stream, sync non-stream, async non-stream) quickly, and run the full team test suite.

  14. Claude Assistant

    All four functions confirmed fixed. Now let's run the broader test suite for team-related unit and integration tests (excluding those requiring API keys).

  15. Claude Assistant

    Confirmed pre-existing failures, unrelated to my change. Now let's run the agent unit tests too, since I didn't change agent code but let's make sure nothing else broke.

  16. Claude Assistant

    Same pre-existing environment issue, unrelated. Now let's run integration tests that don't require API keys for teams HITL, to be thorough.

  17. Claude Assistant

    Diff looks clean. Let's remove the extra blank line for style consistency.

  18. Claude Assistant

    All good. Let's rerun our reproduction scripts once more to confirm final state, then clean up temp files.

  19. Claude Assistant

    Summary

    Checklist review:

    • Reproduced the reported error: Yes. I traced the issue to libs/agno/agno/team/_run.py, where the four functions responsible for routing HITL requirements back to member agents on continue_run/acontinue_run (_route_requirements_to_members, _route_requirements_to_members_stream, _aroute_requirements_to_members, _aroute_requirements_to_members_stream) called member.continue_run() / member.acontinue_run() without passing the team-level run_context (which carries session_state, dependencies, knowledge_filters, metadata). I wrote a script mocking these functions and confirmed that, before the fix, run_context passed to the member's continue_run call was None, causing session_state/dependencies (e.g. user_token) to be lost inside member tools like group_del_stock.

    • Confirmed the fix resolves the error: Yes. After adding a helper _build_member_continue_run_context() that constructs a member-scoped RunContext (copying session_state, dependencies, knowledge_filters, metadata, user_id from the team-level context) and passing it via run_context= in all four routing functions, my reproduction script confirmed the member now receives the correct session_state and dependencies (matching the pattern already used in adelegate_task_to_member/delegate_task_to_members for the initial delegation).

    • Edge cases considered:

      • run_context is None → helper returns None, preserving old behavior (backward compatible).
      • Both code paths within each routing function (member_run_output available vs. fallback via member_run_id) are patched consistently.
      • Used deepcopy for session_state so mutations by concurrently-running members (via asyncio.gather in the non-streaming async variant) don't leak into each other or corrupt the team-level state.
      • The member's own continue_run_dispatch/acontinue_run_dispatch logic preserves provided session_state/dependencies over freshly loaded DB values (verified via merge_dictionaries precedence in load_session_state), and apply_to_context only fills in dependencies/knowledge_filters/metadata when not already set — so passing our fully-populated context doesn't get overwritten.
      • Fixed all 4 variants (sync/async × streaming/non-streaming) since all had the identical bug, not just the one mentioned in the issue.
    • Ran existing tests: libs/agno/tests/unit/team/ (412 passed, 2 pre-existing unrelated failures due to missing sqlite/postgres db modules in this sandboxed environment — confirmed via git stash that these fail identically without my changes) and libs/agno/tests/unit/agent/ (same pre-existing failures, everything else passes). Integration tests couldn't run due to missing sqlalchemy dependency in this environment, unrelated to the change.

    Cleaned up all temporary reproduction scripts before submission.

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