Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 20, 2025

Summary

This PR fixes issue #7249 where API error messages were being added to the chat history, disrupting the conversation flow with the LLM.

Problem

When an API returns an empty assistant message or encounters an error, the system was adding a hardcoded error message "Failure: I did not provide a response." to the API conversation history. This error message would then be sent to the LLM in subsequent requests, polluting the context and disrupting the natural conversation flow.

Solution

  • Removed the line that adds the error message to the API conversation history
  • Kept the error display to the user via say("error") so users are still informed about the issue
  • Added a comment explaining why we don't add error messages to the conversation history

Testing

  • Ran existing tests: npx vitest run core/task/__tests__/Task.spec.ts - all tests pass ✅
  • Ran linting: all checks pass ✅
  • Ran type checking: all checks pass ✅

Impact

This change ensures that API-level errors are properly displayed to users without contaminating the LLM's conversation context, resulting in more coherent and consistent interactions.

Fixes #7249


Important

Fixes issue #7249 by preventing API error messages from being added to conversation history in Task.ts, ensuring cleaner LLM interactions.

  • Behavior:
    • Removes addition of error messages to apiConversationHistory in recursivelyMakeClineRequests() in Task.ts to prevent context pollution.
    • Error messages are still displayed to users via say("error").
    • Adds a comment explaining the rationale for not adding error messages to the conversation history.
  • Testing:
    • Ran existing tests in core/task/__tests__/Task.spec.ts - all tests pass.
    • Linting and type checking passed.
  • Impact:
    • Ensures API errors do not disrupt LLM conversation flow, improving interaction coherence.

This description was created by Ellipsis for 025e605. You can customize this summary. It will automatically update as commits are pushed.

Remove error message from API conversation history when assistant provides no response.
Keep error display to user via say("error") but do not add to LLM context.
This fixes the issue where API errors disrupt conversation flow.

Fixes #7249
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 20, 2025 08:54
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Aug 20, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Reviewing my own code is like debugging in production - technically possible but morally questionable.

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.

content: [{ type: "text", text: "Failure: I did not provide a response." }],
})
// Don't add error messages to the API conversation history as it pollutes
// 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.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 20, 2025
@daniel-lxs daniel-lxs closed this Aug 20, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 20, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

The API error log has been added to the chat message list.

4 participants