Skip to content

fix: align team tool update handlers with agent HITL#7451

Closed
ysolanky wants to merge 1 commit intofeat/team-hitl-apifrom
ysolanky/team-hitl-bugfixes
Closed

fix: align team tool update handlers with agent HITL#7451
ysolanky wants to merge 1 commit intofeat/team-hitl-apifrom
ysolanky/team-hitl-bugfixes

Conversation

@ysolanky
Copy link
Copy Markdown
Member

Summary

Fixes four inconsistencies between team and agent HITL tool handling, found during review of #6725.

  • Add missing ask_user (Case 3b) tool handler to all four team tool update functions, matching agent/_tools.py:872. Without this, team-level ask_user feedback tools silently fail to resolve.
  • Add _maybe_create_audit_approval calls after tool confirmation, external execution, and user input resolution, matching the agent's audit trail behavior.
  • Fix stream_events parameter being ignored in _route_requirements_to_members_stream and _aroute_requirements_to_members_stream. The yield condition only checked team.stream_member_events, dropping events when the caller passed stream_events=True.
  • Restore events_to_skip on the RunContinued event in _continue_run (was commented out with no explanation).

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Improvement
  • Model update
  • Other:

Checklist

  • Code complies with style guidelines
  • Ran format/validation scripts (./scripts/format.sh and ./scripts/validate.sh)
  • Self-review completed
  • Documentation updated (comments, docstrings)
  • Examples and guides: Relevant cookbook examples have been included or updated (if applicable)
  • Tested in clean environment
  • Tests added/updated (if applicable)

Duplicate and AI-Generated PR Check

  • I have searched existing open pull requests and confirmed that no other PR already addresses this issue
  • If a similar PR exists, I have explained below why this PR is a better approach
  • Check if this PR was entirely AI-generated (by Copilot, Claude Code, Cursor, etc.)

Additional Notes

Follow-up to #6725 and #7449. Only touches team/_run.py - brings the four _handle_team_tool_call_updates* functions into parity with their agent counterparts in agent/_tools.py.

1. Add missing ask_user (Case 3b) tool handler to all four team
   tool update functions, matching agent/_tools.py:872.

2. Add _maybe_create_audit_approval calls after tool confirmation,
   external execution, and user input resolution, matching the
   agent handler's audit trail behavior.

3. Fix stream_events parameter being ignored in
   _route_requirements_to_members_stream and its async variant.
   The yield condition checked only team.stream_member_events,
   silently dropping events when stream_events=True.

4. Restore events_to_skip on RunContinued event in _continue_run
   (was commented out with no explanation).
@ysolanky ysolanky requested a review from a team as a code owner April 10, 2026 02:56
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ee7874f3c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

_t.confirmed = False
_t.confirmation_note = _t.confirmation_note or "Tool call was rejected"
_t.tool_call_error = True
_maybe_create_audit_approval(team, _t, run_response, "approved" if _t.confirmed is True else "rejected") # type: ignore
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Record team audit approvals with team_id metadata

_maybe_create_audit_approval in agno/agent/_tools.py always forwards agent_id/agent_name to create_audit_approval and never sets team_id/team_name; calling it from team tool-update paths here therefore writes team HITL audit records as agent-scoped records. For team runs with approval_type="audit", approval queries filtered by team_id or source_type=team will not return these entries, so audit attribution is incorrect. Use a team-aware audit helper (or pass team fields explicitly) when logging approvals from team handlers.

Useful? React with 👍 / 👎.

_t.confirmed = False
_t.confirmation_note = _t.confirmation_note or "Tool call was rejected"
_t.tool_call_error = True
_maybe_create_audit_approval(team, _t, run_response, "approved" if _t.confirmed is True else "rejected") # type: ignore
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Await audit writes in async team tool update handlers

The async team handlers invoke synchronous _maybe_create_audit_approval (for example here), but that helper calls db.create_approval(...) without awaiting. With async DB backends (e.g., async Postgres/SQLite adapters where create_approval is async def), this produces an un-awaited coroutine and the audit approval is never persisted, so async team continue flows can silently lose audit records. These async paths should use an awaited async audit helper instead.

Useful? React with 👍 / 👎.

@ysolanky ysolanky closed this Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant