test_create_agent_error_only_model_controllable_params() — langchain Function Reference
Architecture documentation for the test_create_agent_error_only_model_controllable_params() function in test_create_agent_tool_validation.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 09eff0c8_99a6_d3f0_b48c_a4b338a96898["test_create_agent_error_only_model_controllable_params()"] 870e14f1_d0c5_dab7_450a_69cd441301b0["test_create_agent_tool_validation.py"] 09eff0c8_99a6_d3f0_b48c_a4b338a96898 -->|defined in| 870e14f1_d0c5_dab7_450a_69cd441301b0 style 09eff0c8_99a6_d3f0_b48c_a4b338a96898 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/test_create_agent_tool_validation.py lines 304–378
def test_create_agent_error_only_model_controllable_params() -> None:
"""Test that errors only include LLM-controllable parameter issues.
Focused test ensuring that validation errors for LLM-controlled parameters
are clearly reported, while system-injected parameters remain completely
absent from error messages. This provides focused feedback to the LLM.
"""
class StateWithSecrets(AgentState[Any]):
password: str # Example of data not controlled by LLM
@dec_tool
def secure_tool(
username: str,
email: str,
state: Annotated[StateWithSecrets, InjectedState],
) -> str:
"""Tool that validates user credentials.
Args:
username: The username (3-20 chars).
email: The email address.
state: State with password (system-injected).
"""
return f"Validated {username} with email {email}"
# LLM provides invalid username (too short) and invalid email
model = FakeToolCallingModel(
tool_calls=[
[
{
"name": "secure_tool",
"args": {
"username": "ab", # Too short (needs 3-20)
"email": "not-an-email", # Invalid format
},
"id": "call_secure_1",
}
],
[],
]
)
agent = create_agent(
model=model,
tools=[secure_tool],
state_schema=StateWithSecrets,
)
result = agent.invoke(
{
"messages": [HumanMessage("Create account")],
"password": "super_secret_password_12345",
}
)
tool_messages = [m for m in result["messages"] if m.type == "tool"]
assert len(tool_messages) == 1
content = tool_messages[0].content
# The error should mention LLM-controlled parameters
# Note: Pydantic's default validation may or may not catch format issues,
# but the parameters themselves should be present in error messages
assert "username" in content.lower() or "email" in content.lower(), (
"Error should mention at least one LLM-controlled parameter"
)
# Password is system-injected and should not appear
# The LLM doesn't control it, so it shouldn't distract from the actual errors
assert "password" not in content.lower(), (
"Error should NOT mention 'password' (system-injected parameter)"
)
assert "super_secret_password" not in content, (
"Error should NOT contain password value (from system-injected state)"
)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_create_agent_error_only_model_controllable_params() do?
test_create_agent_error_only_model_controllable_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_only_model_controllable_params() defined?
test_create_agent_error_only_model_controllable_params() is defined in libs/langchain_v1/tests/unit_tests/agents/test_create_agent_tool_validation.py at line 304.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free