Normalize responses SSE events for Codex
This commit is contained in:
@@ -1043,6 +1043,26 @@ async function run() {
|
||||
assert(streamDisconnectedRetryResponse.status === 200, `stream disconnected capacity 抖动后未自动恢复: ${streamDisconnectedRetryResponse.status}`);
|
||||
assert(streamDisconnectedRetryText.includes("hello"), "stream disconnected capacity 恢复后未拿到正常 SSE 内容");
|
||||
|
||||
const normalizedFailureStream = await readSseUntilClose(
|
||||
`http://127.0.0.1:${gatewayPort}/responses`,
|
||||
{
|
||||
stream: true,
|
||||
test_capacity_before_success_times: 1,
|
||||
test_capacity_message: "Permanent upstream failure for codex normalization test.",
|
||||
test_capacity_stream_event_name: "error",
|
||||
test_capacity_stream_payload_shape: "default",
|
||||
},
|
||||
);
|
||||
assert(normalizedFailureStream.status === 200, `非重试 fatal stream 首状态异常: ${normalizedFailureStream.status}`);
|
||||
assert(
|
||||
normalizedFailureStream.text.includes('"type":"response.failed"'),
|
||||
"非重试 fatal stream 未归一化为 response.failed",
|
||||
);
|
||||
assert(
|
||||
!normalizedFailureStream.text.includes('"type":"error"'),
|
||||
"非重试 fatal stream 不应继续透传 type=error",
|
||||
);
|
||||
|
||||
for (const streamPath of [
|
||||
"/responses",
|
||||
"/v1/responses",
|
||||
@@ -1065,10 +1085,16 @@ async function run() {
|
||||
const okStream = await readSseUntilClose(
|
||||
`http://127.0.0.1:${gatewayPort}${streamPath}`,
|
||||
{ stream: true, test_reasoning_tokens: 128 },
|
||||
);
|
||||
);
|
||||
assert(okStream.status === 200, `${streamPath} 128 首状态异常: ${okStream.status}`);
|
||||
assert(okStream.text.includes("[DONE]"), `${streamPath} 流式 128 未完整结束`);
|
||||
assert(!okStream.closedByError, `${streamPath} 流式 128 不应异常断开`);
|
||||
if (streamPath === "/responses" || streamPath === "/v1/responses") {
|
||||
assert(
|
||||
okStream.text.includes('"type":"response.completed"'),
|
||||
`${streamPath} 成功流未补 response.completed`,
|
||||
);
|
||||
}
|
||||
|
||||
if (streamPath === "/responses" || streamPath === "/v1/responses") {
|
||||
const replayedStream = await readSseUntilClose(
|
||||
|
||||
Reference in New Issue
Block a user