Skip to content

Remove early return for empty messages in sendChatHistoryMessagesAsync#158

Merged
pontemonti merged 2 commits intousers/johanb/RTP_OpenAIfrom
copilot/sub-pr-157
Jan 27, 2026
Merged

Remove early return for empty messages in sendChatHistoryMessagesAsync#158
pontemonti merged 2 commits intousers/johanb/RTP_OpenAIfrom
copilot/sub-pr-157

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 27, 2026

The sendChatHistoryMessagesAsync method was returning early when the messages array was empty, skipping the MCP platform call. The platform expects the call even with empty chat history.

Changes:

  • Removed early return for messages.length === 0 in McpToolRegistrationService.sendChatHistoryMessagesAsync()
  • Updated test to verify HTTP call occurs with empty array
  • Updated documentation to reflect empty messages still invoke MCP platform

Before:

if (messages.length === 0) {
  return OperationResult.success;  // No MCP call made
}

After:

// Empty messages array now proceeds to MCP platform call with empty chatHistory: []

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix MCP call to handle empty messages case Remove early return for empty messages in sendChatHistoryMessagesAsync Jan 27, 2026
Copilot AI requested a review from pontemonti January 27, 2026 17:12
@pontemonti pontemonti marked this pull request as ready for review January 27, 2026 17:15
@pontemonti pontemonti requested a review from a team as a code owner January 27, 2026 17:15
@pontemonti pontemonti merged commit 89d783f into users/johanb/RTP_OpenAI Jan 27, 2026
1 check passed
@pontemonti pontemonti deleted the copilot/sub-pr-157 branch January 27, 2026 17:15
pontemonti added a commit that referenced this pull request Jan 28, 2026
* Add chat history API for OpenAI

* fix: update uuid and @types/uuid dependencies to use catalog

* fix: correct header formatting in PRD for OpenAI sendChatHistoryAsync API

* refactor: remove unnecessary logging and improve message role validation in McpToolRegistrationService

* refactor: simplify role extraction in McpToolRegistrationService and remove validation

* Add @types/uuid and uuid dependencies

* Remove early return for empty messages in sendChatHistoryMessagesAsync (#158)

* Initial plan

* fix: ensure MCP call is made even when messages array is empty

Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>

* Remove fragile error handling from sendChatHistory methods (#159)

* Initial plan

* Remove fragile 'is required' check from sendChatHistory methods

Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>

* Update tests/tooling-extensions-openai/sendChatHistoryAsync.test.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix error handling in sendChatHistoryAsync and empty array test expectations (#160)

* Initial plan

* Fix test failures: wrap session.getItems() in try-catch and update test expectations for empty arrays

Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Co-authored-by: Johan Broberg <johan@pontemonti.net>

* Add error handling for message conversion in sendChatHistoryMessagesAsync (#163)

* Initial plan

* Add error handling for convertToChatHistoryMessages and test

Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>

* Address code review feedback: safer error handling and remove extra blank line

Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>

---------

Co-authored-by: Johan Broberg <johanb@microsoft.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pontemonti <7850950+pontemonti@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants