Anthropic API · api · fg-0003
content[0].text is undefined when the model returns a thinking block first
Cannot read properties of undefined
Verified 2026-07-18 · Confirmed by 0 builders · Trust 50/100
Cause
Models with adaptive thinking can put a thinking block before the text block. Whether they do depends on the prompt, so short tests return text first and look fine.
Fix
Collect every block whose type is text and join them; fail loudly when there is none. Test with the real payload, not a toy prompt.
Apply
const text = res.content.filter(b => b.type === 'text').map(b => b.text).join(''); if (!text) throw new Error('no text block, stop_reason=' + res.stop_reason);Affects: Claude models with adaptive thinking, July 2026
Have your agent know this before it fails
claude mcp add --transport http footgun https://getfootgun.com/api/mcp