We convert openai API into bedrock interface to use bedrock models like openai. Hetting this issue
2026-03-10T10:20:58.563692Z WARN llms::bedrock::chat: Bedrock messages=[Message { role: User, content: [Text("Title: How can i optimise this SQL.\nWITH s3questions AS (\n SELECT s3questions AS "source", answer_content AS answer FROM s3tables_questions LIMIT 3\n), pganswers AS (\n SELECT postgres_answers AS "source", original_text AS answer FROM postgres_answers LIMIT 3\n)\n\nSELECT source, substr(answer, 0, 80)::text FROM s3questions\nUNION ALL\nSELECT source, substr(answer, 0, 80)::text FROM pganswers;\n")] }, Message { role: Assistant, content: [ToolUse(ToolUseBlock { tool_use_id: "initial_list_datasets", name: "list_datasets", input: Object({}), type: None })] }, Message { role: User, content: [ToolResult(ToolResultBlock { tool_use_id: "initial_list_datasets", content: [Text("[]")], status: Some(Success), type: None })] }]
2026-03-10T10:21:02.336138Z WARN llms::bedrock::chat: OpenAI messages=[System(ChatCompletionRequestSystemMessage { content: Text("You are a helpful AI assistant for a company that can answer questions from Stack Overflow data.\n\nIMPORTANT NOTE: The company has proprietary data in the form of datasets that you have access to (in addition to the stack overflow data). These datasets are:\n- spice.public.python_docs\n- spice.public.rust_book\nAlways consult these datasets first when answering questions, as they contain the most accurate and relevant information.\n\nYou will be given the title and optionally the content of a new question that was asked.\nTo answer this question, ALWAYS do the following:\n1. Use the document similarity tool to find related information in the datasets you have access to.\n2. Perform a websearch for the question using the websearch tool, enhancing your understanding with external sources.\n\nALWAYS include the following aspects in your response:\n- 5 similar questions to the ones the user has provided that are in the spice.public.questions dataset. The document similarity returns the question IDs of similar questions. Use the SQL tool to get the titles of these questions from the spice.public.questions dataset. Link to these questions based on this format: [<question_title>](/questions/<question_id>). If no similar questions are found, state that no similar questions were found. If the title is not available, exclude the question. Some of the question titles may not actually be relevant, so filter out any that are not relevant to the question being asked.\n- Your response to the question. Be clear, detailed, and, most importantly, data-grounded in all your insights. Don't title this section.\n- A list of sources you consulted, such as dataset names, websites, etc. When listing a website, ensure it exists using the websearch tool and has the information you expect it to. Use the web search tool to include sources the user can browse to learn more.\n\nFocus the content of your response in any section toward the provided question. Respond conversationally, as if you were having a discussion with the user or helping them out. Additionally, include a list of the tools you used, what documents/datasets you consulted, and any other sources you consulted to build your response.\n\nIf you get a SQL Schema or Syntax error when using the sql_tool, use the set of tools available to you to troubleshoot, fix the query, and then retry.\n\nWhen utilising the document_similarity tool, include all relevant filters for datasets relating to the question. For example\n - if the question is about Rust - include datasets for the questions dataset, as well as the rust_book dataset.\n - if the question is about Python, include datasets for the questions dataset, as well as the python_docs dataset.\n"), name: None }), User(ChatCompletionRequestUserMessage { content: Text("Title: How can i optimise this SQL.\nWITH s3questions AS (\n SELECT s3questions AS "source", answer_content AS answer FROM s3tables_questions LIMIT 3\n), pganswers AS (\n SELECT postgres_answers AS "source", original_text AS answer FROM postgres_answers LIMIT 3\n)\n\nSELECT source, substr(answer, 0, 80)::text FROM s3questions\nUNION ALL\nSELECT source, substr(answer, 0, 80)::text FROM pganswers;\n"), name: None }), Assistant(ChatCompletionRequestAssistantMessage { content: None, refusal: None, name: None, audio: None, tool_calls: Some([Function(ChatCompletionMessageToolCall { id: "initial_list_datasets", function: FunctionCall { name: "list_datasets", arguments: "" } })]), function_call: None }), Tool(ChatCompletionRequestToolMessage { content: Text("[]"), tool_call_id: "initial_list_datasets" }), Assistant(ChatCompletionRequestAssistantMessage { content: None, refusal: None, name: None, audio: None, tool_calls: Some([Function(ChatCompletionMessageToolCall { id: "REDACTED", function: FunctionCall { name: "search", arguments: "{"datasets":["spice.public.questions"],"limit":10,"text":"SQL query optimization UNION ALL CTE performance"}" } }), Function(ChatCompletionMessageToolCall { id: "tooluse_MqUxAyFsBESnsVgoY5oFtJ", function: FunctionCall { name: "search", arguments: "{"datasets":["spice.public.questions"],"text":"optimize SQL WITH CTE common table expression LIMIT","limit":10}" } })]), function_call: None }), Tool(ChatCompletionRequestToolMessage { content: Text(""Failed to call the tool search.\nAn error occurred: Data sources [spice.public.questions] do not exist""), tool_call_id: "REDACTED" }), Tool(ChatCompletionRequestToolMessage { content: Text(""Failed to call the tool search.\nAn error occurred: Data sources [spice.public.questions] do not exist""), tool_call_id: "tooluse_MqUxAyFsBESnsVgoY5oFtJ" })]
2026-03-10T10:21:02.336840Z WARN llms::bedrock::chat: Bedrock messages=[Message { role: User, content: [Text("Title: How can i optimise this SQL.\nWITH s3questions AS (\n SELECT s3questions AS "source", answer_content AS answer FROM s3tables_questions LIMIT 3\n), pganswers AS (\n SELECT postgres_answers AS "source", original_text AS answer FROM postgres_answers LIMIT 3\n)\n\nSELECT source, substr(answer, 0, 80)::text FROM s3questions\nUNION ALL\nSELECT source, substr(answer, 0, 80)::text FROM pganswers;\n")] }, Message { role: Assistant, content: [ToolUse(ToolUseBlock { tool_use_id: "initial_list_datasets", name: "list_datasets", input: Object({}), type: None })] }, Message { role: User, content: [ToolResult(ToolResultBlock { tool_use_id: "initial_list_datasets", content: [Text("[]")], status: Some(Success), type: None })] }, Message { role: Assistant, content: [ToolUse(ToolUseBlock { tool_use_id: "REDACTED", name: "search", input: Object({"text": String("SQL query optimization UNION ALL CTE performance"), "limit": Number(PosInt(10)), "datasets": Array([String("spice.public.questions")])}), type: None }), ToolUse(ToolUseBlock { tool_use_id: "tooluse_MqUxAyFsBESnsVgoY5oFtJ", name: "search", input: Object({"text": String("optimize SQL WITH CTE common table expression LIMIT"), "limit": Number(PosInt(10)), "datasets": Array([String("spice.public.questions")])}), type: None })] }, Message { role: User, content: [ToolResult(ToolResultBlock { tool_use_id: "REDACTED", content: [Text(""Failed to call the tool search.\nAn error occurred: Data sources [spice.public.questions] do not exist"")], status: Some(Success), type: None })] }, Message { role: User, content: [ToolResult(ToolResultBlock { tool_use_id: "tooluse_MqUxAyFsBESnsVgoY5oFtJ", content: [Text(""Failed to call the tool search.\nAn error occurred: Data sources [spice.public.questions] do not exist"")], status: Some(Success), type: None })] }]
2026-03-10T10:21:02.685419Z ERROR runtime::http::v1::chat: Error from v1/chat: ValidationException: Expected toolResult blocks at messages.4.content for the following Ids: tooluse_MqUxAyFsBESnsVgoY5oFtJ