🧩ResultMessage
Also known as SDK result message, total_cost_usd, Claude Agent SDK ResultMessage
The last message of a run. It has the final text, the cost and how it ended.
Think of it like
It is like the slip you get at the end of a shop visit.
Example
Leo's job runs every night. It saves the session ID and cost from each ResultMessage, so he can resume and budget.
Why it matters
It is the one message that says whether the task worked and what it cost.
Definition
Example code
typescript
if (m.type === "result" && m.subtype === "success") {
console.log(m.result, m.total_cost_usd);
}Common mistake
Key takeaways
- 1End of the loop. Always last.
- 2Subtype says how. success or error.
- 3Cost is an estimate. Not the bill.