Skip to content

Commit 914cc4e

Browse files
committed
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
1 parent 367ec5f commit 914cc4e

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/api/providers/__tests__/openai.spec.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,15 +1195,19 @@ describe("OpenAiHandler", () => {
11951195

11961196
// Assert tool message exists - test setup should always produce a tool message
11971197
expect(toolMessageIndex).not.toBe(-1)
1198+
const toolMessage = messages[toolMessageIndex]
11981199

1199-
// The message after tool should be the next user message from a new request,
1200-
// not a user message with environment_details (which should be merged)
1200+
// Verify the tool message contains both the original content AND the merged environment_details
1201+
// This is the key verification that mergeToolResultText is working correctly
1202+
expect(toolMessage.content).toContain("File content here")
1203+
expect(toolMessage.content).toContain("environment_details")
1204+
1205+
// Verify there is NO user message immediately after the tool message
1206+
// This is the Mistral constraint: after tool, only assistant or tool is allowed, never user
1207+
// Per mistral_common validator: elif previous_role == Roles.tool: expected_roles = {Roles.assistant, Roles.tool}
12011208
const nextMessage = messages[toolMessageIndex + 1]
1202-
// If there's a next message, it should not be a user message containing environment_details
1203-
if (nextMessage && nextMessage.role === "user") {
1204-
const content =
1205-
typeof nextMessage.content === "string" ? nextMessage.content : JSON.stringify(nextMessage.content)
1206-
expect(content).not.toContain("environment_details")
1209+
if (nextMessage) {
1210+
expect(nextMessage.role).not.toBe("user")
12071211
}
12081212
})
12091213

0 commit comments

Comments
 (0)