Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/core/task/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2132,10 +2132,9 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
"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.",
)

await this.addToApiConversationHistory({
role: "assistant",
content: [{ type: "text", text: "Failure: I did not provide a response." }],
})
// Don't add error messages to the API conversation history as it pollutes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a test case to verify that error messages are NOT added to the API conversation history when an empty assistant message is received? This would help prevent regression of this issue.

// the context sent to the LLM. The error is already shown to the user via say("error").
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding the issue number to the comment for future reference:

Suggested change
// the context sent to the LLM. The error is already shown to the user via say("error").
// Don't add error messages to the API conversation history as it pollutes
// the context sent to the LLM (fixes #7249). The error is already shown to the user via say("error").
// This prevents the issue where API errors disrupt the conversation flow.

// This prevents the issue where API errors disrupt the conversation flow.
}

// If we reach here without continuing, return false (will always be false for now)
Expand Down
Loading