test_thinking() — langchain Function Reference
Architecture documentation for the test_thinking() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD bde73317_7d7c_4953_a071_7c85c3be53e7["test_thinking()"] f27640dd_3870_5548_d153_f9504ae1021f["test_chat_models.py"] bde73317_7d7c_4953_a071_7c85c3be53e7 -->|defined in| f27640dd_3870_5548_d153_f9504ae1021f style bde73317_7d7c_4953_a071_7c85c3be53e7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/tests/integration_tests/test_chat_models.py lines 1006–1043
def test_thinking() -> 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},
)
input_message = {"role": "user", "content": "Hello"}
response = llm.invoke([input_message])
assert any("thinking" in block for block in response.content)
for block in response.content:
assert isinstance(block, dict)
if block["type"] == "thinking":
assert set(block.keys()) == {"type", "thinking", "signature"}
assert block["thinking"]
assert isinstance(block["thinking"], str)
assert block["signature"]
assert isinstance(block["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("thinking" in block for block in full.content)
for block in full.content:
assert isinstance(block, dict)
if block["type"] == "thinking":
assert set(block.keys()) == {"type", "thinking", "signature", "index"}
assert block["thinking"]
assert isinstance(block["thinking"], str)
assert block["signature"]
assert isinstance(block["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() do?
test_thinking() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py.
Where is test_thinking() defined?
test_thinking() is defined in libs/partners/anthropic/tests/integration_tests/test_chat_models.py at line 1006.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free