fix: add missing mcp_approval_response event name (fixes #1020)#1931
Merged
seratch merged 2 commits intoopenai:mainfrom Oct 21, 2025
Merged
fix: add missing mcp_approval_response event name (fixes #1020)#1931seratch merged 2 commits intoopenai:mainfrom
seratch merged 2 commits intoopenai:mainfrom
Conversation
The RunItemStreamEvent was missing the 'mcp_approval_response' event name for MCPApprovalResponseItem, causing it to fall through to the 'else' branch and trigger an 'Unexpected item type' warning. Changes: - Added 'mcp_approval_response' to RunItemStreamEvent.name Literal - Added MCPApprovalResponseItem handling in stream_step_items_to_queue This ensures all RunItem types have corresponding event names: - MessageOutputItem -> message_output_created - HandoffCallItem -> handoff_requested - HandoffOutputItem -> handoff_occured - ToolCallItem -> tool_called - ToolCallOutputItem -> tool_output - ReasoningItem -> reasoning_item_created - MCPApprovalRequestItem -> mcp_approval_requested - MCPApprovalResponseItem -> mcp_approval_response (NEW) - MCPListToolsItem -> mcp_list_tools Generated with Lucas Wang<lucas_wang@automodules.com>
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a missing event name for MCPApprovalResponseItem in the streaming events system, addressing incomplete type coverage where 9 RunItem types existed but only 8 had corresponding event names.
Key changes:
- Added
"mcp_approval_response"to theRunItemStreamEvent.nameLiteral type - Added handling for
MCPApprovalResponseItemin the stream event processing logic
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/agents/stream_events.py | Added missing "mcp_approval_response" event name to the Literal type |
| src/agents/_run_impl.py | Added case handling for MCPApprovalResponseItem in stream processing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
seratch
approved these changes
Oct 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1020
This PR adds the missing
mcp_approval_responseevent name forMCPApprovalResponseIteminRunItemStreamEvent.Problem
The
RunItemStreamEvent.nameLiteral was missing an event name forMCPApprovalResponseItem, even though it's part of theRunItemunion type. This caused:RunItemtypes but only 8 event namesMCPApprovalResponseItemwould fall through to theelsebranch, triggering "Unexpected item type" warningsRunItemtypes had corresponding events except this one1. 重現問題 (Reproduce the Problem)
Step 1: Review the Type Definitions
Check
src/agents/items.pyto see allRunItemtypes:Count: 9 types total
Step 2: Check the Event Names
Check
src/agents/stream_events.py:Count: Only 8 event names
Step 3: Verify the Gap
Create a mapping table:
Problem confirmed:
MCPApprovalResponseItemhas no corresponding event name!Step 4: Check the Handler Code
In
src/agents/_run_impl.py, thestream_step_items_to_queuefunction handles all item types:Result:
MCPApprovalResponseItemwould trigger the warning and be skipped.2. 修復 (Fix)
Fix Part 1: Add Event Name
In
src/agents/stream_events.py(line 40), add the missing event name:Fix Part 2: Add Handler
In
src/agents/_run_impl.py(lines 1175-1176), add the handler case:3. 驗證問題被解決 (Verify the Fix)
Verification 1: Type Coverage is Complete
After the fix, all 9
RunItemtypes have corresponding event names:✅ 9 types → 9 events (complete coverage)
Verification 2: Run Existing Tests
Verification 3: Run MCP Tests
Verification 4: Type Checking
Verification 5: Manual Code Review
Review the handler logic in
_run_impl.py:Impact
Changes
src/agents/stream_events.py"mcp_approval_response"toRunItemStreamEvent.nameLiteral (line 40)src/agents/_run_impl.pyMCPApprovalResponseItemcase instream_step_items_to_queue(lines 1175-1176)Generated with Lucas Wanglucas_wang@automodules.com