awrap_model_call() — langchain Function Reference
Architecture documentation for the awrap_model_call() function in anthropic_tools.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 4e2c1a57_5ac4_0437_9ba4_9c6afd44729b["awrap_model_call()"] cc57e604_ebeb_0d7e_259e_ae26b40e03fa["_StateClaudeFileToolMiddleware"] 4e2c1a57_5ac4_0437_9ba4_9c6afd44729b -->|defined in| cc57e604_ebeb_0d7e_259e_ae26b40e03fa 88574211_7a97_729c_0938_263ee8de0137["awrap_model_call()"] 88574211_7a97_729c_0938_263ee8de0137 -->|calls| 4e2c1a57_5ac4_0437_9ba4_9c6afd44729b 88574211_7a97_729c_0938_263ee8de0137["awrap_model_call()"] 4e2c1a57_5ac4_0437_9ba4_9c6afd44729b -->|calls| 88574211_7a97_729c_0938_263ee8de0137 style 4e2c1a57_5ac4_0437_9ba4_9c6afd44729b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py lines 292–320
async def awrap_model_call(
self,
request: ModelRequest,
handler: Callable[[ModelRequest], Awaitable[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 await handler(request.override(**overrides))
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does awrap_model_call() do?
awrap_model_call() is a function in the langchain codebase, defined in libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py.
Where is awrap_model_call() defined?
awrap_model_call() is defined in libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py at line 292.
What does awrap_model_call() call?
awrap_model_call() calls 1 function(s): awrap_model_call.
What calls awrap_model_call()?
awrap_model_call() is called by 1 function(s): awrap_model_call.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free