Claude sometimes returns no JSON
This happens with images that it's previously had no problem parsing.
When you inspect the returned message, instead of the JSON specified by the tool, you get something like this
"image": "https://s3.amazonaws.com/openai-assets/d9c2c3e4f0fb1c15f05d982f30622844"
Following that URL sends you to the following XML error:
<Error>
<script/>
<Code>PermanentRedirect</Code>
<Message>The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.</Message>
<Endpoint>openai-assets.s3.amazonaws.com</Endpoint>
<Bucket>openai-assets</Bucket>
<RequestId>8TASA3S5ZA1PC3KS</RequestId>
<HostId>VZ6EIZdw1rAtMEIwnW5ZcqVRdmtyoIzaXLcKblm/6yXVqvR9tXBC/5vWVrdXiNUsYb2RwSuenfo=</HostId>
</Error>
Update - I sometimes also just get some empty JSON. I'm pretty sure it's unrelated to any changes I've made, or the images I'm using. So perhaps it's the Claude API being flaky?
You can see here that it's processing the image enough to recognise that it's a form and it should use the tool - it's specifically the tool use that seems to be failing (that empty 'input' key). More often than not right now.
I think I might have fixed this.
As the tool was returning empty JSON, I added some required elements to the schema, eg:
"required": ["id", "question_text", "answer_type"]
This seems to have sorted it.
It seemed to work fine before, so perhaps Anthropic updated tool use to be more fussy.