Home / Function/ _build_tool_message_content() — langchain Function Reference

_build_tool_message_content() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  5f1bf505_60e2_b89c_ee3a_094cab95139a["_build_tool_message_content()"]
  4eaf9f24_fce9_0af1_80e1_f2e4f9935aeb["tool_call_limit.py"]
  5f1bf505_60e2_b89c_ee3a_094cab95139a -->|defined in| 4eaf9f24_fce9_0af1_80e1_f2e4f9935aeb
  2d4474df_60a6_0dd0_a7de_afbe664f4896["after_model()"]
  2d4474df_60a6_0dd0_a7de_afbe664f4896 -->|calls| 5f1bf505_60e2_b89c_ee3a_094cab95139a
  style 5f1bf505_60e2_b89c_ee3a_094cab95139a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/langchain/agents/middleware/tool_call_limit.py lines 52–67

def _build_tool_message_content(tool_name: str | None) -> str:
    """Build the error message content for `ToolMessage` when limit is exceeded.

    This message is sent to the model, so it should not reference thread/run concepts
    that the model has no notion of.

    Args:
        tool_name: Tool name being limited (if specific tool), or `None` for all tools.

    Returns:
        A concise message instructing the model not to call the tool again.
    """
    # Always instruct the model not to call again, regardless of which limit was hit
    if tool_name:
        return f"Tool call limit exceeded. Do not call '{tool_name}' again."
    return "Tool call limit exceeded. Do not make additional tool calls."

Domain

Subdomains

Called By

Frequently Asked Questions

What does _build_tool_message_content() do?
_build_tool_message_content() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/tool_call_limit.py.
Where is _build_tool_message_content() defined?
_build_tool_message_content() is defined in libs/langchain_v1/langchain/agents/middleware/tool_call_limit.py at line 52.
What calls _build_tool_message_content()?
_build_tool_message_content() 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