Skip to content

test: improve SSE streaming test reliability in CI environment#60

Open
OhYee wants to merge 3 commits intofix-sandbox-ttl-secondsfrom
fix-sandbox-ttl-seconds-ut
Open

test: improve SSE streaming test reliability in CI environment#60
OhYee wants to merge 3 commits intofix-sandbox-ttl-secondsfrom
fix-sandbox-ttl-seconds-ut

Conversation

@OhYee
Copy link
Member

@OhYee OhYee commented Mar 2, 2026

Add real HTTP server support for SSE streaming tests to address CancelledError issues with httpx.ASGITransport in CI environments. Update test fixtures to use uvicorn-based servers instead of ASGI transport for more reliable stream handling during integration tests.

The changes replace httpx.ASGITransport with actual HTTP servers using uvicorn for testing SSE streams, which resolves premature cancellation problems in CI environments where ASGI transport failed to properly handle streaming responses.

这些更改将 httpx.ASGITransport 替换为使用 uvicorn 的实际 HTTP 服务器来测试 SSE 流,
解决了 CI 环境中 ASGI 传输无法正确处理流式响应导致的提前取消问题。

Change-Id: Ie47a62015e7530b2fd7e027e47e440d2fb3ee453

Thank you for creating a pull request to contribute to Serverless Devs agentrun-sdk-python code! Before you open the request please answer the following questions to help it be more easily integrated. Please check the boxes "[ ]" with "[x]" when done too.
Please select one of the PR types below to complete


Fix bugs

Bug detail

The specific manifestation of the bug or the associated issue.

Pull request tasks

  • Add test cases for the changes
  • Passed the CI test

Update docs

Reason for update

Why do you need to update your documentation?

Pull request tasks

  • Update Chinese documentation
  • Update English documentation

Add contributor

Contributed content

  • Code
  • Document

Content detail

if content_type == 'code' || content_type == 'document':
    please tell us `PR url`,like: https://github.com/Serverless-Devs/agentrun-sdk-python/pull/1
else:
    please describe your contribution in detail

Others

Reason for update

Why do you need to update your documentation?

OhYee added 3 commits March 2, 2026 17:22
Add real HTTP server support for SSE streaming tests to address
CancelledError issues with httpx.ASGITransport in CI environments.
Update test fixtures to use uvicorn-based servers instead of ASGI
transport for more reliable stream handling during integration tests.

The changes replace httpx.ASGITransport with actual HTTP servers
using uvicorn for testing SSE streams, which resolves premature
cancellation problems in CI environments where ASGI transport
failed to properly handle streaming responses.

  这些更改将 httpx.ASGITransport 替换为使用 uvicorn 的实际 HTTP 服务器来测试 SSE 流,
  解决了 CI 环境中 ASGI 传输无法正确处理流式响应导致的提前取消问题。

Change-Id: Ie47a62015e7530b2fd7e027e47e440d2fb3ee453
Signed-off-by: OhYee <oyohyee@oyohyee.com>
Improve test reliability by adding proper error handling when the mock
OpenAI server fails to start within the expected timeframe, providing
clear error messaging for debugging purposes.

改进测试可靠性,在模拟 OpenAI 服务器无法在预期时间内启动时添加适当的错误处理,提供清晰的错误消息以便调试。

Change-Id: Ibc0fbc8d660dd272da108cd310f91c4393f75087
Signed-off-by: OhYee <oyohyee@oyohyee.com>
Update the mock OpenAI server implementation to properly simulate
streaming tool calls with the correct format including tool name,
empty arguments, and proper chunk structure that matches real OpenAI
streaming responses.

The changes modify the streaming test helper to yield tool call
information across multiple chunks as expected by the real API format,
improving test accuracy and reliability.

更新模拟 OpenAI 服务器实现以正确模拟工具调用的流式传输,
使用与真实 OpenAI 流式响应匹配的格式。修改了流式测试助手,
按真实 API 格式跨多个数据块生成工具调用信息,提高测试准确性和可靠性。

Change-Id: I08f7d64bfc69735ad806ae04e9414c08094c8ed1
Signed-off-by: OhYee <oyohyee@oyohyee.com>
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.

1 participant