[Bug] 400 Bad Request when restoring conversation from persistence · Issue #131 · microsoft/copilot-for-eclipse · GitHub
Skip to content

[Bug] 400 Bad Request when restoring conversation from persistence #131

Closed

Description

@xinyi-gong

Environment

  • OS:
  • Eclipse Version:
  • Plugin Version:

Describe the bug
When restoring a conversation from persistent storage (history-based conversation), the first request to the LLM intermittently fails with a 400 Bad Request error:

To Reproduce

  1. Have a multi-turn conversation in Agent mode
  2. The conversation includes tool calls and assistant responses
  3. Restart the ide and restore the previous conversation
  4. First request fails with 400, subsequent retry succeeds

Expected behavior
Should have no error

Screenshots

Image

Root Cause
After debugging the CLS and inspecting the constructed messages array sent to the model API, two issues were found in how Eclipse reconstructs conversation turns from persistence:

  1. New user message not appended at the end
    When creating a history-based conversation, the current user message is placed as the first turn, and historical turns are appended after it. This results in the messages array ending with an assistant role message. Claude API requires the last message to be role: "user", so the request returns 400.

  2. Assistant response duplicated as user message
    When converting persisted CopilotTurnData back to Turn objects, the assistant's response text is incorrectly assigned to both the request field (user message) and response field (assistant message). This causes the LLM's previous reply to appear as a role: "user" message in the history, resulting in duplicated content and wasted tokens.

Activity

  1. self-assigned this
    on Apr 29, 2026
  2. changed the title [-][Bug] Bug: 400 Bad Request when restoring conversation from persistence[/-] [+][Bug] 400 Bad Request when restoring conversation from persistence[/+] on Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions