Closed dandv closed 2 months ago
Where is it documented that content
should always be a non-empty array? This may be a bug in the documentation, or a misunderstanding of the API's contract.
Either way, this does not sound like a bug in the SDK, so I'm going to go ahead and close this issue.
When Claude doesn't return anything, the content array is empty. This breaks the assumption that the content array will contain an object with a text field. The correct output should be
[ { type: 'text', text: '' } ]
@rattrayalex is correct, that is not a valid assumption and this is the expected behavior for empty responses and matches the behavior on input where "content": [{"type": "text", "text": ""}]
will give you an error.
Unrelated note:
'anthropic-beta': 'messages-2023-12-15', // required to use the Messages API while in beta
Messages API is now GA and you no longer need this header.
Thanks for the clarifications!
I filed this a few months ago (#399) and it turns out it's not a Bedrock issue, and not limited to max_tokens 1.
When Claude doesn't return anything, the
content
array is empty. This breaks the assumption that the content array will contain an object with atext
field. The correct output should beRepro: