Wire the real model — swap fake_llm for the Anthropic SDK shape — step 8 of 9
Write extract_text_and_tools(response) that takes a response
object (real anthropic.types.Message OR a MockMessage with
matching attribute access) and returns a tuple (text_parts, tool_calls):
text_partsis a list of strings, one per text block inresponse.content, in order.tool_callsis a list of dicts, one per tool_use block, each shaped{"id": ..., "name": ..., "input": ...}.
Iterate response.content, branch on block.type, build both
lists. Skip blocks whose type is neither "text" nor "tool_use"
(forward-compat for thinking blocks — they exist but you don't
need them here).
The script will run two cases. Expected output:
text=['Let me look that up.'] tools=[{'id': 'toolu_01', 'name': 'search', 'input': {'q': 'ramen'}}]
text=['Found a 2026 guide.', 'Hope this helps!'] tools=[]
Write extract_text_and_tools(response) that takes a response
object (real anthropic.types.Message OR a MockMessage with
matching attribute access) and returns a tuple (text_parts, tool_calls):
text_partsis a list of strings, one per text block inresponse.content, in order.tool_callsis a list of dicts, one per tool_use block, each shaped{"id": ..., "name": ..., "input": ...}.
Iterate response.content, branch on block.type, build both
lists. Skip blocks whose type is neither "text" nor "tool_use"
(forward-compat for thinking blocks — they exist but you don't
need them here).
The script will run two cases. Expected output:
text=['Let me look that up.'] tools=[{'id': 'toolu_01', 'name': 'search', 'input': {'q': 'ramen'}}]
text=['Found a 2026 guide.', 'Hope this helps!'] tools=[]
this step needs the editor
on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.