# Managed Deep Agents - Tools

## Executive summary

This video details how to extend the functionality of a managed deep agent by implementing custom tools. Tools allow agents to interact with external systems (like databases or proprietary APIs) beyond built-in capabilities. Custom tools are defined as standard Python/TypeScript functions decorated with `@tool` and require detailed docstrings, which guide the Large Language Model (LLM) on how and when to use them.

## Key takeaways

- Purpose of Tools: Tools give agents capability by allowing interaction with the outside world, such as looking up data in databases or taking actions via external APIs. Built-in tools (e.g., web search) are provided by the underlying model, while custom tools address specific organizational needs.
- Defining Custom Tools: In Python, a custom tool is defined as a function decorated with `@tool` from `LangChain tools`. The function's name becomes the tool name, its parameters are what the LLM must fill out, and the docstring serves as the primary description for the agent.
- Integration Process: To use a custom tool, define it in a separate file (e.g., `tools/lookup.py`), and then import and pass the function reference into the agent definition script.

## Technical details

- Tool Definition Requirements: A custom tool requires three elements: 1) The `@tool` decorator (from `LangChain tools`), 2) A function signature defining necessary parameters, and 3) A comprehensive docstring. This docstring is crucial as it informs the LLM about the tool's purpose and required inputs.
- Tool Implementation Example: The process involves creating a function (e.g., `lookup_customer`) in a dedicated file, decorating it with `@tool`, and then importing this function into the main agent script to expose its capabilities.
- Agent Execution Flow: When an agent is run (e.g., using `MDA dev`), it automatically lists all available tools, including built-in ones (like File Workspace Tools) and custom ones (like the CRM tool). The LLM uses the provided description and parameters to correctly invoke the function.

## Practical implications

- Engineers can significantly expand the scope of an AI agent by integrating proprietary business logic or specialized APIs that are not covered by general-purpose models.
- The structured nature of tool definition (name, parameters, docstring) ensures reliable and predictable interaction between the LLM and external code execution.

## Topics

Agent Development, LangChain, Custom Tools, LLMs, API Integration, Python Programming, LangChain Docs: Managed Deep Agents Tools, LangSmith Docs: Managed Deep Agents Tools

Source: https://www.youtube.com/watch?v=piBwvWgHqkY
