fix: align team tool update handlers with agent HITL#7451
fix: align team tool update handlers with agent HITL#7451ysolanky wants to merge 1 commit intofeat/team-hitl-apifrom
Conversation
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).
There was a problem hiding this comment.
💡 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
Fixes four inconsistencies between team and agent HITL tool handling, found during review of #6725.
ask_user(Case 3b) tool handler to all four team tool update functions, matching agent/_tools.py:872. Without this, team-levelask_userfeedback tools silently fail to resolve._maybe_create_audit_approvalcalls after tool confirmation, external execution, and user input resolution, matching the agent's audit trail behavior.stream_eventsparameter being ignored in_route_requirements_to_members_streamand_aroute_requirements_to_members_stream. The yield condition only checkedteam.stream_member_events, dropping events when the caller passedstream_events=True.events_to_skipon theRunContinuedevent in_continue_run(was commented out with no explanation).Type of change
Checklist
./scripts/format.shand./scripts/validate.sh)Duplicate and AI-Generated PR Check
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 inagent/_tools.py.