← All labs
D5·Fix the code
Crashing on a successful response
A production service throws an IndexError a few times a day. The traceback points at response handling, the HTTP status was 200, and the requests look ordinary.
response = client.messages.create(
model="claude-opus-5", max_tokens=4096, messages=messages
)
answer = response.content[0].text
return {"answer": answer}1.How can a 200 response have no content to index?
2.What should be checked, and is stop_details reliable for the branch?