{"record":{"id":"39052458b053abd3","repo":"rohitg00/ai-engineering-from-scratch","slug":"tool-result-or-confirmation-must-reference-a-known","errorCode":null,"errorMessage":"tool result or confirmation must reference a known action","messagePattern":"tool result or confirmation must reference a known action","errorType":"exception","errorClass":"EventStreamError","httpStatus":null,"severity":"error","filePath":"certifications/claude/lessons/12-claude-agent-sdk-and-hooks/code/main.py","lineNumber":93,"sourceCode":"            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\"}:\n                raise EventStreamError(\"idle status needs a supported stop_reason\")\n            stop_reason = reason[\"type\"]\n            if stop_reason == \"requires_action\":\n                event_ids = reason.get(\"event_ids\")\n                if not isinstance(event_ids, list) or not event_ids or not all(\n                    isinstance(item, str) and item in actionable for item in event_ids\n                ):\n                    raise EventStreamError(\"requires_action must reference known actionable event IDs\")\n                pending = set(event_ids)\n            else:\n                pending.clear()\n        elif event_type == \"session.status_terminated\":\n            status = \"terminated\"","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/certifications/claude/lessons/12-claude-agent-sdk-and-hooks/code/main.py#L75-L111","documentation":"Error \"tool result or confirmation must reference a known action\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at certifications/claude/lessons/12-claude-agent-sdk-and-hooks/code/main.py:93 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"}