new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

LangChain & LangGraph · all subjects

tools and deep agents

8 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Tools parameter in agent definition

Pass tools in the 'tools' list (Python) or 'tools' array (JavaScript) to let the agent call application logic or external services. Tools are defined in local modules, imported into the agent entry, and added to the definition. Remote MCP servers can be added without importing using MCP connectors.

Tools in Managed Deep Agents - definition and purpose

Tools extend what an agent can do by letting it interact with external systems such as fetching real-time data, querying databases, executing code, and taking actions. A tool is a callable function with defined inputs and outputs. The model uses the tool's description and the conversation context to decide when to call it and which arguments to provide.

Managed Deep Agents project structure with tools

The agent entry point should be at the project root and authored tools should be under a tools/ subdirectory. Example structure: my-agent/ containing agent.py (or agent.ts) at root and tools/ folder containing tool modules like customer.py (or customer.ts).

Python tool definition in Managed Deep Agents

Use the @tool decorator with parse_docstring=True from langchain.tools. Define a function with type hints and a docstring. The docstring should include an Args section describing parameters. Example: @tool(parse_docstring=True) def lookup_customer(customer_id: str) -> str: """Look up a customer record by ID. Args: customer_id: Customer ID from the CRM.""" return f"Customer {customer_id} is on the enterprise plan."

TypeScript tool definition in Managed Deep Agents

Use the tool function from langchain with an async handler and a schema object. The schema uses Zod validation with z.object(). Include name, description, and schema properties. Example: export const lookupCustomer = tool(async ({ customerId }) => `Customer ${customerId} is on the enterprise plan.`, { name: "lookup_customer", description: "Look up a customer record by ID.", schema: z.object({ customerId: z.string().describe("Customer ID from the CRM."), }), });

Attaching tools to Managed Deep Agents

Import tools into the project-root agent entry point and pass them in the tools list parameter to define_deep_agent() or defineDeepAgent(). The mda dev and mda deploy commands copy the project files into the compiled build, so imports work the same way as in normal local projects.

Tool naming best practices in Managed Deep Agents

Use clear, unique tool names to avoid collisions.

Loading tools from MCP server

To load tools from a remote MCP server, use an MCP connector.

Give your agent this brain