Skip to content
TheChatArchiveThe Chat Archive
fable-5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Untitled conversation

  1. User

    [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.

  2. Assistant

    Now let me check the top imports of team/_run.py:

  3. Assistant

    Now I'll implement the fix. First, add a helper that builds the member's RunContext:

  4. Assistant

    Now update the sync non-streaming variant _route_requirements_to_members:

  5. Assistant

    Now the sync streaming variant _route_requirements_to_members_stream:

  6. Assistant

    Add the merge-back in the sync streaming variant after the loop:

  7. Assistant

    Now the async non-streaming variant _aroute_requirements_to_members:

  8. Assistant

    Now the async streaming variant _aroute_requirements_to_members_stream (the one the issue points at):

  9. Assistant

    Now verify the call sites pass run_context to all routing functions:

  10. Assistant

    Let me check how session state restoration works without a DB, to understand the full flow:

  11. Assistant

    Now let's find and run existing tests covering team HITL continue_run:

  12. Assistant

    All 49 pass. Let me look at how existing tests mock members, so I can add a regression test:

  13. Assistant

    Now let me check the end of the test file and add a regression test class:

  14. Assistant

    All 55 pass. Run the broader team and agent test suites:

  15. Assistant

    Same 7 failures pre-exist on the clean tree — unrelated to this fix. Now run formatting/validation:

  16. Assistant

    Now the Team overloads:

  17. Assistant

    All remaining failures pre-exist on a clean tree (environment-related: missing db drivers, skills snippet). Final review of the diff:

  18. Assistant

    All checks pass. Summary of the fix:

    Problem

    When a team run paused for HITL (e.g., tool confirmation on a member agent) and was resumed via team.acontinue_run(...), the member's continue_run/acontinue_run was invoked with only run_response/run_id and session_id (libs/agno/agno/team/_run.py). The member then built a fresh RunContext with empty session_state and no dependencies, so member tools reading run_context.session_state["user_token"] (or dependencies) got None — exactly what the issue reports at _aroute_requirements_to_members_stream.

    Fix (libs/agno/agno/team/_run.py)

    • Added _build_member_continue_run_context() — builds a member RunContext carrying the team run's session_state (a copy), dependencies, metadata, user_id, and knowledge_filters, mirroring what delegate_task_to_member passes on the initial run.
    • Added _merge_member_session_state() — merges member session_state changes back into the team run_context after the member finishes, mirroring _process_delegate_task_to_member.
    • Wired both into all four routing variants: _route_requirements_to_members, _route_requirements_to_members_stream, _aroute_requirements_to_members, _aroute_requirements_to_members_stream — covering both the run_response path and the run_id fallback path.
    • Added the (already-implemented) run_context parameter to the continue_run/acontinue_run overload signatures on Agent (agent.py) and Team (team.py) so the calls type-check.

    Tests

    Added TestMemberContinueRunContext (6 tests) in libs/agno/tests/unit/team/test_continue_run_requirements.py verifying: context carries state/dependencies as a copy, None passthrough, merge-back, and that all sync/async/stream routing variants pass a populated run_context to the member and merge member state back.

    Results:

    • tests/unit/team/test_continue_run_requirements.py: 55 passed
    • tests/unit/team + tests/unit/agent: 756 passed; the 5 failures (test_team_config, test_agent_config, test_team_skills) also fail on the clean tree — pre-existing environment issues (missing sqlite/postgres db drivers), unrelated to this change
    • ruff format / ruff check: clean; mypy on all modified files: no issues

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