From 914cc4e73ebdecb0438f69c077d4c42db29b6393 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Thu, 22 Jan 2026 23:47:27 +0000 Subject: [PATCH] test: strengthen Mistral test to verify tool message contains merged text - Add explicit assertions verifying merged environment_details in tool message - Add assertion confirming no user message follows tool (Mistral constraint) - Reference mistral_common validator constraint in comment --- src/api/providers/__tests__/openai.spec.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/api/providers/__tests__/openai.spec.ts b/src/api/providers/__tests__/openai.spec.ts index 48243f2b24..63ac438b0c 100644 --- a/src/api/providers/__tests__/openai.spec.ts +++ b/src/api/providers/__tests__/openai.spec.ts @@ -1195,15 +1195,19 @@ describe("OpenAiHandler", () => { // Assert tool message exists - test setup should always produce a tool message expect(toolMessageIndex).not.toBe(-1) + const toolMessage = messages[toolMessageIndex] - // The message after tool should be the next user message from a new request, - // not a user message with environment_details (which should be merged) + // Verify the tool message contains both the original content AND the merged environment_details + // This is the key verification that mergeToolResultText is working correctly + expect(toolMessage.content).toContain("File content here") + expect(toolMessage.content).toContain("environment_details") + + // Verify there is NO user message immediately after the tool message + // This is the Mistral constraint: after tool, only assistant or tool is allowed, never user + // Per mistral_common validator: elif previous_role == Roles.tool: expected_roles = {Roles.assistant, Roles.tool} const nextMessage = messages[toolMessageIndex + 1] - // If there's a next message, it should not be a user message containing environment_details - if (nextMessage && nextMessage.role === "user") { - const content = - typeof nextMessage.content === "string" ? nextMessage.content : JSON.stringify(nextMessage.content) - expect(content).not.toContain("environment_details") + if (nextMessage) { + expect(nextMessage.role).not.toBe("user") } })