File tree Expand file tree Collapse file tree
src/api/providers/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments