惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Security Blog
Microsoft Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
美团技术团队
WordPress大学
WordPress大学
酷 壳 – CoolShell
酷 壳 – CoolShell
G
Google Developers Blog
阮一峰的网络日志
阮一峰的网络日志
The Cloudflare Blog
J
Java Code Geeks
Martin Fowler
Martin Fowler
M
MIT News - Artificial intelligence
IT之家
IT之家
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
Google DeepMind News
Google DeepMind News
小众软件
小众软件
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Jina AI
Jina AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
B
Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(gateway): flush initial openai chat stream chunk · op...
steipete · 2026-05-06 · via Recent Commits to openclaw:main

@@ -1028,6 +1028,85 @@ describe("OpenAI-compatible HTTP API (e2e)", () => {

10281028

}

10291029

});

103010301031+

it(

1032+

"sends an initial SSE chunk before a streaming agent run settles",

1033+

{ timeout: 15_000 },

1034+

async () => {

1035+

const port = enabledPort;

1036+

let serverAbortSignal: AbortSignal | undefined;

1037+1038+

agentCommand.mockClear();

1039+

agentCommand.mockImplementationOnce(

1040+

(opts: unknown) =>

1041+

new Promise<undefined>((resolve) => {

1042+

const signal = (opts as { abortSignal?: AbortSignal } | undefined)?.abortSignal;

1043+

serverAbortSignal = signal;

1044+

if (signal?.aborted) {

1045+

resolve(undefined);

1046+

return;

1047+

}

1048+

signal?.addEventListener("abort", () => resolve(undefined), { once: true });

1049+

}),

1050+

);

1051+1052+

let settled = false;

1053+

const firstChunk = new Promise<string>((resolve, reject) => {

1054+

const clientReq = http.request(

1055+

{

1056+

hostname: "127.0.0.1",

1057+

port,

1058+

path: "/v1/chat/completions",

1059+

method: "POST",

1060+

headers: {

1061+

"content-type": "application/json",

1062+

authorization: "Bearer secret",

1063+

},

1064+

},

1065+

(res) => {

1066+

expect(res.statusCode).toBe(200);

1067+

expect(res.headers["content-type"] ?? "").toContain("text/event-stream");

1068+

res.setEncoding("utf8");

1069+

res.once("data", (chunk) => {

1070+

settled = true;

1071+

resolve(String(chunk));

1072+

clientReq.destroy();

1073+

});

1074+

},

1075+

);

1076+

clientReq.on("error", (err) => {

1077+

if (!settled) {

1078+

reject(err);

1079+

}

1080+

});

1081+

clientReq.setTimeout(2_000, () => {

1082+

if (!settled) {

1083+

settled = true;

1084+

clientReq.destroy(new Error("timed out waiting for first SSE chunk"));

1085+

}

1086+

});

1087+

clientReq.end(

1088+

JSON.stringify({

1089+

stream: true,

1090+

model: "openclaw",

1091+

messages: [{ role: "user", content: "hi" }],

1092+

}),

1093+

);

1094+

});

1095+1096+

await expect(firstChunk).resolves.toContain('"role":"assistant"');

1097+

await vi.waitFor(() => {

1098+

expect(agentCommand).toHaveBeenCalledTimes(1);

1099+

});

1100+1101+

await vi.waitFor(

1102+

() => {

1103+

expect(serverAbortSignal?.aborted).toBe(true);

1104+

},

1105+

{ timeout: 5_000, interval: 50 },

1106+

);

1107+

},

1108+

);

1109+10311110

it("includes usage in final stream chunk when stream_options.include_usage=true", async () => {

10321111

const port = enabledPort;

10331112

agentCommand.mockClear();