Home / Function/ test_validation_error_with_invalid_response() — langchain Function Reference

test_validation_error_with_invalid_response() — langchain Function Reference

Architecture documentation for the test_validation_error_with_invalid_response() function in test_response_format.py from the langchain codebase.

Function python LangChainCore Runnables calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  d3c39084_3dca_90f9_645a_60c7f057f5ed["test_validation_error_with_invalid_response()"]
  d1d579f8_d411_ce75_6fa3_d97e725405cb["TestResponseFormatAsToolStrategy"]
  d3c39084_3dca_90f9_645a_60c7f057f5ed -->|defined in| d1d579f8_d411_ce75_6fa3_d97e725405cb
  15eab12c_0956_c53a_4e7b_716084c91cdb["test_validation_error_with_invalid_response()"]
  15eab12c_0956_c53a_4e7b_716084c91cdb -->|calls| d3c39084_3dca_90f9_645a_60c7f057f5ed
  15eab12c_0956_c53a_4e7b_716084c91cdb["test_validation_error_with_invalid_response()"]
  d3c39084_3dca_90f9_645a_60c7f057f5ed -->|calls| 15eab12c_0956_c53a_4e7b_716084c91cdb
  style d3c39084_3dca_90f9_645a_60c7f057f5ed fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/test_response_format.py lines 653–684

    def test_validation_error_with_invalid_response(self) -> None:
        """Test validation error with invalid response.

        Test that StructuredOutputValidationError is raised when tool strategy receives
        invalid response.
        """
        tool_calls = [
            [
                {
                    "name": "WeatherBaseModel",
                    "id": "1",
                    "args": {"invalid_field": "wrong_data", "another_bad_field": 123},
                },
            ],
        ]

        model = FakeToolCallingModel(tool_calls=tool_calls)

        agent = create_agent(
            model,
            [],
            response_format=ToolStrategy(
                WeatherBaseModel,
                handle_errors=False,  # Disable retry to ensure error is raised
            ),
        )

        with pytest.raises(
            StructuredOutputValidationError,
            match=r".*WeatherBaseModel.*",
        ):
            agent.invoke({"messages": [HumanMessage("What's the weather?")]})

Domain

Subdomains

Frequently Asked Questions

What does test_validation_error_with_invalid_response() do?
test_validation_error_with_invalid_response() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/test_response_format.py.
Where is test_validation_error_with_invalid_response() defined?
test_validation_error_with_invalid_response() is defined in libs/langchain_v1/tests/unit_tests/agents/test_response_format.py at line 653.
What does test_validation_error_with_invalid_response() call?
test_validation_error_with_invalid_response() calls 1 function(s): test_validation_error_with_invalid_response.
What calls test_validation_error_with_invalid_response()?
test_validation_error_with_invalid_response() is called by 1 function(s): test_validation_error_with_invalid_response.

Analyze Your Own Codebase

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

Try Supermodel Free