Reading the response — content blocks, stop_reason, usage — step 9 of 9
Checkpoint
One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.
Final drill. Build a session-level aggregator across multiple
responses. Write summarize_session(responses) that:
- For each response in the list, calls
parse_response(r)(provided). - Aggregates across all responses:
total_text: alltextfields joined with" | "(skip empty texts).tool_call_count: total number of tool_use blocks across all responses.total_tokens: sum oftokensacross all responses.final_stop: thestop_reasonof the LAST response.
- Returns the aggregate dict.
Two sessions run. Expected output:
agent session: text='Searching... | Found Tokyo ramen guide.' tools=1 tokens=180 final=end_turn
truncated session: text='Starting...' tools=0 tokens=1024 final=max_tokens
⌘↵ runs the editor.read, then continue.
Checkpoint
One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.
Final drill. Build a session-level aggregator across multiple
responses. Write summarize_session(responses) that:
- For each response in the list, calls
parse_response(r)(provided). - Aggregates across all responses:
total_text: alltextfields joined with" | "(skip empty texts).tool_call_count: total number of tool_use blocks across all responses.total_tokens: sum oftokensacross all responses.final_stop: thestop_reasonof the LAST response.
- Returns the aggregate dict.
Two sessions run. Expected output:
agent session: text='Searching... | Found Tokyo ramen guide.' tools=1 tokens=180 final=end_turn
truncated session: text='Starting...' tools=0 tokens=1024 final=max_tokens
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.