I'm getting the following error message bubbling through to OpenRouter when I try to send a request to Claude that contains a function call output. I've created a simple script to replicate the issue as well. What am I doing wrong here?
Error:
message: Provider returned error
error: {
"code": 400,
"message": "Provider returned error",
"metadata": {
"raw": "{\"message\":\"messages.0.content.1: unexpected `tool_use_id` found in `tool_result` blocks: toolu_synthetic_repro_001. Each `tool_result` block must have a corresponding `tool_use` block in the previous message.\"}",
"provider_name": "Amazon Bedrock",
"is_byok": false
}
}
I've attached the script to reproduce the issue. Just run npx tsx repro-openrouter.ts in a TS environment to see it.