Home / Function/ _handle_structured_output_error() — langchain Function Reference

_handle_structured_output_error() — langchain Function Reference

Architecture documentation for the _handle_structured_output_error() function in factory.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  31584a4b_7eff_75cb_ac2d_a6ac7f732e5b["_handle_structured_output_error()"]
  fd7a28b1_3772_169b_6524_1342f35143b1["factory.py"]
  31584a4b_7eff_75cb_ac2d_a6ac7f732e5b -->|defined in| fd7a28b1_3772_169b_6524_1342f35143b1
  f4b66c38_651c_807a_caca_41f73fbbe516["create_agent()"]
  f4b66c38_651c_807a_caca_41f73fbbe516 -->|calls| 31584a4b_7eff_75cb_ac2d_a6ac7f732e5b
  style 31584a4b_7eff_75cb_ac2d_a6ac7f732e5b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/factory.py lines 511–538

def _handle_structured_output_error(
    exception: Exception,
    response_format: ResponseFormat[Any],
) -> tuple[bool, str]:
    """Handle structured output error.

    Returns `(should_retry, retry_tool_message)`.
    """
    if not isinstance(response_format, ToolStrategy):
        return False, ""

    handle_errors = response_format.handle_errors

    if handle_errors is False:
        return False, ""
    if handle_errors is True:
        return True, STRUCTURED_OUTPUT_ERROR_TEMPLATE.format(error=str(exception))
    if isinstance(handle_errors, str):
        return True, handle_errors
    if isinstance(handle_errors, type):
        if issubclass(handle_errors, Exception) and isinstance(exception, handle_errors):
            return True, STRUCTURED_OUTPUT_ERROR_TEMPLATE.format(error=str(exception))
        return False, ""
    if isinstance(handle_errors, tuple):
        if any(isinstance(exception, exc_type) for exc_type in handle_errors):
            return True, STRUCTURED_OUTPUT_ERROR_TEMPLATE.format(error=str(exception))
        return False, ""
    return True, handle_errors(exception)

Domain

Subdomains

Called By

Frequently Asked Questions

What does _handle_structured_output_error() do?
_handle_structured_output_error() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/factory.py.
Where is _handle_structured_output_error() defined?
_handle_structured_output_error() is defined in libs/langchain_v1/langchain/agents/factory.py at line 511.
What calls _handle_structured_output_error()?
_handle_structured_output_error() is called by 1 function(s): create_agent.

Analyze Your Own Codebase

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

Try Supermodel Free