{"record":{"id":"f0283220c31f4416","repo":"langchain-ai/deepagents","slug":"offload-server-completed-without-a-typed-result","errorCode":null,"errorMessage":"Offload server completed without a typed result.","messagePattern":"Offload server completed without a typed result\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/client/remote_client.py","lineNumber":133,"sourceCode":"    \"\"\"Check a server offload result before any caller indexes it.\n\n    The renderer subscripts these fields by key and unguarded. Validating here\n    means a protocol skew fails with a message naming the problem, instead of a\n    `KeyError` reported as a generic reporting failure for an offload the server\n    already committed.\n\n    Args:\n        result: The `result` object from a `complete` operation response.\n\n    Returns:\n        The same mapping, once its required fields are known to be present.\n\n    Raises:\n        RuntimeError: If a required field is missing or has the wrong type.\n    \"\"\"\n    if not isinstance(result, dict):\n        msg = \"Offload server completed without a typed result.\"\n        raise RuntimeError(msg)  # noqa: TRY004  # protocol fault, not a type misuse\n    status = result.get(\"status\")\n    if not isinstance(status, str) or not status:\n        msg = \"Offload result has no status.\"\n        raise RuntimeError(msg)\n    # Statistics are only meaningful (and only read) for a committed compaction.\n    if status == \"compacted\":\n        for field in _OFFLOAD_RESULT_INT_FIELDS:\n            value = result.get(field)\n            if not isinstance(value, int) or isinstance(value, bool):\n                msg = (\n                    f\"Offload result field {field!r} must be an integer, got \"\n                    f\"{type(value).__name__}.\"\n                )\n                raise RuntimeError(msg)  # noqa: TRY004  # protocol fault\n    return cast(\"OffloadResult\", result)\n\n\ndef _require_thread_id(config: Mapping[str, Any] | None) -> str:","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/client/remote_client.py#L115-L151","documentation":"`_validated_offload_result` type-checks the offload server's result; if the completed result is not a `dict`, it raises `RuntimeError` because no typed `OffloadResult` payload was produced. This is a protocol fault indicating the server finished the offload/compaction but returned an unexpected (non-object) body.","triggerScenarios":"`aoffload` completes and passes the raw result to `_validated_offload_result`, but the deserialized response is `None`, a list, a string, etc., instead of a JSON object.","commonSituations":"Server error pages or empty bodies being deserialized to `None`; client/server version drift changing the response envelope; serialization bugs on the server returning a bare array.","solutions":["Verify server health/logs for why the offload completed without a result object.","Align client and server versions so the offload response schema matches.","Inspect the raw response body to confirm what the server actually returned.","Retry the offload; if reproducible, file a server-side protocol bug."],"exampleFix":"// before: server returns bare result list\nreturn [items]\n// after: return the typed envelope\nreturn {\"status\": \"compacted\", \"items\": items}","handlingStrategy":"type-guard","validationCode":"def looks_like_offload_result(result) -> bool:\n    return isinstance(result, dict) and isinstance(result.get(\"status\"), str) and bool(result[\"status\"])\n# pre-check before calling APIs that consume the result\nassert looks_like_offload_result(raw), \"offload returned no typed result\"","typeGuard":"from typing import TypeGuard\ndef is_offload_result(result: object) -> TypeGuard[dict]:\n    return isinstance(result, dict) and isinstance(result.get(\"status\"), str) and bool(result[\"status\"])","tryCatchPattern":"try:\n    result = await aoffload(...)\nexcept RuntimeError as exc:\n    if \"without a typed result\" in str(exc):\n        inspect_raw_response_and_retry()","preventionTips":["Verify server returns a JSON object envelope, never a bare value or empty body","Align response schema between client and server versions","Monitor server error rates that may surface as non-object bodies"],"tags":["offload","protocol","validation","remote"],"backgroundTag":"invalid-server-response","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}