test_create_agent_error_content_with_multiple_params() — langchain Function Reference
Architecture documentation for the test_create_agent_error_content_with_multiple_params() function in test_create_agent_tool_validation.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 7aa8f44b_b152_ed33_1a41_a01ea065ffe9["test_create_agent_error_content_with_multiple_params()"] 870e14f1_d0c5_dab7_450a_69cd441301b0["test_create_agent_tool_validation.py"] 7aa8f44b_b152_ed33_1a41_a01ea065ffe9 -->|defined in| 870e14f1_d0c5_dab7_450a_69cd441301b0 style 7aa8f44b_b152_ed33_1a41_a01ea065ffe9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/test_create_agent_tool_validation.py lines 184–298
def test_create_agent_error_content_with_multiple_params() -> None:
"""Test that error messages only include LLM-controlled parameter errors.
Uses create_agent to verify that when a tool with both LLM-controlled
and system-injected parameters receives invalid arguments, the error message:
1. Contains details about LLM-controlled parameter errors (query, limit)
2. Does NOT contain system-injected parameter names (state, store, runtime)
3. Does NOT contain values from system-injected parameters
4. Properly formats the validation errors for LLM correction
This ensures the LLM receives focused, actionable feedback.
"""
class TestState(AgentState[Any]):
user_id: str
api_key: str
session_data: dict[str, Any]
@dec_tool
def complex_tool(
query: str,
limit: int,
state: Annotated[TestState, InjectedState],
store: Annotated[BaseStore, InjectedStore()],
runtime: ToolRuntime,
) -> str:
"""A complex tool with multiple injected and non-injected parameters.
Args:
query: The search query string.
limit: Maximum number of results to return.
state: The graph state (injected).
store: The persistent store (injected).
runtime: The tool runtime context (injected).
"""
# Access injected params to verify they work in normal execution
user = state.get("user_id", "unknown")
return f"Results for '{query}' (limit={limit}, user={user})"
# Create a model that makes an incorrect tool call with multiple errors:
# - query is wrong type (int instead of str)
# - limit is missing
# Then returns no tool calls to end the loop
model = FakeToolCallingModel(
tool_calls=[
[
{
"name": "complex_tool",
"args": {
"query": 12345, # Wrong type - should be str
# "limit" is missing - required field
},
"id": "call_complex_1",
}
],
[], # No tool calls on second iteration to end the loop
]
)
# Create an agent with the complex tool and custom state
# Need to provide a store since the tool uses InjectedStore
agent = create_agent(
model=model,
tools=[complex_tool],
state_schema=TestState,
store=InMemoryStore(),
)
# Invoke with sensitive data in state
result = agent.invoke(
{
"messages": [HumanMessage("Search for something")],
"user_id": "user_12345",
"api_key": "sk-secret-key-abc123xyz",
"session_data": {"token": "secret_session_token"},
}
)
# Find the tool error message
tool_messages = [m for m in result["messages"] if m.type == "tool"]
assert len(tool_messages) == 1
tool_message = tool_messages[0]
Domain
Subdomains
Source
Frequently Asked Questions
What does test_create_agent_error_content_with_multiple_params() do?
test_create_agent_error_content_with_multiple_params() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/test_create_agent_tool_validation.py.
Where is test_create_agent_error_content_with_multiple_params() defined?
test_create_agent_error_content_with_multiple_params() is defined in libs/langchain_v1/tests/unit_tests/agents/test_create_agent_tool_validation.py at line 184.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free