{"record":{"id":"d301b479ba8cdece","repo":"rohitg00/ai-engineering-from-scratch","slug":"agent-message-content-must-be-a-list","errorCode":null,"errorMessage":"agent.message content must be a list","messagePattern":"agent\\.message content must be a list","errorType":"exception","errorClass":"EventStreamError","httpStatus":null,"severity":"error","filePath":"certifications/claude/lessons/12-claude-agent-sdk-and-hooks/code/main.py","lineNumber":80,"sourceCode":"            if event_type == \"event_delta\" and isinstance(event.get(\"text\"), str):\n                preview_parts.append(event[\"text\"])\n            continue\n\n        event_id = event.get(\"id\")\n        if not isinstance(event_id, str) or not event_id:\n            raise EventStreamError(\"persisted events need a non-empty id\")\n        if event_id in seen:\n            continue\n        seen.add(event_id)\n        last_event_id = event_id\n\n        if event_type == \"session.status_running\":\n            status = \"running\"\n            stop_reason = None\n        elif event_type == \"agent.message\":\n            content = event.get(\"content\", [])\n            if not isinstance(content, list):\n                raise EventStreamError(\"agent.message content must be a list\")\n            messages.append(\n                \"\".join(\n                    str(block.get(\"text\", \"\"))\n                    for block in content\n                    if isinstance(block, dict) and block.get(\"type\") == \"text\"\n                )\n            )\n        elif event_type in {\"agent.custom_tool_use\", \"agent.tool_use\", \"agent.mcp_tool_use\"}:\n            actionable.add(event_id)\n        elif event_type in {\"user.custom_tool_result\", \"user.tool_confirmation\"}:\n            reference = event.get(\"custom_tool_use_id\") or event.get(\"tool_use_id\")\n            if not isinstance(reference, str) or reference not in actionable:\n                raise EventStreamError(\"tool result or confirmation must reference a known action\")\n            pending.discard(reference)\n        elif event_type == \"session.status_idle\":\n            status = \"idle\"\n            reason = event.get(\"stop_reason\")\n            if not isinstance(reason, dict) or reason.get(\"type\") not in {\"requires_action\", \"end_turn\"}:","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/certifications/claude/lessons/12-claude-agent-sdk-and-hooks/code/main.py#L62-L98","documentation":"Error \"agent.message content must be a list\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at certifications/claude/lessons/12-claude-agent-sdk-and-hooks/code/main.py:80 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}