-
-
Notifications
You must be signed in to change notification settings - Fork 868
Open
Labels
Description
- This is actually a bug report.
- I am not getting good LLM Results
- I have tried asking for help in the community on discord or discussions and have not received a response.
- I have tried searching the documentation and have not found an answer.
What Model are you using?
- gpt-3.5-turbo
- gpt-4-turbo
- gpt-4
- Other (please specify) Claude Sonnet 4
Describe the bug
We recently bumped our Instructor version from 1.10.0 -> 1.11.3. When using ANTHROPIC_TOOLS mode with an Anthropic model (I tried both Claude Sonnet 4 and 3.7), the following error is thrown:
<exception>
Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'messages.2: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01Tu9X18ypN9Q3tJgrppfVJa. Each `tool_use` block must have a corresponding `tool_result` block in the next message.'}, 'request_id': 'req_011CTf7ydPeSGSBovG3rxx3T'}
</exception>
There is a current bug against Anthropic with a similar error message, but our Anthropic SDK version did not change when we bumped Instructor versions.
For this bug to be hit, the first attempt at validating the model does appear to have to fail. If the model validation succeeds on the first try, this bug appears not to be hit.
To Reproduce
This code reproduces the error.
- Run
test_with_instructor("My name is John Smith")
- Crash is observed.
- Change mode to
ANTHROPIC_JSON
or reduce Instructor version to 1.10.0 - Crash is no longer observed.
- Run with something that will succeed on the first try such as
test_with_instructor("My name is Bob Smith")
- Crash is also no longer observed.
Expected behavior
Expected behavior is no crash, i.e. what happens in 1.10.0 or with ANTHROPIC_JSON
mode.
Screenshots
NA