Skip to content

test(openai): cover ReAct streamEvents backpressure regression - #3061

Open
guslegend0510 wants to merge 12 commits into
agentscope-ai:mainfrom
guslegend0510:codex/fix-3055-stream-events-stall
Open

test(openai): cover ReAct streamEvents backpressure regression#3061
guslegend0510 wants to merge 12 commits into
agentscope-ai:mainfrom
guslegend0510:codex/fix-3055-stream-events-stall

Conversation

@guslegend0510

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.0.3-SNAPSHOT

Description

Refs #3055.
Related issue: #2957.
Follow-up to the transport fix in #2963.

The streaming stall described in #3055 matches the request-starvation issue already fixed in OkHttpTransport by #2963.

This PR adds regression coverage through OkHttpTransport, OpenAIChatModel, and ReActAgent.streamEvents():

  • Require all 96 text deltas to arrive in order before sending [DONE].
  • Cover ordinary consumption and cross-thread incremental demand.
  • Verify exactly one model request and one model-call end event.
  • Document why the blocking transport uses subscribeOn(Schedulers.boundedElastic(), false).

The existing runtime fix is preserved; this PR adds regression tests and an explanatory comment.

Validation

  • Temporarily restoring the old request scheduling makes both new tests time out.
  • Both tests pass with the existing fix.
  • Full Core suite: 2,323 tests, 9 skipped.
  • Full Harness suite: 1,010 tests, 14 skipped.
  • Full OpenAI module suite: 557 tests, 12 skipped.
  • Zero failures or errors across these suites.
  • Spotless, required focused checks, and git diff --check passed.

The reproduction uses a controlled streaming response body; no live model API was called.

Checklist

  • Code has been formatted.
  • Relevant module test suites pass.
  • Comments explain the scheduling constraint.
  • No public API or user-facing documentation changes are needed.
  • Code is ready for review.

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@oss-maintainer oss-maintainer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Regression coverage for the #3055 streaming stall: a new OpenAIReActAgentStreamingBackpressureTest that drives 96 SSE deltas through OkHttpTransportOpenAIChatModelReActAgent.streamEvents() and asserts every delta is delivered before [DONE], under both eager and incremental (publishOn(parallel(), 1)) demand, plus exactly one model request and one ModelCallEndEvent. The only production change is an explanatory comment on subscribeOn(Schedulers.boundedElastic(), false). Clean, valuable test-first PR — the negative control (restoring the old scheduling makes both tests time out) is exactly the evidence a regression test needs, and the fake-Pipe harness avoids any live model call.

Two small notes, neither blocking:

  • [Info] agentscope-extensions-model-openai/src/test/.../OpenAIReActAgentStreamingBackpressureTest.java:78 — the response body is created with a null content type; passing MediaType.parse("text/event-stream") would make the fixture closer to what a real OpenAI-compatible endpoint returns, in case the decoder ever starts inspecting the content type.
  • [Info] same file, responseSink is fully buffered before the request is subscribed. That is safe for 96 chunks (~8 KB against the 64 KB pipe) but will block the test thread (rather than fail cleanly) if someone scales expected up past the buffer. A one-line comment on that limit, or writing chunks from a separate task, would keep it future-proof.

CLA: signed ✅


Automated review by github-manager-bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants