test_manual_tool_call_msg() — langchain Function Reference
Architecture documentation for the test_manual_tool_call_msg() function in test_base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 88067420_6d76_2225_4d78_b144fd5f9184["test_manual_tool_call_msg()"] bd382a4e_442c_13ae_530c_6e34bc43623d["test_base.py"] 88067420_6d76_2225_4d78_b144fd5f9184 -->|defined in| bd382a4e_442c_13ae_530c_6e34bc43623d style 88067420_6d76_2225_4d78_b144fd5f9184 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/openai/tests/integration_tests/chat_models/test_base.py lines 545–590
def test_manual_tool_call_msg(use_responses_api: bool) -> None:
"""Test passing in manually construct tool call message."""
llm = ChatOpenAI(
model="gpt-5-nano", temperature=0, use_responses_api=use_responses_api
)
llm_with_tool = llm.bind_tools(tools=[GenerateUsername])
msgs: list = [
HumanMessage("Sally has green hair, what would her username be?"),
AIMessage(
content="",
tool_calls=[
ToolCall(
name="GenerateUsername",
args={"name": "Sally", "hair_color": "green"},
id="foo",
type="tool_call",
)
],
),
ToolMessage("sally_green_hair", tool_call_id="foo"),
]
output: AIMessage = cast(AIMessage, llm_with_tool.invoke(msgs))
assert output.content
# Should not have called the tool again.
assert not output.tool_calls
assert not output.invalid_tool_calls
# OpenAI should error when tool call id doesn't match across AIMessage and
# ToolMessage
msgs = [
HumanMessage("Sally has green hair, what would her username be?"),
AIMessage(
content="",
tool_calls=[
ToolCall(
name="GenerateUsername",
args={"name": "Sally", "hair_color": "green"},
id="bar",
type="tool_call",
)
],
),
ToolMessage("sally_green_hair", tool_call_id="foo"),
]
with pytest.raises(Exception):
llm_with_tool.invoke(msgs)
Domain
Subdomains
Source
Frequently Asked Questions
What does test_manual_tool_call_msg() do?
test_manual_tool_call_msg() is a function in the langchain codebase, defined in libs/partners/openai/tests/integration_tests/chat_models/test_base.py.
Where is test_manual_tool_call_msg() defined?
test_manual_tool_call_msg() is defined in libs/partners/openai/tests/integration_tests/chat_models/test_base.py at line 545.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free