OutputToolBinding Class — langchain Architecture
Architecture documentation for the OutputToolBinding class in structured_output.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 0e7f8a9f_a02a_a673_44d3_09b6a018dd6e["OutputToolBinding"] c2936c24_74cd_6911_037b_0f67eebfefee["structured_output.py"] 0e7f8a9f_a02a_a673_44d3_09b6a018dd6e -->|defined in| c2936c24_74cd_6911_037b_0f67eebfefee fcfa0579_edc1_4e85_a010_594ee3a8aeef["from_schema_spec()"] 0e7f8a9f_a02a_a673_44d3_09b6a018dd6e -->|method| fcfa0579_edc1_4e85_a010_594ee3a8aeef 2e00e1b4_350b_ee3e_5dc5_f7ce23fc8893["parse()"] 0e7f8a9f_a02a_a673_44d3_09b6a018dd6e -->|method| 2e00e1b4_350b_ee3e_5dc5_f7ce23fc8893
Relationship Graph
Source Code
libs/langchain_v1/langchain/agents/structured_output.py lines 308–359
class OutputToolBinding(Generic[SchemaT]):
"""Information for tracking structured output tool metadata.
This contains all necessary information to handle structured responses generated via
tool calls, including the original schema, its type classification, and the
corresponding tool implementation used by the tools strategy.
"""
schema: type[SchemaT] | dict[str, Any]
"""The original schema provided for structured output (Pydantic model, dataclass,
TypedDict, or JSON schema dict).
"""
schema_kind: SchemaKind
"""Classification of the schema type for proper response construction."""
tool: BaseTool
"""LangChain tool instance created from the schema for model binding."""
@classmethod
def from_schema_spec(cls, schema_spec: _SchemaSpec[SchemaT]) -> Self:
"""Create an `OutputToolBinding` instance from a `SchemaSpec`.
Args:
schema_spec: The `SchemaSpec` to convert
Returns:
An `OutputToolBinding` instance with the appropriate tool created
"""
return cls(
schema=schema_spec.schema,
schema_kind=schema_spec.schema_kind,
tool=StructuredTool(
args_schema=schema_spec.json_schema,
name=schema_spec.name,
description=schema_spec.description,
),
)
def parse(self, tool_args: dict[str, Any]) -> SchemaT:
"""Parse tool arguments according to the schema.
Args:
tool_args: The arguments from the tool call
Returns:
The parsed response according to the schema type
Raises:
ValueError: If parsing fails
"""
return _parse_with_schema(self.schema, self.schema_kind, tool_args)
Source
Frequently Asked Questions
What is the OutputToolBinding class?
OutputToolBinding is a class in the langchain codebase, defined in libs/langchain_v1/langchain/agents/structured_output.py.
Where is OutputToolBinding defined?
OutputToolBinding is defined in libs/langchain_v1/langchain/agents/structured_output.py at line 308.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free