langchain-ai/langgraph · error · ValueError

response_format must be 'array' or 'object'

Error message

response_format must be 'array' or 'object'

What it means

Argument guard in the sync assistants.search method: response_format selects the response shape and only the literals 'array' (plain list) and 'object' (dict with pagination fields) are accepted. Other values are rejected before the HTTP call.

Solutions

  1. Pass response_format="array" or "object"
  2. Omit response_format to use the default
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at libs/sdk-py/langgraph_sdk/_sync/assistants.py:585 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26). Data as JSON: /api/errors/81e448c82049f46b. Report an issue: GitHub.

Appendix: source

Thrown at libs/sdk-py/langgraph_sdk/_sync/assistants.py:585

            `response_format="object"`).

        ???+ example "Example Usage"

            ```python
            client = get_sync_client(url="http://localhost:2024")
            response = client.assistants.search(
                metadata = {"name":"my_name"},
                graph_id="my_graph_id",
                limit=5,
                offset=5,
                response_format="object",
            )
            assistants = response["assistants"]
            next_cursor = response["next"]
            ```
        """
        if response_format not in ("array", "object"):
            raise ValueError("response_format must be 'array' or 'object'")
        payload: dict[str, Any] = {
            "limit": limit,
            "offset": offset,
        }
        if metadata:
            payload["metadata"] = metadata
        if graph_id:
            payload["graph_id"] = graph_id
        if name:
            payload["name"] = name
        if sort_by:
            payload["sort_by"] = sort_by
        if sort_order:
            payload["sort_order"] = sort_order
        if select:
            payload["select"] = select
        next_cursor: str | None = None

View on GitHub (pinned to 38031739e5)