Skip to content

Commit 35b5f3d

Browse files
committed
test(streaming): add coalescing-layer tests; loosen one model assertion
After merging the test-suite repair from main (#334) into this branch, one model test (test_responses_api_streaming) regressed because its assert_called_with strict-matched all kwargs of streaming_task_message_context and didn't tolerate the new `streaming_mode='coalesced'` kwarg this PR adds. Switched to assert_called() + targeted kwarg checks so the test verifies what it cares about (task_id threading) without locking in implementation details. Replaced the ad-hoc smoke scripts that lived in conversation with a real pytest module at tests/lib/core/services/adk/test_streaming.py covering: - _delta_char_len, _can_merge, _merge_pair: per-channel correctness + None-handling - _merge_consecutive: pure-text collapse, cross-channel order preservation, per-channel reconstruction matches per-token semantics - CoalescingBuffer: first-delta-immediate flush within ~20ms, size-threshold flush before timer fires, multi-delta coalescing within one window, idle close, add-after-close no-op - CoalescingBuffer cancel-during-flush regression test for the P1 fix: five queued chunks must all surface across publishes when close() cancels mid-flush (asserts substring presence rather than exact ordering, since the documented trade-off allows duplicates of the in-flight item) - StreamingTaskMessageContext mode dispatch: "off" suppresses publishes but persists full content, "per_token" publishes each delta synchronously, "coalesced" batches and persists full content
1 parent 8e26b73 commit 35b5f3d

4 files changed

Lines changed: 504 additions & 5 deletions

File tree

src/agentex/lib/core/temporal/plugins/openai_agents/tests/test_streaming_model.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -773,11 +773,13 @@ async def test_responses_api_streaming(self, streaming_model, mock_adk_streaming
773773
task_id=sample_task_id
774774
)
775775

776-
# Verify streaming context was created
777-
mock_adk_streaming.streaming_task_message_context.assert_called_with(
778-
task_id=sample_task_id,
779-
initial_content=mock_adk_streaming.streaming_task_message_context.call_args.kwargs['initial_content']
780-
)
776+
# Verify streaming context was created with the right task_id. We
777+
# don't strict-match the full kwargs because production also passes
778+
# ``streaming_mode``, which is an implementation detail this test
779+
# doesn't care about.
780+
mock_adk_streaming.streaming_task_message_context.assert_called()
781+
call_kwargs = mock_adk_streaming.streaming_task_message_context.call_args.kwargs
782+
assert call_kwargs['task_id'] == sample_task_id
781783

782784
# Verify result is returned as ModelResponse
783785
from agents import ModelResponse

tests/lib/core/services/__init__.py

Whitespace-only changes.

tests/lib/core/services/adk/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)