Skip to content

Commit 69caca3

Browse files
committed
fix(compat_oai): correct parameter order in ToolMessage call
The parameters to openai.ToolMessage were swapped, causing tool responses to have their content and tool_call_id fields reversed in the JSON output. This was causing validation errors with AWS Bedrock which expects: - tool_call_id: to contain the tool reference ID (matching [a-zA-Z0-9_-]+ pattern) - content: to contain the actual response data The incorrect order was putting JSON response data in tool_call_id field, causing Bedrock validation to fail with regex pattern errors. Fixed by swapping the parameters to match the OpenAI SDK signature: ToolMessage(content, toolCallID) instead of ToolMessage(toolCallID, content)
1 parent 91775bf commit 69caca3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

go/plugins/compat_oai/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ func (g *ModelGenerator) WithMessages(messages []*ai.Message) *ModelGenerator {
107107
}
108108

109109
tm := openai.ToolMessage(
110-
toolCallID,
111110
anyToJSONString(p.ToolResponse.Output),
111+
toolCallID,
112112
)
113113
oaiMessages = append(oaiMessages, tm)
114114
}

0 commit comments

Comments
 (0)