test_unified_error_messages() — langchain Function Reference
Architecture documentation for the test_unified_error_messages() function in test_tool_call_limit.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD b0da1855_cb71_f60d_d52e_6a3691adee18["test_unified_error_messages()"] a75b8390_08d3_7137_c8a7_9d78fc0c4517["test_tool_call_limit.py"] b0da1855_cb71_f60d_d52e_6a3691adee18 -->|defined in| a75b8390_08d3_7137_c8a7_9d78fc0c4517 style b0da1855_cb71_f60d_d52e_6a3691adee18 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_call_limit.py lines 535–559
def test_unified_error_messages() -> None:
"""Test that error messages instruct model not to call again for both run and thread limits.
Previously, only thread limit messages included 'Do not' instruction.
Now both run and thread limit messages should include it.
"""
middleware = ToolCallLimitMiddleware(thread_limit=10, run_limit=1, exit_behavior="continue")
runtime = None
# Test with run limit exceeded (thread limit not exceeded)
state = ToolCallLimitState(
messages=[AIMessage("Response", tool_calls=[{"name": "search", "args": {}, "id": "2"}])],
thread_tool_call_count={"__all__": 1}, # Under thread limit
run_tool_call_count={"__all__": 1}, # At run limit, next call will exceed
)
result = middleware.after_model(state, runtime) # type: ignore[arg-type]
assert result is not None
# Check the error message includes "Do not" instruction
error_messages = [msg for msg in result["messages"] if isinstance(msg, ToolMessage)]
assert len(error_messages) == 1
error_content = error_messages[0].content
assert "Do not" in error_content, (
"Run limit error message should include 'Do not' instruction to guide model behavior"
)
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_unified_error_messages() do?
test_unified_error_messages() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_call_limit.py.
Where is test_unified_error_messages() defined?
test_unified_error_messages() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_tool_call_limit.py at line 535.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free