test_thinking_v1() — langchain Function Reference
Architecture documentation for the test_thinking_v1() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ee16de13_68c6_584d_0e7e_b8f6c87c2421["test_thinking_v1()"] f27640dd_3870_5548_d153_f9504ae1021f["test_chat_models.py"] ee16de13_68c6_584d_0e7e_b8f6c87c2421 -->|defined in| f27640dd_3870_5548_d153_f9504ae1021f style ee16de13_68c6_584d_0e7e_b8f6c87c2421 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/tests/integration_tests/test_chat_models.py lines 1048–1088
def test_thinking_v1() -> None:
llm = ChatAnthropic(
model="claude-sonnet-4-5-20250929", # type: ignore[call-arg]
max_tokens=5_000, # type: ignore[call-arg]
thinking={"type": "enabled", "budget_tokens": 2_000},
output_version="v1",
)
input_message = {"role": "user", "content": "Hello"}
response = llm.invoke([input_message])
assert any("reasoning" in block for block in response.content)
for block in response.content:
assert isinstance(block, dict)
if block["type"] == "reasoning":
assert set(block.keys()) == {"type", "reasoning", "extras"}
assert block["reasoning"]
assert isinstance(block["reasoning"], str)
signature = block["extras"]["signature"]
assert signature
assert isinstance(signature, str)
# Test streaming
full: BaseMessageChunk | None = None
for chunk in llm.stream([input_message]):
full = cast(BaseMessageChunk, chunk) if full is None else full + chunk
assert isinstance(full, AIMessageChunk)
assert isinstance(full.content, list)
assert any("reasoning" in block for block in full.content)
for block in full.content:
assert isinstance(block, dict)
if block["type"] == "reasoning":
assert set(block.keys()) == {"type", "reasoning", "extras", "index"}
assert block["reasoning"]
assert isinstance(block["reasoning"], str)
signature = block["extras"]["signature"]
assert signature
assert isinstance(signature, str)
# Test pass back in
next_message = {"role": "user", "content": "How are you?"}
_ = llm.invoke([input_message, full, next_message])
Domain
Subdomains
Source
Frequently Asked Questions
What does test_thinking_v1() do?
test_thinking_v1() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py.
Where is test_thinking_v1() defined?
test_thinking_v1() is defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py at line 1048.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free