API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.8: tool_use ids were found without tool_result blocks immediately after:
toolu_01JJLWxfcBw93tw2yUcSaro4. Each tool_use block must have a corresponding tool_result block in the next message."}}
Steps to Reproduce
Send a request to the API that includes a tool_use block in the messages array.
Do not include a corresponding tool_result block immediately after the tool_use block.
Observe the API response.
Expected Behavior
The API should process the request successfully if all required message blocks are present and correctly ordered.
Actual Behavior
The API returns a 400 Bad Request error, indicating that a tool_use block was found without a corresponding tool_result block immediately after it.
Additional Context
The error message specifically points to messages.8, suggesting the issue is with the 9th message in the array.
The error occurs when the message sequence includes a tool_use block that is not immediately followed by a tool_result block, which is required by the API protocol.
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.8:
tool_useids were found withouttool_resultblocks immediately after:toolu_01JJLWxfcBw93tw2yUcSaro4. Each
tool_useblock must have a correspondingtool_resultblock in the next message."}}Steps to Reproduce
Send a request to the API that includes a tool_use block in the messages array.
Do not include a corresponding tool_result block immediately after the tool_use block.
Observe the API response.
Expected Behavior
The API should process the request successfully if all required message blocks are present and correctly ordered.
Actual Behavior
The API returns a 400 Bad Request error, indicating that a tool_use block was found without a corresponding tool_result block immediately after it.
Additional Context
The error message specifically points to messages.8, suggesting the issue is with the 9th message in the array.
The error occurs when the message sequence includes a tool_use block that is not immediately followed by a tool_result block, which is required by the API protocol.