{"record":{"id":"a7a0e2da20f36c46","repo":"rohitg00/ai-engineering-from-scratch","slug":"transport-has-no-scripted-response-left","errorCode":null,"errorMessage":"transport has no scripted response left","messagePattern":"transport has no scripted response left","errorType":"exception","errorClass":"ProtocolError","httpStatus":null,"severity":"error","filePath":"certifications/claude/lessons/08-messages-api-and-application-lifecycle/code/main.py","lineNumber":67,"sourceCode":"        delivery = \"message-batch\"\n    elif needs.progressive_output:\n        delivery = \"streaming\"\n    else:\n        delivery = \"synchronous\"\n    return {\"client\": client, \"delivery\": delivery}\n\n\nclass ScriptedTransport:\n    \"\"\"A stateless transport that returns scripted API responses.\"\"\"\n\n    def __init__(self, responses: list[dict[str, Any]]) -> None:\n        self._responses = copy.deepcopy(responses)\n        self.requests: list[list[dict[str, Any]]] = []\n\n    def create(self, messages: list[dict[str, Any]]) -> dict[str, Any]:\n        self.requests.append(copy.deepcopy(messages))\n        if not self._responses:\n            raise ProtocolError(\"transport has no scripted response left\")\n        return self._responses.pop(0)\n\n\nclass MessageLifecycle:\n    \"\"\"Own conversation state and advance it until the model ends the turn.\"\"\"\n\n    def __init__(\n        self,\n        transport: ScriptedTransport,\n        tools: dict[str, Callable[[dict[str, Any]], Any]] | None = None,\n        max_turns: int = 8,\n    ) -> None:\n        if max_turns < 1:\n            raise ValueError(\"max_turns must be positive\")\n        self.transport = transport\n        self.tools = tools or {}\n        self.max_turns = max_turns\n","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/certifications/claude/lessons/08-messages-api-and-application-lifecycle/code/main.py#L49-L85","documentation":"Error \"transport has no scripted response left\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at certifications/claude/lessons/08-messages-api-and-application-lifecycle/code/main.py:67 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"}