test_responses_integration_matrix() — langchain Function Reference
Architecture documentation for the test_responses_integration_matrix() function in test_responses_spec.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 7f729c04_c50c_2eea_c486_67a2676c7829["test_responses_integration_matrix()"] e8aafd1b_21af_e716_6b31_14e1cb032faa["test_responses_spec.py"] 7f729c04_c50c_2eea_c486_67a2676c7829 -->|defined in| e8aafd1b_21af_e716_6b31_14e1cb032faa 99d8fafd_9703_0e81_2299_11884efd897a["_make_tool()"] 7f729c04_c50c_2eea_c486_67a2676c7829 -->|calls| 99d8fafd_9703_0e81_2299_11884efd897a style 7f729c04_c50c_2eea_c486_67a2676c7829 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/test_responses_spec.py lines 83–166
def test_responses_integration_matrix(case: TestCase) -> None:
if case.name == "asking for information that does not fit into the response format":
pytest.xfail(
"currently failing due to undefined behavior when model cannot conform to "
"any of the structured response formats."
)
def get_employee_role(*, name: str) -> str | None:
for e in EMPLOYEES:
if e.name == name:
return e.role
return None
def get_employee_department(*, name: str) -> str | None:
for e in EMPLOYEES:
if e.name == name:
return e.department
return None
role_tool = _make_tool(
get_employee_role,
name="get_employee_role",
description="Get the employee role by name",
)
dept_tool = _make_tool(
get_employee_department,
name="get_employee_department",
description="Get the employee department by name",
)
response_format_spec = case.response_format
if isinstance(response_format_spec, dict):
response_format_spec = [response_format_spec]
# Unwrap nested schema objects
response_format_spec = [item.get("schema", item) for item in response_format_spec]
if len(response_format_spec) == 1:
tool_output = ToolStrategy(response_format_spec[0])
else:
tool_output = ToolStrategy({"oneOf": response_format_spec})
llm_request_count = 0
for assertion in case.assertions_by_invocation:
def on_request(_request: httpx.Request) -> None:
nonlocal llm_request_count
llm_request_count += 1
http_client = httpx.Client(
event_hooks={"request": [on_request]},
)
model = ChatOpenAI(
model="gpt-4o",
temperature=0,
http_client=http_client,
)
agent = create_agent(
model,
tools=[role_tool["tool"], dept_tool["tool"]],
system_prompt=AGENT_PROMPT,
response_format=tool_output,
)
result = agent.invoke({"messages": [HumanMessage(assertion.prompt)]})
# Count tool calls
assert role_tool["mock"].call_count == assertion.tools_with_expected_calls.get_employee_role
assert (
dept_tool["mock"].call_count
== assertion.tools_with_expected_calls.get_employee_department
)
# Count LLM calls
assert llm_request_count == assertion.llm_request_count
# Check last message content
last_message = result["messages"][-1]
assert last_message.content == assertion.expected_last_message
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_responses_integration_matrix() do?
test_responses_integration_matrix() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/test_responses_spec.py.
Where is test_responses_integration_matrix() defined?
test_responses_integration_matrix() is defined in libs/langchain_v1/tests/unit_tests/agents/test_responses_spec.py at line 83.
What does test_responses_integration_matrix() call?
test_responses_integration_matrix() calls 1 function(s): _make_tool.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free