test_extras_with_cache_control() — langchain Function Reference
Architecture documentation for the test_extras_with_cache_control() function in test_chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 6e94ba49_9e8d_c5d9_6712_fde676086c4c["test_extras_with_cache_control()"] 18428dc5_a41b_90c6_88ad_615296ee3311["test_chat_models.py"] 6e94ba49_9e8d_c5d9_6712_fde676086c4c -->|defined in| 18428dc5_a41b_90c6_88ad_615296ee3311 style 6e94ba49_9e8d_c5d9_6712_fde676086c4c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/tests/unit_tests/test_chat_models.py lines 2181–2205
def test_extras_with_cache_control() -> None:
"""Test that extras with `cache_control` are merged into tool definitions."""
from langchain_core.tools import tool
@tool(extras={"cache_control": {"type": "ephemeral"}})
def search_files(query: str) -> str:
"""Search files."""
return f"Results for {query}"
model = ChatAnthropic(model=MODEL_NAME) # type: ignore[call-arg]
model_with_tools = model.bind_tools([search_files])
payload = model_with_tools._get_request_payload( # type: ignore[attr-defined]
"test",
**model_with_tools.kwargs, # type: ignore[attr-defined]
)
search_tool = None
for tool_def in payload["tools"]:
if isinstance(tool_def, dict) and tool_def.get("name") == "search_files":
search_tool = tool_def
break
assert search_tool is not None
assert search_tool.get("cache_control") == {"type": "ephemeral"}
Domain
Subdomains
Source
Frequently Asked Questions
What does test_extras_with_cache_control() do?
test_extras_with_cache_control() is a function in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py.
Where is test_extras_with_cache_control() defined?
test_extras_with_cache_control() is defined in libs/partners/anthropic/tests/unit_tests/test_chat_models.py at line 2181.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free