Skip to content

Commit c28b0e6

Browse files
authored
Merge branch 'main' into copilot/fix-send-chat-history-bug
2 parents 3d06d7d + accc8a3 commit c28b0e6

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,8 @@ async def send_chat_history(
569569
Must have a valid activity with conversation.id, activity.id, and
570570
activity.text.
571571
chat_history_messages: List of ChatHistoryMessage objects representing the chat
572-
history. Can be empty - the request will still be sent to
573-
register the user message from turn_context.activity.text.
572+
history. May be empty - an empty list will still send a
573+
request to the MCP platform with empty chat history.
574574
options: Optional ToolOptions instance containing optional parameters.
575575
576576
Returns:
@@ -608,8 +608,8 @@ async def send_chat_history(
608608
if chat_history_messages is None:
609609
raise ValueError("chat_history_messages cannot be None")
610610

611-
# Empty chat_history_messages is allowed - the request will still be sent
612-
# to register the user message from turn_context.activity.text in the MCP platform.
611+
# Note: Empty chat_history_messages is allowed - we still send the request to MCP platform
612+
# The platform needs to receive the request even with empty chat history
613613

614614
# Extract required information from turn context
615615
if not turn_context.activity:

tests/tooling/services/test_send_chat_history.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
"""Unit tests for send_chat_history method in McpToolServerConfigurationService."""
55

6+
import json
67
from datetime import UTC, datetime
78
from unittest.mock import AsyncMock, MagicMock, Mock, patch
89

@@ -147,7 +148,7 @@ async def test_send_chat_history_validates_chat_history_messages(
147148

148149
@pytest.mark.asyncio
149150
async def test_send_chat_history_empty_list_sends_request(self, service, mock_turn_context):
150-
"""Test that send_chat_history still sends request for empty list to register user message."""
151+
"""Test that send_chat_history sends request to MCP platform even with empty list."""
151152
# Arrange
152153
mock_response = AsyncMock()
153154
mock_response.status = 200
@@ -164,11 +165,19 @@ async def test_send_chat_history_empty_list_sends_request(self, service, mock_tu
164165
# Act
165166
result = await service.send_chat_history(mock_turn_context, [])
166167

167-
# Assert - empty list should still make HTTP request to register user message
168+
# Assert - empty list should still make HTTP request and return success
168169
assert result.succeeded is True
169170
assert len(result.errors) == 0
170-
# Verify HTTP POST was called
171+
172+
# Verify HTTP request was actually made
171173
assert mock_session_instance.post.called
174+
call_args = mock_session_instance.post.call_args
175+
assert "real-time-threat-protection/chat-message" in call_args[0][0]
176+
177+
# Verify the payload contains an empty chat history
178+
data = call_args[1]["data"]
179+
payload = json.loads(data)
180+
assert payload["chatHistory"] == []
172181

173182
@pytest.mark.asyncio
174183
async def test_send_chat_history_validates_activity(self, service, chat_history_messages):

0 commit comments

Comments
 (0)