Home / Function/ awrap_model_call() — langchain Function Reference

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
  88574211_7a97_729c_0938_263ee8de0137["awrap_model_call()"]
  87c73dc6_9eac_4f37_3263_c6a4d3764b6e["_FilesystemClaudeFileToolMiddleware"]
  88574211_7a97_729c_0938_263ee8de0137 -->|defined in| 87c73dc6_9eac_4f37_3263_c6a4d3764b6e
  4e2c1a57_5ac4_0437_9ba4_9c6afd44729b["awrap_model_call()"]
  4e2c1a57_5ac4_0437_9ba4_9c6afd44729b -->|calls| 88574211_7a97_729c_0938_263ee8de0137
  4e2c1a57_5ac4_0437_9ba4_9c6afd44729b["awrap_model_call()"]
  88574211_7a97_729c_0938_263ee8de0137 -->|calls| 4e2c1a57_5ac4_0437_9ba4_9c6afd44729b
  style 88574211_7a97_729c_0938_263ee8de0137 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py lines 784–812

    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

Called By

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 784.
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