Home / Function/ test_tool_message_error_status() — langchain Function Reference

test_tool_message_error_status() — langchain Function Reference

Architecture documentation for the test_tool_message_error_status() function in chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  a7a03c2a_3ba5_2265_8470_0b6200f9e745["test_tool_message_error_status()"]
  971e928f_9c9b_ce7a_b93d_e762f2f5aa54["ChatModelIntegrationTests"]
  a7a03c2a_3ba5_2265_8470_0b6200f9e745 -->|defined in| 971e928f_9c9b_ce7a_b93d_e762f2f5aa54
  style a7a03c2a_3ba5_2265_8470_0b6200f9e745 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/standard-tests/langchain_tests/integration_tests/chat_models.py lines 2026–2091

    def test_tool_message_error_status(
        self, model: BaseChatModel, my_adder_tool: BaseTool
    ) -> None:
        """Test that `ToolMessage` with `status="error"` can be handled.

        These messages may take the form:

        ```python
        ToolMessage(
            "Error: Missing required argument 'b'.",
            name="my_adder_tool",
            tool_call_id="abc123",
            status="error",
        )
        ```

        If possible, the `status` field should be parsed and passed appropriately
        to the model.

        This test is optional and should be skipped if the model does not support
        tool calling (see configuration below).

        ??? note "Configuration"

            To disable tool calling tests, set `has_tool_calling` to `False` in your
            test class:

            ```python
            class TestMyChatModelIntegration(ChatModelIntegrationTests):
                @property
                def has_tool_calling(self) -> bool:
                    return False
            ```

        ??? question "Troubleshooting"

            If this test fails, check that the `status` field on `ToolMessage`
            objects is either ignored or passed to the model appropriately.

        """
        if not self.has_tool_calling:
            pytest.skip("Test requires tool calling.")

        model_with_tools = model.bind_tools([my_adder_tool])
        messages = [
            HumanMessage("What is 1 + 2"),
            AIMessage(
                "",
                tool_calls=[
                    {
                        "name": "my_adder_tool",
                        "args": {"a": 1},
                        "id": "abc123",
                        "type": "tool_call",
                    },
                ],
            ),
            ToolMessage(
                "Error: Missing required argument 'b'.",
                name="my_adder_tool",
                tool_call_id="abc123",
                status="error",
            ),
        ]
        result = model_with_tools.invoke(messages)
        assert isinstance(result, AIMessage)

Domain

Subdomains

Frequently Asked Questions

What does test_tool_message_error_status() do?
test_tool_message_error_status() is a function in the langchain codebase, defined in libs/standard-tests/langchain_tests/integration_tests/chat_models.py.
Where is test_tool_message_error_status() defined?
test_tool_message_error_status() is defined in libs/standard-tests/langchain_tests/integration_tests/chat_models.py at line 2026.

Analyze Your Own Codebase

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

Try Supermodel Free