Home / Function/ _separate_tool_calls() — langchain Function Reference

_separate_tool_calls() — langchain Function Reference

Architecture documentation for the _separate_tool_calls() function in tool_call_limit.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  6385d4be_67e3_d055_9df4_4d5383df6d8d["_separate_tool_calls()"]
  68f7858b_b207_3223_e360_e5e5b35adf21["ToolCallLimitMiddleware"]
  6385d4be_67e3_d055_9df4_4d5383df6d8d -->|defined in| 68f7858b_b207_3223_e360_e5e5b35adf21
  2d4474df_60a6_0dd0_a7de_afbe664f4896["after_model()"]
  2d4474df_60a6_0dd0_a7de_afbe664f4896 -->|calls| 6385d4be_67e3_d055_9df4_4d5383df6d8d
  69072976_06ba_948b_d3cc_f7ede1e73d0f["_matches_tool_filter()"]
  6385d4be_67e3_d055_9df4_4d5383df6d8d -->|calls| 69072976_06ba_948b_d3cc_f7ede1e73d0f
  2e791b1d_2872_d64f_168d_31d605574212["_would_exceed_limit()"]
  6385d4be_67e3_d055_9df4_4d5383df6d8d -->|calls| 2e791b1d_2872_d64f_168d_31d605574212
  style 6385d4be_67e3_d055_9df4_4d5383df6d8d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/tool_call_limit.py lines 292–322

    def _separate_tool_calls(
        self, tool_calls: list[ToolCall], thread_count: int, run_count: int
    ) -> tuple[list[ToolCall], list[ToolCall], int, int]:
        """Separate tool calls into allowed and blocked based on limits.

        Args:
            tool_calls: List of tool calls to evaluate.
            thread_count: Current thread call count.
            run_count: Current run call count.

        Returns:
            Tuple of `(allowed_calls, blocked_calls, final_thread_count,
                final_run_count)`.
        """
        allowed_calls: list[ToolCall] = []
        blocked_calls: list[ToolCall] = []
        temp_thread_count = thread_count
        temp_run_count = run_count

        for tool_call in tool_calls:
            if not self._matches_tool_filter(tool_call):
                continue

            if self._would_exceed_limit(temp_thread_count, temp_run_count):
                blocked_calls.append(tool_call)
            else:
                allowed_calls.append(tool_call)
                temp_thread_count += 1
                temp_run_count += 1

        return allowed_calls, blocked_calls, temp_thread_count, temp_run_count

Domain

Subdomains

Called By

Frequently Asked Questions

What does _separate_tool_calls() do?
_separate_tool_calls() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/tool_call_limit.py.
Where is _separate_tool_calls() defined?
_separate_tool_calls() is defined in libs/langchain_v1/langchain/agents/middleware/tool_call_limit.py at line 292.
What does _separate_tool_calls() call?
_separate_tool_calls() calls 2 function(s): _matches_tool_filter, _would_exceed_limit.
What calls _separate_tool_calls()?
_separate_tool_calls() is called by 1 function(s): after_model.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free