langchain-ai/langgraph · error · ValueError

response_format must be 'array' or 'object', got

Error message

response_format must be 'array' or 'object', got {response_format!r}

What it means

Argument guard in the async assistants.search client method: response_format must be exactly 'array' (return a plain list) or 'object' (return a dict with pagination info like next_cursor). Any other value is rejected before the HTTP request is made.

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/_async/assistants.py:584 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/73a2aed100e5679b. Report an issue: GitHub.

Appendix: source

Thrown at libs/sdk-py/langgraph_sdk/_async/assistants.py:584

            `response_format="object"`).

        ???+ example "Example Usage"

            ```python
            client = get_client(url="http://localhost:2024")
            response = await client.assistants.search(
                metadata = {"name":"my_name"},
                graph_id="my_graph_id",
                limit=5,
                offset=5,
                response_format="object"
            )
            next_cursor = response["next"]
            assistants = response["assistants"]
            ```
        """
        if response_format not in ("array", "object"):
            raise ValueError(
                f"response_format must be 'array' or 'object', got {response_format!r}"
            )
        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

View on GitHub (pinned to 38031739e5)