Skip to content

Commit 974b0fa

Browse files
committed
fix
1 parent 76e5a72 commit 974b0fa

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

src/core/task/Task.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,15 +1835,32 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
18351835
// If there's no assistant_responses, that means we got no text
18361836
// or tool_use content blocks from API which we should assume is
18371837
// an error.
1838-
await this.say(
1839-
"error",
1840-
"Unexpected API Response: The language model did not provide any assistant messages. This may indicate an issue with the API or the model's output.",
1841-
)
1838+
// Note: GPT-5 can emit reasoning without assistant tokens, so
1839+
// also check if there is reasoning.
1840+
1841+
const modelId = getModelId(this.apiConfiguration)
1842+
const isGPT5 = modelId?.startsWith("gpt-5")
1843+
1844+
if (reasoningMessage.length > 0 && isGPT5) {
1845+
// GPT-5 produced only reasoning tokens, inform the model
1846+
await this.addToApiConversationHistory({
1847+
role: "assistant",
1848+
content: [
1849+
{ type: "text", text: "I only provided reasoning tokens without an actual response." },
1850+
],
1851+
})
1852+
} else {
1853+
// Show error for: no reasoning at all, or non-GPT5 models
1854+
await this.say(
1855+
"error",
1856+
"Unexpected API Response: The language model did not provide any assistant messages. This may indicate an issue with the API or the model's output.",
1857+
)
18421858

1843-
await this.addToApiConversationHistory({
1844-
role: "assistant",
1845-
content: [{ type: "text", text: "Failure: I did not provide a response." }],
1846-
})
1859+
await this.addToApiConversationHistory({
1860+
role: "assistant",
1861+
content: [{ type: "text", text: "Failure: I did not provide a response." }],
1862+
})
1863+
}
18471864
}
18481865

18491866
return didEndLoop // Will always be false for now.

0 commit comments

Comments
 (0)