wrap_model_call() — langchain Function Reference
Architecture documentation for the wrap_model_call() function in anthropic_tools.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD dc9524e3_cb43_2481_1aee_b82424bafcfe["wrap_model_call()"] cc57e604_ebeb_0d7e_259e_ae26b40e03fa["_StateClaudeFileToolMiddleware"] dc9524e3_cb43_2481_1aee_b82424bafcfe -->|defined in| cc57e604_ebeb_0d7e_259e_ae26b40e03fa 219d4c7d_e796_f766_c3b6_e8cfd03bb8de["wrap_model_call()"] 219d4c7d_e796_f766_c3b6_e8cfd03bb8de -->|calls| dc9524e3_cb43_2481_1aee_b82424bafcfe 219d4c7d_e796_f766_c3b6_e8cfd03bb8de["wrap_model_call()"] dc9524e3_cb43_2481_1aee_b82424bafcfe -->|calls| 219d4c7d_e796_f766_c3b6_e8cfd03bb8de style dc9524e3_cb43_2481_1aee_b82424bafcfe fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py lines 262–290
def wrap_model_call(
self,
request: ModelRequest,
handler: Callable[[ModelRequest], ModelResponse],
) -> ModelResponse:
"""Inject Anthropic tool descriptor and optional system prompt."""
# Replace our BaseTool with Anthropic's native tool descriptor
tools = [
t
for t in (request.tools or [])
if getattr(t, "name", None) != self.tool_name
] + [{"type": self.tool_type, "name": self.tool_name}]
# Inject system prompt if provided
overrides: _ModelRequestOverrides = {"tools": tools}
if self.system_prompt:
if request.system_message is not None:
new_system_content = [
*request.system_message.content_blocks,
{"type": "text", "text": f"\n\n{self.system_prompt}"},
]
else:
new_system_content = [{"type": "text", "text": self.system_prompt}]
new_system_message = SystemMessage(
content=cast("list[str | dict[str, str]]", new_system_content)
)
overrides["system_message"] = new_system_message
return handler(request.override(**overrides))
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does wrap_model_call() do?
wrap_model_call() is a function in the langchain codebase, defined in libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py.
Where is wrap_model_call() defined?
wrap_model_call() is defined in libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py at line 262.
What does wrap_model_call() call?
wrap_model_call() calls 1 function(s): wrap_model_call.
What calls wrap_model_call()?
wrap_model_call() is called by 1 function(s): wrap_model_call.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free