{"record":{"id":"7587bdb59d4d15f2","repo":"rohitg00/ai-engineering-from-scratch","slug":"independent-requests-must-be-positive","errorCode":null,"errorMessage":"independent_requests must be positive","messagePattern":"independent_requests must be positive","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"certifications/claude/lessons/08-messages-api-and-application-lifecycle/code/main.py","lineNumber":43,"sourceCode":"    messages: list[dict[str, Any]]\n    turns: int\n\n\n@dataclass(frozen=True)\nclass AccessNeeds:\n    \"\"\"Workload facts used to choose a client and completion pattern.\"\"\"\n\n    supported_sdk: bool = True\n    custom_transport: bool = False\n    progressive_output: bool = False\n    independent_requests: int = 1\n    can_wait: bool = False\n\n\ndef choose_access_pattern(needs: AccessNeeds) -> dict[str, str]:\n    \"\"\"Choose SDK versus REST separately from sync, stream, or batch.\"\"\"\n    if needs.independent_requests < 1:\n        raise ValueError(\"independent_requests must be positive\")\n    if needs.progressive_output and needs.can_wait and needs.independent_requests > 1:\n        raise ValueError(\"message batches do not provide progressive per-token output\")\n\n    client = \"raw-rest\" if needs.custom_transport or not needs.supported_sdk else \"sdk\"\n    if needs.can_wait and needs.independent_requests > 1:\n        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)","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/certifications/claude/lessons/08-messages-api-and-application-lifecycle/code/main.py#L25-L61","documentation":"Error \"independent_requests must be positive\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at certifications/claude/lessons/08-messages-api-and-application-lifecycle/code/main.py:43 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"}