Want a ready-made UI? See the Chat UI tutorial.
sessions.messages() while a task runs to get the agent’s reasoning, tool calls, and results.
role (user, assistant, tool), a summary for display, and a type (e.g. browser_action, browser_action_result). Browser action results include a screenshot_url. See List session messages for all fields.