Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ The service handles automatic conversion of OpenAI message types:
| `turnContext` is null/undefined | Throws `Error('turnContext is required')` |
| `session` is null/undefined | Throws `Error('session is required')` |
| `messages` is null/undefined | Throws `Error('messages is required')` |
| `messages` is empty array | Returns `OperationResult.success` (no-op) |
| `messages` is empty array | Makes MCP platform call with empty chat history |
| Message conversion fails | Message is skipped, error logged |
| HTTP error from MCP platform | Returns `OperationResult.failed()` with error |
| Network timeout | Returns `OperationResult.failed()` with error |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ export class McpToolRegistrationService {
throw new Error('messages is required');
}

// Handle empty list as no-op
if (messages.length === 0) {
return OperationResult.success;
}

// Set default options
const effectiveOptions: ToolOptions = {
orchestratorName: toolOptions?.orchestratorName ?? this.orchestratorName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,24 @@ describe('McpToolRegistrationService - sendChatHistoryMessagesAsync', () => {
).rejects.toThrow('messages is required');
});

it('UV-05: should return success for empty array (no-op)', async () => {
it('UV-05: should make MCP platform call even with empty array', async () => {
mockedAxios.post.mockResolvedValue({ status: 200, data: {} });
const result = await service.sendChatHistoryMessagesAsync(mockTurnContext, []);

expect(result.succeeded).toBe(true);
expect(result).toBe(OperationResult.success);
// Verify that no HTTP call was made
expect(mockedAxios.post).not.toHaveBeenCalled();
// Verify that HTTP call was made even with empty messages
expect(mockedAxios.post).toHaveBeenCalledTimes(1);
expect(mockedAxios.post).toHaveBeenCalledWith(
expect.any(String),
expect.objectContaining({
conversationId: 'conv-123',
messageId: 'msg-456',
userMessage: 'Current user message',
chatHistory: [], // Empty chat history
}),
expect.any(Object)
);
});
});

Expand Down