my harness for niri
1import assert from "node:assert/strict"
2import test from "node:test"
3import { __completionTest } from "./loop-completion.js"
4
5test("consumeCompletionStream preserves reasoning_content on assistant messages", async () => {
6 async function* stream() {
7 yield {
8 id: "chunk_1",
9 object: "chat.completion.chunk",
10 created: 0,
11 model: "deepseek-v4-flash",
12 choices: [
13 {
14 index: 0,
15 delta: {
16 reasoning_content: "thinking...",
17 },
18 finish_reason: null,
19 },
20 ],
21 }
22 yield {
23 id: "chunk_2",
24 object: "chat.completion.chunk",
25 created: 0,
26 model: "deepseek-v4-flash",
27 choices: [
28 {
29 index: 0,
30 delta: {
31 content: "hello",
32 },
33 finish_reason: "stop",
34 },
35 ],
36 usage: {
37 prompt_tokens: 10,
38 completion_tokens: 5,
39 total_tokens: 15,
40 },
41 }
42 }
43
44 const result = await __completionTest.consumeCompletionStream(stream() as never)
45 const message = result.message as typeof result.message & { reasoning_content?: string }
46
47 assert.equal(message.content, "hello")
48 assert.equal(message.reasoning_content, "thinking...")
49 assert.equal(result.bufferedThinking, "thinking...")
50})