_collect_code_execution_tool_ids() — langchain Function Reference
Architecture documentation for the _collect_code_execution_tool_ids() function in chat_models.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD aab782ca_4f87_29fb_27bf_1efa17a219a4["_collect_code_execution_tool_ids()"] a85819c7_917d_4c71_2864_a19e68947340["chat_models.py"] aab782ca_4f87_29fb_27bf_1efa17a219a4 -->|defined in| a85819c7_917d_4c71_2864_a19e68947340 954f0cfe_731b_ac1b_0145_b5a3d210030b["_get_request_payload()"] 954f0cfe_731b_ac1b_0145_b5a3d210030b -->|calls| aab782ca_4f87_29fb_27bf_1efa17a219a4 style aab782ca_4f87_29fb_27bf_1efa17a219a4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/langchain_anthropic/chat_models.py lines 665–691
def _collect_code_execution_tool_ids(formatted_messages: list[dict]) -> set[str]:
"""Collect tool_use IDs that were called by code_execution.
These blocks cannot have cache_control applied per Anthropic API requirements.
"""
code_execution_tool_ids: set[str] = set()
for message in formatted_messages:
if message.get("role") != "assistant":
continue
content = message.get("content", [])
if not isinstance(content, list):
continue
for block in content:
if not isinstance(block, dict):
continue
if block.get("type") != "tool_use":
continue
caller = block.get("caller")
if isinstance(caller, dict):
caller_type = caller.get("type", "")
if caller_type.startswith("code_execution"):
tool_id = block.get("id")
if tool_id:
code_execution_tool_ids.add(tool_id)
return code_execution_tool_ids
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _collect_code_execution_tool_ids() do?
_collect_code_execution_tool_ids() is a function in the langchain codebase, defined in libs/partners/anthropic/langchain_anthropic/chat_models.py.
Where is _collect_code_execution_tool_ids() defined?
_collect_code_execution_tool_ids() is defined in libs/partners/anthropic/langchain_anthropic/chat_models.py at line 665.
What calls _collect_code_execution_tool_ids()?
_collect_code_execution_tool_ids() is called by 1 function(s): _get_request_payload.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free