Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 27, 2026

send_chat_history_messages was returning early when chat_messages or history_messages were empty, skipping the API call entirely. This prevented the user message (turn_context.activity.text) from being registered in the MCP platform for real-time threat protection.

Changes

  • Core service (mcp_tool_server_configuration_service.py): Removed early return for empty chat_history_messages
  • AgentFramework extension: Removed early returns for empty input and post-conversion filtered messages
  • OpenAI extension: Removed early returns for empty input and post-conversion filtered messages
  • Tests: Updated to verify core service is called with empty lists
  • Docstrings: Updated to document that empty lists are valid and will still trigger the API call

Behavior Change

# Before: Returns immediately, user message never registered
result = await service.send_chat_history_messages([], turn_context)
# Core service NOT called

# After: Sends request with empty chat_history, user message registered
result = await service.send_chat_history_messages([], turn_context)
# Core service called with chat_history_messages=[]
Original prompt

On mcp_tool_registration_service.py, Fix send_chat_history_messages so that if chat_messages or history_messages are empty, we still send the empty list/array to the generic API. This is required so that the user message gets registered correctly in MCP platform. Please fix this bug and update any documentation and tests to reflect this.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix send chat history messages to handle empty lists Fix send_chat_history_messages to send empty lists to MCP platform Jan 27, 2026
Copilot AI requested a review from pontemonti January 27, 2026 06:54
@pontemonti pontemonti marked this pull request as ready for review January 27, 2026 07:06
@pontemonti pontemonti requested a review from a team as a code owner January 27, 2026 07:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where send_chat_history_messages would return early when chat messages or history messages were empty, preventing the user message from being registered in the MCP platform for real-time threat protection.

Changes:

  • Removed early returns in core service and extensions when chat history is empty
  • Updated docstrings to document that empty lists are valid inputs
  • Updated tests to verify that API calls are made even with empty lists

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py Removed early return for empty chat_history_messages and updated docstring to clarify empty lists are allowed
libraries/microsoft-agents-a365-tooling-extensions-openai/microsoft_agents_a365/tooling/extensions/openai/mcp_tool_registration_service.py Removed early returns for empty input and post-conversion filtered messages, updated docstrings
libraries/microsoft-agents-a365-tooling-extensions-agentframework/microsoft_agents_a365/tooling/extensions/agentframework/services/mcp_tool_registration_service.py Removed early returns for empty input and post-conversion filtered messages, updated docstrings
tests/tooling/services/test_send_chat_history.py Updated test to verify core service makes HTTP request with empty list
tests/tooling/extensions/openai/test_send_chat_history.py Updated test to verify core service is called with empty list
tests/tooling/extensions/agentframework/services/test_send_chat_history.py Updated tests to verify core service is called with empty lists in both empty input and all-filtered scenarios

tmlsousa
tmlsousa previously approved these changes Jan 27, 2026
@pontemonti pontemonti enabled auto-merge (squash) January 27, 2026 18:23
@pontemonti pontemonti merged commit 637f690 into main Jan 27, 2026
8 checks passed
@pontemonti pontemonti deleted the copilot/fix-send-chat-history-bug branch January 27, 2026 23:47
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.

4 participants