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

    Good, already imported. Now let's add the helper function and update all four routing functions.

  3. Claude Assistant

    Now let's insert the helper function after line 4807, then update the four call sites.

  4. Claude Assistant

    Need a blank line before def _route_requirements_to_members. Let's fix formatting.

  5. Claude Assistant

    Now update the member.continue_run calls (lines ~4896-4915) in _route_requirements_to_members.

  6. Claude Assistant

    Now let's look at _route_requirements_to_members_stream and update its two member.continue_run calls.

  7. Claude Assistant

    I have leftover duplicate lines (5023-5025) and a missing blank line before if member_run_output. Let's fix.

  8. Claude Assistant

    Now remove duplicate lines 5024-5026.

  9. Claude Assistant

    Good, that's fixed now. Let's continue to _aroute_requirements_to_members (async non-streaming) - update its member.acontinue_run calls.

  10. Claude Assistant

    Extra duplicate ) at line 5132. Fix it.

  11. Claude Assistant

    Good, that section is fixed. Now let's fix _aroute_requirements_to_members_stream (the one mentioned in the issue).

  12. Claude Assistant

    Extra duplicate ) at line 5246. Remove.

  13. Claude Assistant

    Now let's verify the whole file compiles correctly.

  14. Claude Assistant

    Now let's check whether Team members can also be sub-teams (not just Agents), since Team.continue_run/acontinue_run might have different signatures. Let's check.

  15. Claude Assistant

    Good — Team also accepts run_context, so member team subteams work with the same interface. Now let's double check the continue_run (sync, non-async) signature on Agent too, to confirm run_context kwarg is supported (used in the sync route functions).

  16. Claude Assistant

    Duplicate lines 4852-4853. Fix.

  17. Claude Assistant

    All 8 call sites updated. Let's verify.

  18. Claude Assistant

    All 8 call sites now pass member=member. Let's validate syntax again.

  19. Claude Assistant

    Now let's write a reproduction script to verify the fix works end-to-end.

  20. Claude Assistant

    All existing tests pass. Now let's run the broader team test suite to make sure nothing else broke.

  21. Claude Assistant

    Good — these 3 failures are pre-existing and unrelated to our change. Now let's run the full agent test suite too for sanity and check flake8/ruff lint.

  22. Claude Assistant

    Also pre-existing (same agno.db module issue). Good. Now let's run flake8/ruff check for our modified file.

  23. Claude Assistant

    Let's also run ruff format check to ensure style consistency, and mypy if configured.

  24. Claude Assistant

    Just line-length formatting. Let's apply the formatting.

  25. Claude Assistant

    Now let's re-run our repro script to confirm the fix still holds after formatting, and view the final diff.

  26. Claude Assistant

    Fix confirmed. Let's view the full diff for review.

  27. Claude Assistant

    The diff looks clean. Now let's clean up the temp repro script and run the full test suite one more time.

  28. Claude Assistant

    Same pre-existing 3 failures, unrelated to our change. Let's also double check git status before submitting.

  29. Claude Assistant

    Checklist Review

    • [x] If an error was reported in the issue description, I have successfully reproduced it. I traced the reported bug to the four member-requirement routing helpers in libs/agno/agno/team/_run.py (_route_requirements_to_members, _route_requirements_to_members_stream, _aroute_requirements_to_members, _aroute_requirements_to_members_stream, specifically the one at line ~5145 mentioned in the issue). I confirmed via code inspection that none of the member.continue_run()/member.acontinue_run() calls passed run_context (or any equivalent), even though the team-level run_context (with session_state/dependencies correctly restored by _asetup_session) was available in scope. I wrote a reproduction script mocking a member agent's acontinue_run and confirmed that, prior to the fix, no run_context was forwarded, so session_state/dependencies were unavailable to the member.

    • [x] If an error was reported in the issue description, I have confirmed that my fix resolves the error. After adding the _build_member_run_context() helper and wiring it into all 8 call sites (2 per each of the 4 routing functions — sync/async × streaming/non-streaming), the reproduction script now shows the member's acontinue_run receiving a run_context whose session_state and dependencies match exactly what was set on the team's run ({"user_token": "Bearer abc123"} and {"dep_key": "dep_val"} in my test), confirming the fix works.

    • [x] I have thought about edge cases and made sure my fix handles them as well.

      • Used a shallow copy of session_state (matching the pattern already used in adelegate_task_to_member) so member continuation doesn't mutate the team's shared session_state dict in place.
      • Set run_id on the constructed RunContext to the actual member run's id (falling back to the team's run_id only if unavailable), so internal bookkeeping (e.g. current_run_id stamped into session_state) reflects the correct run rather than the team's.
      • Added a guard so remote members (RemoteAgent/RemoteTeam, which don't accept a run_context kwarg and would forward it as an opaque object to an HTTP client) are skipped — the helper returns None for those, preserving prior (working) behavior for remote routing.
      • Applied the fix uniformly across all 4 routing functions (sync/async, streaming/non-streaming) and both code branches within each (resuming from a cached member_run_output vs. falling back to run_id), since all had the identical bug.
    • [x] I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. Ran tests/unit/team/test_continue_run_requirements.py (49 passed), the full tests/unit/team/ suite (411 passed, 3 pre-existing unrelated failures verified via git stash to exist before my change too, 2 skipped), and tests/unit/agent/ (339 passed, 2 pre-existing unrelated failures). Also ran ruff check and ruff format on the modified file to keep style consistent.

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