Home / Class/ ExtendedModelResponse Class — langchain Architecture

ExtendedModelResponse Class — langchain Architecture

Architecture documentation for the ExtendedModelResponse class in types.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  494c2ae3_038e_9ef1_ec9c_c13132bfcdf9["ExtendedModelResponse"]
  fb1284e2_76fc_661f_c16d_e084e8c2b175["types.py"]
  494c2ae3_038e_9ef1_ec9c_c13132bfcdf9 -->|defined in| fb1284e2_76fc_661f_c16d_e084e8c2b175

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/types.py lines 290–311

class ExtendedModelResponse(Generic[ResponseT]):
    """Model response with an optional 'Command' from 'wrap_model_call' middleware.

    Use this to return a 'Command' alongside the model response from a
    'wrap_model_call' handler. The command is applied as an additional state
    update after the model node completes, using the graph's reducers (e.g.
    'add_messages' for the 'messages' key).

    Because each 'Command' is applied through the reducer, messages in the
    command are **added alongside** the model response messages rather than
    replacing them. For non-reducer state fields, later commands overwrite
    earlier ones (outermost middleware wins over inner).

    Type Parameters:
        ResponseT: The type of the structured response. Defaults to 'Any' if not specified.
    """

    model_response: ModelResponse[ResponseT]
    """The underlying model response."""

    command: Command[Any] | None = None
    """Optional command to apply as an additional state update."""

Frequently Asked Questions

What is the ExtendedModelResponse class?
ExtendedModelResponse is a class in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/types.py.
Where is ExtendedModelResponse defined?
ExtendedModelResponse is defined in libs/langchain_v1/langchain/agents/middleware/types.py at line 290.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free