Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Document-Processing-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,36 @@
</li>
</ul>
</li>
<li>AI Agent Tools
<ul>
<li>
<a href="/document-processing/ai-agent-tools/overview">Overview</a>
</li>
<li>
<a href="/document-processing/ai-agent-tools/tools">Tools</a>
</li>
<li>
<a href="/document-processing/ai-agent-tools/getting-started">Getting Started</a>
<ul>
<li>
<a href="/document-processing/ai-agent-tools/getting-started-in-memory-mode">In-Memory Mode</a>
</li>
<li>
<a href="/document-processing/ai-agent-tools/getting-started-storage-mode">Storage Mode</a>
</li>
</ul>
</li>
<li>
<a href="/document-processing/ai-agent-tools/customization">Customization</a>
</li>
<li>
<a href="/document-processing/ai-agent-tools/example-prompts">Example Prompts</a>
</li>
<li>
<a href="/document-processing/ai-agent-tools/example-use-cases">Example Use Cases</a>
</li>
</ul>
</li>
<li>
MCP Server
<ul>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 25 additions & 17 deletions Document-Processing/ai-agent-tools/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ control: AI Agent Tools
documentation: ug
---

# Customize the Agent Tool Library
# Customize the AI Agent Tool Library

The Syncfusion Document SDK Agent Tool library is designed to be extensible. This guide walks you through creating a custom agent tool class and registering the tools with an AI agent so they are callable alongside the built-in tools.
The [Syncfusion Document SDK AI Agent Tool library](https://www.nuget.org/packages/Syncfusion.DocIO.Net.Core) is designed to be extensible. This guide walks you through creating a custom agent tool class and registering the tools with an AI agent so they are callable alongside the built-in tools.


## Creating a Custom Agent Tool Class
## Creating a Custom AI Agent Tool Class

Follow these steps to expose new document operations to the AI agent.
Follow these steps to enable new document operations to the [AI agent tool library](https://github.com/SyncfusionExamples/DocIO-Examples/tree/main).

**Step 1: Create a Custom Agent Tool by Inheriting AgentToolBase**
**Step 1: Clone the repository**

Create a new class that inherits from `AgentToolBase` (in the `Syncfusion.AI.AgentTools.Core` namespace) and accepts a document manager through its constructor:
```bash
git clone https://github.com/syncfusion/document-sdk-ai-agent-tools.git
cd Document-SDK-AI-Agent-Tools
```

**Step 2: Create a Custom AI Agent Tool by Inheriting AgentToolBase**

Open the Syncfusion.DocumentSDK.AI.AgentTools library project. Then, create a new class inside the Tools that inherits from `AgentToolBase` (in the `Syncfusion.AI.AgentTools.Core` namespace) and accepts a document manager through its constructor:

```csharp
using Syncfusion.AI.AgentTools.Core;
Expand Down Expand Up @@ -46,7 +53,7 @@ namespace Syncfusion.AI.AgentTools.Word
}
```

**Step 2: Add Tool Methods with [Tool]**
**Step 3: Add Tool Methods with [Tool]**

Add `public` instance methods and decorate each one with `[Tool]`, providing a name and a description that the AI agent will use to understand when to call it:

Expand All @@ -60,7 +67,7 @@ public AgentToolResult AddTextWatermark(...)
}
```

**Step 3: Annotate Parameters with [ToolParameter]**
**Step 4: Annotate Parameters with [ToolParameter]**

Decorate each method parameter with `[ToolParameter]` to give the AI a natural-language description of what value to pass:

Expand All @@ -74,7 +81,7 @@ public AgentToolResult AddTextWatermark(
string? outputFilePath = null)
```

**Step 4: Return AgentToolResult**
**Step 5: Return AgentToolResult**

All tool methods must return `AgentToolResult`. Use the static factory methods to signal success or failure:

Expand Down Expand Up @@ -193,11 +200,11 @@ namespace Syncfusion.AI.AgentTools.Word

## Registering Custom Tools with the AI Agent

Once your custom tool class is created, register it alongside the built-in tools in your host application.
Once your custom tool class is created, build the agent tool library, add the required DLL or project dependency to your host application, and then register it alongside the built-in tools.

Documents can be handled using either In‑memory Mode or Storage Mode during AI agent execution. In In‑memory Mode, documents are loaded into memory and shared across tool calls. In Storage Mode, documents are loaded per tool call from external storage and must be explicitly saved to persist changes.
Documents can be handled using either in‑memory Mode or Storage Mode during AI agent execution. In in‑memory Mode, documents are loaded into memory and shared across tool calls. In Storage Mode, documents are loaded per tool call from external storage and must be explicitly saved to persist changes.

**Step 1: Registering a Custom Tool with the Syncfusion Agent Tools**
**Step 1: Registering a Custom Tool with the Syncfusion AI Agent Tools**

#### In-Memory Mode

Expand Down Expand Up @@ -240,7 +247,7 @@ var msAiTools = allSyncfusionTools
.ToList();
```

**Step 3: Build the Agent**
**Step 3: Build the AI Agent**

```csharp
var agent = openAIClient.AsAIAgent(
Expand All @@ -264,7 +271,8 @@ The agent will call `Word_CreateDocument` to load the file, then `Word_AddTextWa

## See Also

- [Overview](https://helpstaging.syncfusion.com/document-processing/ai-agent-tools/overview)
- [Tools](https://helpstaging.syncfusion.com/document-processing/ai-agent-tools/tools)
- [Getting Started](https://helpstaging.syncfusion.com/document-processing/ai-agent-tools/getting-started)
- [Example Prompts](https://helpstaging.syncfusion.com/document-processing/ai-agent-tools/example-prompts)
- [Overview](./overview)
- [Tools](./tools)
- [Getting Started](./getting-started)
- [Example Prompts](./example-prompts)
- [Example Use Cases](./example-use-cases)
Loading