Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 978f8e3

Browse files
committed
refactor: remove unnecessary sawReasoning deduplication in Poe provider
The AI SDK's reasoningText promise is always derived from the same stream parts emitted via fullStream — it can never contain content that wasn't already yielded. Remove the redundant fallback to match the openai-compatible provider pattern.
1 parent 8562ab7 commit 978f8e3

2 files changed

Lines changed: 0 additions & 67 deletions

File tree

src/api/providers/__tests__/poe.spec.ts

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -294,62 +294,6 @@ describe("PoeHandler", () => {
294294
)
295295
})
296296

297-
it("emits final reasoning text when the stream has no reasoning chunks", async () => {
298-
const handler = new PoeHandler({
299-
poeApiKey: "key",
300-
apiModelId: "openai/o3",
301-
enableReasoningEffort: true,
302-
reasoningEffort: "high",
303-
})
304-
305-
const fullStream = (async function* () {
306-
yield { type: "text-delta", text: "Answer" }
307-
})()
308-
309-
mockStreamText.mockReturnValue({
310-
fullStream,
311-
reasoningText: Promise.resolve("Condensed reasoning"),
312-
usage: Promise.resolve({ inputTokens: 10, outputTokens: 5 }),
313-
})
314-
315-
const chunks = []
316-
for await (const chunk of handler.createMessage("system", [{ role: "user" as const, content: "reason" }])) {
317-
chunks.push(chunk)
318-
}
319-
320-
expect(chunks).toContainEqual({ type: "text", text: "Answer" })
321-
expect(chunks).toContainEqual({ type: "reasoning", text: "Condensed reasoning" })
322-
})
323-
324-
it("does not duplicate reasoning when the stream already contains reasoning chunks", async () => {
325-
const handler = new PoeHandler({
326-
poeApiKey: "key",
327-
apiModelId: "openai/o3",
328-
enableReasoningEffort: true,
329-
reasoningEffort: "high",
330-
})
331-
332-
const fullStream = (async function* () {
333-
yield { type: "reasoning-delta", text: "Live reasoning" }
334-
yield { type: "text-delta", text: "Answer" }
335-
})()
336-
337-
mockStreamText.mockReturnValue({
338-
fullStream,
339-
reasoningText: Promise.resolve("Condensed reasoning"),
340-
usage: Promise.resolve({ inputTokens: 10, outputTokens: 5 }),
341-
})
342-
343-
const chunks = []
344-
for await (const chunk of handler.createMessage("system", [{ role: "user" as const, content: "reason" }])) {
345-
chunks.push(chunk)
346-
}
347-
348-
expect(chunks.filter((chunk) => chunk.type === "reasoning")).toEqual([
349-
{ type: "reasoning", text: "Live reasoning" },
350-
])
351-
})
352-
353297
it("does not pass providerOptions when reasoning is disabled", async () => {
354298
const handler = new PoeHandler({
355299
poeApiKey: "key",

src/api/providers/poe.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,12 @@ export class PoeHandler extends BaseProvider implements SingleCompletionHandler
109109
}
110110

111111
try {
112-
let sawReasoning = false
113112
for await (const part of result.fullStream) {
114113
for (const chunk of processAiSdkStreamPart(part)) {
115-
if (chunk.type === "reasoning" && chunk.text.trim().length > 0) {
116-
sawReasoning = true
117-
}
118114
yield chunk
119115
}
120116
}
121117

122-
if (!sawReasoning) {
123-
const reasoningText = await result.reasoningText
124-
if (reasoningText?.trim()) {
125-
yield { type: "reasoning", text: reasoningText }
126-
}
127-
}
128-
129118
const usage = await result.usage
130119
if (usage) {
131120
const metrics = extractUsageMetrics(usage as any)

0 commit comments

Comments
 (0)