Skip to content

fix(run): skip CompactionItem silently in stream queue helper#3224

Merged
seratch merged 1 commit intoopenai:mainfrom
adityasingh2400:fix/stream-audit
May 8, 2026
Merged

fix(run): skip CompactionItem silently in stream queue helper#3224
seratch merged 1 commit intoopenai:mainfrom
adityasingh2400:fix/stream-audit

Conversation

@adityasingh2400
Copy link
Copy Markdown
Contributor

Summary

stream_step_items_to_queue in src/agents/run_internal/streaming.py falls through to the else: logger.warning("Unexpected item type: %s") branch for CompactionItem, even though CompactionItem is an explicit member of the RunItem union (src/agents/items.py).

CompactionItem is produced by turn_resolution.process_model_responses (see src/agents/run_internal/turn_resolution.py:1632) when the responses API emits compaction output, and these items can be passed to stream_step_items_to_queue via stream_step_result_to_queue(step_result, queue) from run_loop.py. They are session-bookkeeping artifacts with no public stream event name in stream_events.RunItemStreamEvent — so they should be skipped silently like ToolApprovalItem, not logged as unexpected.

Change

  • Add an elif isinstance(item, CompactionItem) branch that sets event = None (parallel to the existing ToolApprovalItem branch).
  • Add focused regression test test_stream_step_items_to_queue_skips_compaction_items_silently: queue stays empty, no "Unexpected item type" warning is logged.

Test plan

  • New test test_stream_step_items_to_queue_skips_compaction_items_silently fails before the fix and passes after.
  • Full tests/test_stream_events.py (8 tests) green.
  • Full tests/test_agent_runner_streamed.py (47 tests) green.
  • Diff is 24 lines (3 src + 21 test).

`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.
@github-actions github-actions Bot added bug Something isn't working feature:core labels May 8, 2026
@seratch seratch enabled auto-merge (squash) May 8, 2026 16:23
@seratch seratch merged commit 8619dfd into openai:main May 8, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants