Ag2 Add Custom Tool

Add a custom Python tool to an AG2 `Agent` using the `@tool` decorator. Use when the user wants to give an Agent a new capability backed by Python code (API calls, DB queries, computations, file ops). Covers sync and async tools, parameter typing, Pydantic schema customisation, returning typed `Input` / `ToolResult` (text / data / images / binary), `final=True` early-exit, and dependency injection via `Context` / `Inject` / `Variable` / `Depends`.

ag2ai ccdbe28 2 files · 12.3 KB Updated

File contents

ag2ai/ag2-skills/tree/main/skills/ag2-add-custom-tool commit ccdbe28cef

Frequently asked questions

npx skillmds@latest add ag2ai/ag2-add-custom-tool