langchain-ai/langchain · error · ValueError

Received unsupported arguments {kwargs}

Error message

Received unsupported arguments {kwargs}

What it means

`ValueError` from the default `with_structured_output`: after popping the tolerated legacy kwargs `method` and `strict`, extra keyword arguments remain. The default implementation only forwards a schema to `bind_tools`; any other kwarg (e.g. `temperature`, `include_usage`, provider-specific options) is unsupported here and must go to `bind_tools`/model construction instead.

Source

Thrown at libs/core/langchain_core/language_models/chat_models.py:2522

            structured_model.invoke(
                "What weighs more a pound of bricks or a pound of feathers"
            )
            # -> {
            #     'answer': 'They weigh the same',
            #     'justification': 'Both a pound of bricks and a pound of feathers weigh one pound. The weight is the same, but the volume and density of the two substances differ.'
            # }
            ```

        !!! warning "Behavior changed in `langchain-core` 0.2.26"

            Added support for `TypedDict` class.

        """  # noqa: E501
        _ = kwargs.pop("method", None)
        _ = kwargs.pop("strict", None)
        if kwargs:
            msg = f"Received unsupported arguments {kwargs}"
            raise ValueError(msg)

        if type(self).bind_tools is BaseChatModel.bind_tools:
            msg = "with_structured_output is not implemented for this model."
            raise NotImplementedError(msg)

        llm = self.bind_tools(
            [schema],
            tool_choice="any",
            ls_structured_output_format={
                "kwargs": {"method": "function_calling"},
                "schema": schema,
            },
        )
        output_parser: JsonOutputToolsParser
        if isinstance(schema, type) and is_basemodel_subclass(schema):
            output_parser = PydanticToolsParser(tools=[schema], first_tool_only=True)
        else:
            key_name = convert_to_openai_tool(schema)["function"]["name"]

View on GitHub (pinned to e32fa9a52e)

Solutions

  1. Move non-schema options to model construction (`ChatModel(temperature=0)`) or a `bind_tools(...)` call and build the structured chain manually.
  2. Check the concrete model's `with_structured_output` override signature for supported kwargs (`method`, `strict`, etc.).
  3. Remove the unsupported kwarg entirely if it was accidental.
  4. For full control: `model.bind_tools([Schema], tool_choice="any") | PydanticToolsParser(tools=[Schema], first_tool_only=True)`.

Example fix

# before
chain = model.with_structured_output(Schema, temperature=0, method="function_calling")

# after
model = ChatModel(temperature=0)
chain = model.with_structured_output(Schema, method="function_calling")
Defensive patterns

Strategy: validation

Validate before calling

allowed = {"method", "strict"}
extra = set(kwargs) - allowed
if extra:
    raise ValueError(f"pass these to the model constructor instead: {extra}")

Try / catch

try:
    chain = model.with_structured_output(Schema, **opts)
except ValueError as e:
    if "unsupported arguments" in str(e):
        opts = {k: v for k, v in opts.items() if k in {"method", "strict"}}
        chain = model.with_structured_output(Schema, **opts)
    else:
        raise

Prevention

When it happens

Trigger: Calling `model.with_structured_output(Schema, method="json_schema", temperature=0)` or passing provider-specific kwargs like `parallel_tool_calls=False` directly to `with_structured_output` on a model using the base implementation.

Common situations: Copy-pasting provider-specific examples (OpenAI's `method=`, Anthropic options) onto a model whose override doesn't accept them; upgrading providers where kwargs moved; trying to set sampling params at structured-output time.

Related errors


AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14). Data as JSON: /api/errors/d86ff11b7fb3497b. Report an issue: GitHub.