fix(run): skip CompactionItem silently in stream queue helper#3224
Merged
seratch merged 1 commit intoopenai:mainfrom May 8, 2026
Merged
fix(run): skip CompactionItem silently in stream queue helper#3224seratch merged 1 commit intoopenai:mainfrom
seratch merged 1 commit intoopenai:mainfrom
Conversation
`stream_step_items_to_queue` falls through to a "Unexpected item type" WARNING log for `CompactionItem`, even though `CompactionItem` is a declared member of the `RunItem` union (see `agents.items.RunItem`). Compaction items are session-bookkeeping artifacts produced by `turn_resolution.process_model_responses` and have no public stream event name, so they should be skipped silently like `ToolApprovalItem` rather than spamming user logs whenever responses-side compaction is emitted. Add a focused regression test asserting the queue stays empty and no "Unexpected item type" warning is logged for `CompactionItem` input.
seratch
approved these changes
May 8, 2026
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
stream_step_items_to_queueinsrc/agents/run_internal/streaming.pyfalls through to theelse: logger.warning("Unexpected item type: %s")branch forCompactionItem, even thoughCompactionItemis an explicit member of theRunItemunion (src/agents/items.py).CompactionItemis produced byturn_resolution.process_model_responses(seesrc/agents/run_internal/turn_resolution.py:1632) when the responses API emits compaction output, and these items can be passed tostream_step_items_to_queueviastream_step_result_to_queue(step_result, queue)fromrun_loop.py. They are session-bookkeeping artifacts with no public stream event name instream_events.RunItemStreamEvent— so they should be skipped silently likeToolApprovalItem, not logged as unexpected.Change
elif isinstance(item, CompactionItem)branch that setsevent = None(parallel to the existingToolApprovalItembranch).test_stream_step_items_to_queue_skips_compaction_items_silently: queue stays empty, no"Unexpected item type"warning is logged.Test plan
test_stream_step_items_to_queue_skips_compaction_items_silentlyfails before the fix and passes after.tests/test_stream_events.py(8 tests) green.tests/test_agent_runner_streamed.py(47 tests) green.