TestCollectCodeExecutionToolIds Class — langchain Architecture
Architecture documentation for the TestCollectCodeExecutionToolIds class in test_prompt_caching.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ced2036e_7d46_6b8d_cbe5_b356ff572281["TestCollectCodeExecutionToolIds"] 80b9bbd1_b825_9778_a36c_351fbf1d2478["test_prompt_caching.py"] ced2036e_7d46_6b8d_cbe5_b356ff572281 -->|defined in| 80b9bbd1_b825_9778_a36c_351fbf1d2478 7be50f97_42af_b95f_3ef3_fec084f87351["test_empty_messages()"] ced2036e_7d46_6b8d_cbe5_b356ff572281 -->|method| 7be50f97_42af_b95f_3ef3_fec084f87351 f10195c2_a859_2e87_2d6a_236eb1915935["test_no_code_execution_calls()"] ced2036e_7d46_6b8d_cbe5_b356ff572281 -->|method| f10195c2_a859_2e87_2d6a_236eb1915935 f88a9f58_7462_9a8c_d995_8092c01f02c6["test_single_code_execution_call()"] ced2036e_7d46_6b8d_cbe5_b356ff572281 -->|method| f88a9f58_7462_9a8c_d995_8092c01f02c6 c7897e0c_bf78_9b8a_5a4e_c7b656035d7b["test_multiple_code_execution_calls()"] ced2036e_7d46_6b8d_cbe5_b356ff572281 -->|method| c7897e0c_bf78_9b8a_5a4e_c7b656035d7b 551f8fc9_d276_7820_1fcd_3fe310e43904["test_future_code_execution_version()"] ced2036e_7d46_6b8d_cbe5_b356ff572281 -->|method| 551f8fc9_d276_7820_1fcd_3fe310e43904 fec29e58_6979_9b5d_9927_59a6f101943c["test_ignores_user_messages()"] ced2036e_7d46_6b8d_cbe5_b356ff572281 -->|method| fec29e58_6979_9b5d_9927_59a6f101943c 64734b16_9794_ae40_a080_b291b4f14df6["test_handles_string_content()"] ced2036e_7d46_6b8d_cbe5_b356ff572281 -->|method| 64734b16_9794_ae40_a080_b291b4f14df6
Relationship Graph
Source Code
libs/partners/anthropic/tests/unit_tests/middleware/test_prompt_caching.py lines 343–482
class TestCollectCodeExecutionToolIds:
"""Tests for _collect_code_execution_tool_ids function."""
def test_empty_messages(self) -> None:
"""Test with empty messages list."""
result = _collect_code_execution_tool_ids([])
assert result == set()
def test_no_code_execution_calls(self) -> None:
"""Test messages without any code_execution calls."""
messages = [
{
"role": "user",
"content": [{"type": "text", "text": "Hello"}],
},
{
"role": "assistant",
"content": [
{
"type": "tool_use",
"id": "toolu_regular",
"name": "get_weather",
"input": {"location": "NYC"},
}
],
},
]
result = _collect_code_execution_tool_ids(messages)
assert result == set()
def test_single_code_execution_call(self) -> None:
"""Test with a single code_execution tool call."""
messages = [
{
"role": "assistant",
"content": [
{
"type": "tool_use",
"id": "toolu_code_exec_1",
"name": "get_weather",
"input": {"location": "NYC"},
"caller": {
"type": "code_execution_20250825",
"tool_id": "srvtoolu_abc123",
},
}
],
},
]
result = _collect_code_execution_tool_ids(messages)
assert result == {"toolu_code_exec_1"}
def test_multiple_code_execution_calls(self) -> None:
"""Test with multiple code_execution tool calls."""
messages = [
{
"role": "assistant",
"content": [
{
"type": "tool_use",
"id": "toolu_regular",
"name": "search",
"input": {"query": "test"},
},
{
"type": "tool_use",
"id": "toolu_code_exec_1",
"name": "get_weather",
"input": {"location": "NYC"},
"caller": {
"type": "code_execution_20250825",
"tool_id": "srvtoolu_abc",
},
},
{
"type": "tool_use",
"id": "toolu_code_exec_2",
"name": "get_weather",
"input": {"location": "SF"},
"caller": {
"type": "code_execution_20250825",
Source
Frequently Asked Questions
What is the TestCollectCodeExecutionToolIds class?
TestCollectCodeExecutionToolIds is a class in the langchain codebase, defined in libs/partners/anthropic/tests/unit_tests/middleware/test_prompt_caching.py.
Where is TestCollectCodeExecutionToolIds defined?
TestCollectCodeExecutionToolIds is defined in libs/partners/anthropic/tests/unit_tests/middleware/test_prompt_caching.py at line 343.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free