langchain-ai/deepagents · error · TypeError

Offload server returned a non-object response.

Error message

Offload server returned a non-object response.

What it means

After the offload POST succeeds at the transport level, `aoffload` expects the response body to be a JSON object (dict). If the server returns a non-dict payload (list, string, number, null), the client raises this TypeError because it cannot read `status`/`request`/`result` from it. This is a server/client protocol fault, not something the caller's input caused.

Source

Thrown at libs/code/deepagents_code/client/remote_client.py:432

                    thread_id=thread_id,
                    operation_id=operation_id,
                )
            except NotFoundError as exc:
                # The route itself is missing. An unregistered thread cannot
                # reach here as a 404: the server catches that and answers 409
                # with its own message. A custom `graph_ref` server, or one
                # older than this operation, never registers the dcode HTTP app,
                # and the SDK's bare "404 Not Found" names neither the cause nor
                # a fix.
                msg = (
                    "This server does not provide dcode's /offload operation. "
                    "Use the built-in dcode server, or upgrade the server to a "
                    "version that registers it."
                )
                raise RuntimeError(msg) from exc
            if not isinstance(response, dict):
                msg = "Offload server returned a non-object response."
                raise TypeError(msg)
            status = response.get("status")
            if status == "complete":
                return _validated_offload_result(response.get("result"))
            request = response.get("request")
            if status != "interrupt" or not is_hook_interrupt_payload(request):
                msg = "Offload server returned an invalid operation response."
                raise RuntimeError(msg)
            invocation = request.get("request")
            invocation_id = (
                invocation.get("invocation_id")
                if isinstance(invocation, dict)
                else None
            )
            if not isinstance(invocation_id, str) or not invocation_id:
                msg = "Offload hook request has no invocation id."
                raise RuntimeError(msg)
            logger.debug(
                "Offload round %d fulfilling hook invocation %s",

View on GitHub (pinned to a1af029e6e)

Solutions

  1. Verify server and client versions match — upgrade or downgrade so both speak the same offload protocol.
  2. Inspect the raw response (curl the endpoint or check server logs) to see what non-object body is actually returned.
  3. Remove/reconfigure intermediaries (proxies, gateways) that might rewrite the response body.
  4. If you operate a custom server, fix the route to return `{"status": ...}`-shaped JSON objects.
Defensive patterns

Strategy: type-guard

Type guard

def is_offload_response(value: object) -> bool:
    return isinstance(value, dict)

Try / catch

try:
    result = await agent.aoffload(config=config, context=ctx, fulfill_hook=hook)
except TypeError as exc:
    if "non-object response" in str(exc):
        logging.error("Offload endpoint returned a non-JSON-object body; check server/proxy")
    else:
        raise

Prevention

When it happens

Trigger: The `/dcode/threads/{thread_id}/offload` route (or an intermediary) returns a non-object body: a bare JSON array or string, an error page, or an unexpected serialization from a mismatched server version.

Common situations: A proxy or gateway replacing the JSON body with an HTML/string error; running a server whose offload response schema predates the client's; a custom reimplementation of the route returning a differently shaped payload.

Related errors


AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29). Data as JSON: /api/errors/e65a78f740943a03. Report an issue: GitHub.