Table of Contents

Equip an Agent with Built-In Tools for Data Processing and Automation

LM-Kit.NET ships over 60 built-in tools across eight categories: Data, Text, Numeric, Security, Utility, IO, Net, and Document. These tools give your agent the ability to parse JSON, validate emails, compute statistics, encrypt data, call HTTP APIs, read files, split and merge PDFs, perform OCR, and much more, all without writing custom tool code. This guide shows how to register built-in tools, configure IO tools securely, and build practical data processing agents.


Why This Matters

Two enterprise problems that built-in tools solve:

  1. Repetitive tool authoring. Every agent project reinvents the same utilities: JSON parsing, date formatting, regex matching, URL building. Built-in tools provide production-tested implementations for 50+ common operations, saving weeks of development time and eliminating bugs in foundational plumbing.
  2. Data pipeline automation. Business workflows require reading CSVs, validating records, computing summaries, and writing output files. An agent equipped with data, text, and IO tools can orchestrate these steps autonomously, turning a multi-script ETL process into a single natural language instruction.

Prerequisites

Requirement Minimum
.NET SDK 8.0+
VRAM 6+ GB (for a tool-calling model like Qwen 3 8B)
Model Must support tool calling (model.HasToolCalls == true)

Step 1: Create the Project

dotnet new console -n BuiltInToolsAgent
cd BuiltInToolsAgent
dotnet add package LM-Kit.NET

Step 2: Understand the Built-In Tools Ecosystem

All built-in tools are accessible through the BuiltInTools static class. They fall into two groups: safe tools (no file system or network access) and IO tools (require explicit configuration for security).

                        BuiltInTools
                             │
        ┌────────────┬───────┼───────┬────────────┐
        ▼            ▼       ▼       ▼            ▼
   Safe Tools   IO Tools  Net Tools  Document Tools
        │            │       │            │
   ┌────┴────┐  ┌───┴───┐ ┌──┴──┐  ┌─────┴─────┐
   │  Data   │  │ File  │ │Http │  │ PdfSplit  │
   │  Text   │  │ System│ │ Web │  │ PdfInfo   │
   │ Numeric │  │Process│ │Srch │  │ PdfRender │
   │Security │  │Environ│ │ Net │  │ PdfMerge  │
   │ Utility │  │Comprss│ │SMTP │  │ ImgDeskew │
   └─────────┘  │ Watch │ └─────┘  │ ImgCrop   │
                └───────┘          │ ImgResize │
                                   │ DocText   │
                                   │ OCR       │
                                   └───────────┘
Category Representative Tools Access
Data BuiltInTools.Json, BuiltInTools.Csv, BuiltInTools.Xml, BuiltInTools.Yaml, BuiltInTools.Html, BuiltInTools.Markdown, BuiltInTools.QRCode Safe
Text BuiltInTools.Text, BuiltInTools.Regex, BuiltInTools.Diff, BuiltInTools.Template, BuiltInTools.Encoding, BuiltInTools.Slug, BuiltInTools.Fuzzy Safe
Numeric BuiltInTools.Calculator, BuiltInTools.Stats, BuiltInTools.Conversion, BuiltInTools.Financial, BuiltInTools.Random, BuiltInTools.Expression Safe
Security BuiltInTools.Hash, BuiltInTools.Crypto, BuiltInTools.Jwt, BuiltInTools.Validator, BuiltInTools.Password, BuiltInTools.Checksum Safe
Utility BuiltInTools.DateTime, BuiltInTools.TimeZone, BuiltInTools.Url, BuiltInTools.Cron, BuiltInTools.SemVer, BuiltInTools.Color, BuiltInTools.Humanize, BuiltInTools.Country Safe
Document BuiltInTools.PdfSplit, BuiltInTools.PdfInfo, BuiltInTools.PdfRender, BuiltInTools.PdfMerge, BuiltInTools.ImageDeskew, BuiltInTools.ImageCrop, BuiltInTools.ImageResize, BuiltInTools.DocumentText, BuiltInTools.Ocr Has I/O
IO BuiltInTools.FileSystem, BuiltInTools.Process, BuiltInTools.Environment, BuiltInTools.Compress, BuiltInTools.Watch Requires config
Net BuiltInTools.Http, BuiltInTools.WebSearch, BuiltInTools.Network, BuiltInTools.CreateSmtp(...) Requires config

Step 3: Register Safe Tools with an Agent

The fastest way to get started: register all safe tools at once. This gives your agent 50 tools with zero configuration and no IO access.

using System.Text;
using LMKit.Model;
using LMKit.Agents;
using LMKit.Agents.Tools.BuiltIn;

LMKit.Licensing.LicenseManager.SetLicenseKey("");

Console.InputEncoding = Encoding.UTF8;
Console.OutputEncoding = Encoding.UTF8;

// ──────────────────────────────────────
// 1. Load a tool-calling model
// ──────────────────────────────────────
Console.WriteLine("Loading model...");
using LM model = LM.LoadFromModelID("qwen3:8b",
    downloadingProgress: (_, len, read) =>
    {
        if (len.HasValue) Console.Write($"\r  Downloading: {(double)read / len.Value * 100:F1}%   ");
        return true;
    },
    loadingProgress: p => { Console.Write($"\r  Loading: {p * 100:F0}%   "); return true; });
Console.WriteLine("\n");

// ──────────────────────────────────────
// 2. Create agent with all safe tools
// ──────────────────────────────────────
var agent = Agent.CreateBuilder(model)
    .WithPersona("Data Processing Assistant")
    .WithInstruction("You have access to tools for parsing data, validating formats, computing statistics, " +
                     "manipulating text, and working with dates. Use the right tool for each task.")
    .WithTools(tools =>
    {
        tools.RegisterSafeTools();
    })
    .Build();

// ──────────────────────────────────────
// 3. Ask the agent to process data
// ──────────────────────────────────────
var result = await agent.RunAsync(
    "Parse this JSON and tell me how many items it contains: " +
    "{\"orders\": [{\"id\": 1, \"total\": 59.99}, {\"id\": 2, \"total\": 124.50}, {\"id\": 3, \"total\": 89.00}]}");

Console.WriteLine(result.Content);

Step 4: Pick Specific Tools for a Focused Agent

For production agents, register only the tools the agent needs. Fewer tools means less confusion for the model and faster tool selection.

var agent = Agent.CreateBuilder(model)
    .WithPersona("CSV Data Analyst")
    .WithInstruction("You analyze CSV data. Parse it, compute statistics, validate fields, and output results as JSON.")
    .WithTools(tools =>
    {
        tools.Register(BuiltInTools.Json);
        tools.Register(BuiltInTools.Csv);
        tools.Register(BuiltInTools.Stats);
        tools.Register(BuiltInTools.Calculator);
        tools.Register(BuiltInTools.Validator);
        tools.Register(BuiltInTools.DateTime);
    })
    .Build();

var result = await agent.RunAsync(
    "Here is a CSV of customer orders:\n" +
    "customer,email,amount,date\n" +
    "Alice,alice@example.com,150.00,2025-01-15\n" +
    "Bob,invalid-email,89.50,2025-01-16\n" +
    "Carol,carol@test.org,220.75,2025-01-17\n\n" +
    "Parse this data, validate all email addresses, compute the average order amount, " +
    "and return the results as formatted JSON.");

Console.WriteLine(result.Content);

Step 5: Configure IO Tools with Security Restrictions

IO tools (FileSystem, Http, Process) are disabled by default. Enable them with explicit restrictions to control what the agent can access.

using LMKit.Agents.Tools.BuiltIn.IO;
using LMKit.Agents.Tools.BuiltIn.Net;

var agent = Agent.CreateBuilder(model)
    .WithPersona("File Processing Agent")
    .WithTools(tools =>
    {
        // Safe tools for data processing
        tools.Register(BuiltInTools.Json);
        tools.Register(BuiltInTools.Csv);
        tools.Register(BuiltInTools.Validator);

        // FileSystem: read-only, restricted to specific directories
        tools.Register(BuiltInTools.CreateFileSystem(new FileSystemTool.Options
        {
            AllowWrite = false,
            AllowDelete = false,
            AllowedPaths = new[] { "/data/input", "/data/output" },
            MaxFileSize = 10 * 1024 * 1024  // 10 MB limit
        }));

        // HTTP: restricted to specific hosts
        tools.Register(BuiltInTools.CreateHttp(new HttpTool.Options
        {
            AllowedHosts = new[] { "api.example.com", "data.example.com" },
            Timeout = TimeSpan.FromSeconds(15),
            MaxResponseSize = 50_000
        }));
    })
    .Build();

Security defaults for IO tools:

Tool Default Behavior How to Restrict
FileSystem Read-only, no path restrictions AllowedPaths, BlockedPaths, MaxFileSize
Http Blocks localhost/127.0.0.1 AllowedHosts, BlockedHosts, AllowedSchemes
Process Full access ProcessToolOptions
Network Full access NetworkToolOptions

Step 6: Build a Data Transformation Agent

A complete example: an agent that reads CSV data, validates records, computes statistics, and outputs structured JSON.

var dataAgent = Agent.CreateBuilder(model)
    .WithPersona("Data Quality Engineer")
    .WithInstruction(
        "You process and validate datasets. For each task:\n" +
        "1. Parse the input data using the appropriate tool\n" +
        "2. Validate all fields (emails, dates, numeric ranges)\n" +
        "3. Compute summary statistics on numeric columns\n" +
        "4. Output a JSON report with valid records, invalid records, and statistics")
    .WithTools(tools =>
    {
        tools.Register(BuiltInTools.Csv);
        tools.Register(BuiltInTools.Json);
        tools.Register(BuiltInTools.Validator);
        tools.Register(BuiltInTools.Stats);
        tools.Register(BuiltInTools.Calculator);
        tools.Register(BuiltInTools.DateTime);
    })
    .Build();

string csvData = @"name,email,revenue,signup_date
Acme Corp,sales@acme.com,125000.50,2024-03-15
BadEmail Inc,not-an-email,89000.00,2024-06-01
Tech Solutions,info@techsol.io,210000.75,2024-01-20
Null Fields,,0,invalid-date
Global Ltd,contact@global.com,175000.25,2024-09-10";

var report = await dataAgent.RunAsync(
    $"Process this customer dataset and generate a quality report:\n\n{csvData}");

Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine(report.Content);
Console.ResetColor();

Step 7: Process JSON Data with the Json Tool

The Json tool supports parsing, querying with dot-notation paths, formatting, minifying, validating, and extracting keys/values.

var jsonAgent = Agent.CreateBuilder(model)
    .WithPersona("JSON Data Processor")
    .WithTools(tools =>
    {
        tools.Register(BuiltInTools.Json);
        tools.Register(BuiltInTools.Calculator);
    })
    .Build();

string apiResponse = @"{
    ""status"": ""success"",
    ""data"": {
        ""users"": [
            {""name"": ""Alice"", ""score"": 92.5, ""active"": true},
            {""name"": ""Bob"", ""score"": 87.3, ""active"": false},
            {""name"": ""Carol"", ""score"": 95.1, ""active"": true}
        ],
        ""metadata"": {""total"": 3, ""page"": 1}
    }
}";

var result = await jsonAgent.RunAsync(
    $"From this API response, extract the list of active users and calculate their average score:\n\n{apiResponse}");

Console.WriteLine(result.Content);

Step 8: Validate and Transform Data with Text Tools

Combine Regex, Template, Encoding, and Slug tools for text processing workflows.

var textAgent = Agent.CreateBuilder(model)
    .WithPersona("Text Processing Specialist")
    .WithTools(tools =>
    {
        tools.Register(BuiltInTools.Regex);
        tools.Register(BuiltInTools.Template);
        tools.Register(BuiltInTools.Encoding);
        tools.Register(BuiltInTools.Slug);
        tools.Register(BuiltInTools.Text);
    })
    .Build();

var result = await textAgent.RunAsync(
    "I have these product names that need URL-friendly slugs:\n" +
    "1. 'Café Délicieux™ Premium Blend'\n" +
    "2. 'Über-Fresh Organic Juice (500ml)'\n" +
    "3. '日本茶 Green Tea Extract'\n\n" +
    "For each: generate a URL slug, then check if any contain non-ASCII characters using regex.");

Console.WriteLine(result.Content);

Step 9: Use Security Tools for Data Compliance

The Security category provides hashing, encryption, validation, and JWT operations for compliance workflows.

var securityAgent = Agent.CreateBuilder(model)
    .WithPersona("Data Security Auditor")
    .WithTools(tools =>
    {
        tools.Register(BuiltInTools.Hash);
        tools.Register(BuiltInTools.Validator);
        tools.Register(BuiltInTools.Password);
        tools.Register(BuiltInTools.Checksum);
    })
    .Build();

var result = await securityAgent.RunAsync(
    "Audit this data for security compliance:\n" +
    "1. Validate these emails: 'admin@company.com', 'bad@@email', 'user@test.org'\n" +
    "2. Hash the valid emails with SHA-256 for anonymized storage\n" +
    "3. Generate a secure 16-character password for the new admin account\n" +
    "4. Check the strength of the password 'Welcome123!'");

Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(result.Content);
Console.ResetColor();

Step 10: Use Document Tools for PDF and Image Processing

The Document category provides tools for PDF manipulation, image preprocessing, text extraction, and OCR. These tools operate on files and enable document automation workflows.

using LMKit.Agents.Tools.BuiltIn;
using LMKit.Agents.Tools.BuiltIn.Document;

var docAgent = Agent.CreateBuilder(model)
    .WithPersona("Document Processing Agent")
    .WithInstruction(
        "You process documents and images. You can split and merge PDFs, " +
        "extract text, perform OCR on scanned images, resize and deskew images.")
    .WithTools(tools =>
    {
        tools.Register(BuiltInTools.PdfSplit);
        tools.Register(BuiltInTools.PdfMerge);
        tools.Register(BuiltInTools.PdfInfo);
        tools.Register(BuiltInTools.PdfRender);
        tools.Register(BuiltInTools.DocumentText);
        tools.Register(BuiltInTools.Ocr);
        tools.Register(BuiltInTools.ImageDeskew);
        tools.Register(BuiltInTools.ImageCrop);
        tools.Register(BuiltInTools.ImageResize);
    })
    .Build();

var result = await docAgent.RunAsync(
    "Extract pages 1-3 from 'report.pdf' into a new file called 'summary.pdf', " +
    "then get the text content from page 1.");

Console.WriteLine(result.Content);

Document tools reference:

Tool Description
BuiltInTools.PdfSplit Extract pages, split PDFs by ranges
BuiltInTools.PdfInfo Page count, dimensions, metadata, text content
BuiltInTools.PdfRender Render PDF pages as PNG or BMP images
BuiltInTools.PdfMerge Merge multiple PDF files into one
BuiltInTools.ImageDeskew Detect and correct skew in scanned documents
BuiltInTools.ImageCrop Auto-crop uniform borders from images
BuiltInTools.ImageResize Resize images, convert pixel formats
BuiltInTools.DocumentText Extract text from PDF, DOCX, XLSX, PPTX, HTML
BuiltInTools.Ocr OCR using Tesseract (34 languages)

Step 11: Monitor Tool Invocations

Track which tools the agent calls, how often, and what results they return. This is essential for debugging, auditing, and cost tracking.

var agent = Agent.CreateBuilder(model)
    .WithPersona("Data Analyst")
    .WithTools(tools =>
    {
        tools.RegisterSafeTools();
    })
    .Build();

// Monitor every tool call
agent.ToolInvoked += (sender, e) =>
{
    Console.ForegroundColor = ConsoleColor.DarkGray;
    Console.WriteLine($"  [TOOL] {e.ToolName}({e.Arguments?.Substring(0, Math.Min(80, e.Arguments?.Length ?? 0))}...)");
    Console.WriteLine($"         → {e.Result?.Substring(0, Math.Min(120, e.Result?.Length ?? 0))}...");
    Console.ResetColor();
};

var result = await agent.RunAsync("Parse this JSON {\"x\": 42} and compute the square root of the value.");
Console.WriteLine($"\nFinal answer: {result.Content}");

Model Selection

Model ID VRAM Tool Calling Best For
qwen3:4b ~4 GB Yes Lightweight tool agent, simple data tasks
qwen3:8b ~6.5 GB Yes Balanced speed and accuracy for multi-tool workflows
qwen3:14b ~11 GB Yes Complex reasoning across many tools
gptoss:20b ~15 GB Yes Advanced multi-step data pipelines
glm4.7-flash ~18 GB Yes Strongest 30B-class MoE, agentic tasks

Verify tool-calling support after loading: Console.WriteLine($"Tool calling: {model.HasToolCalls}");


Common Issues

Problem Cause Fix
Agent ignores available tools Too many tools registered Register only the tools needed for the task
FileSystem tool returns "access denied" Default is read-only, paths not allowed Set AllowWrite = true and add paths to AllowedPaths
HTTP tool blocks requests Localhost blocked by default Add target hosts to AllowedHosts
Agent calls wrong tool Tool descriptions overlap Use fewer, more targeted tools per agent
JSON parsing fails Input not valid JSON Use the Validator tool first to check format
Slow response with many tools Model evaluates all tool schemas Limit to 5-10 tools per agent for best performance

Next Steps