π Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/agents/data_analyst_agent
Local Data Analyst Agent for C# .NET Applications
π― Purpose of the Demo
Local Data Analyst Agent demonstrates how to use LM-Kit.NET to build an AI data analyst that reads, parses, and analyzes your data files entirely on local hardware. The agent combines ReAct planning with built-in tools for file I/O, data parsing, and statistical computation.
The sample shows how to:
- Build an agent with ReAct planning using
Agent.CreateBuilder(). - Register built-in tools from multiple categories (Data, Numeric, IO) via
BuiltInTools. - Use built-in Data tools (CSV, JSON, XML parsing) for structured data processing.
- Use built-in Numeric tools (calculator, statistics) for computation.
- Use built-in IO tools (file read, directory list) for local data access.
- Execute agent tasks with
AgentExecutorand stream color-coded output. - Conduct multi-turn analysis where the agent remembers context from previous queries.
Why a Local Data Analyst with LM-Kit.NET?
- Data never leaves your machine: analyze sensitive financial, HR, or customer data without cloud exposure.
- Built-in tools ecosystem: demonstrates the Data, Numeric, and IO tool categories working together.
- Natural language queries: ask questions about your data in plain English.
- Systematic analysis: ReAct planning ensures thorough, step-by-step analysis.
π₯ Who Should Use This Demo
- Business Analysts: explore datasets with natural language instead of writing SQL or Python.
- Data Scientists: quick local data exploration without spinning up notebooks.
- Finance Teams: analyze sensitive financial data with full data sovereignty.
- HR Departments: process employee data locally without compliance concerns.
- Developers: learn how to combine built-in tools from multiple categories in a single agent.
π What Problem It Solves
- Data privacy: analyze confidential data without uploading to cloud AI services.
- Technical barrier: non-technical users can query data with natural language.
- Quick exploration: get insights from CSV/JSON files without writing code.
- Tool ecosystem demo: showcases built-in tools from three categories working together.
- Reproducible analysis: the agent explains its methodology and shows supporting numbers.
π» Demo Application Overview
Console app that:
- Lets you choose from multiple models optimized for tool-calling and reasoning.
- Downloads models if needed, with live progress updates.
- Creates an Agent with ReAct planning and registered built-in tools.
- Enters an interactive analysis loop where you can:
- Point the agent at local data files (CSV, JSON, XML, text).
- Ask analytical questions in natural language.
- Watch the agent reason through analyses (blue), call tools (magenta), and present results (white).
- Ask follow-up questions that build on previous analysis.
- Displays execution statistics (tool calls, duration, inferences).
- Loops until you type
q.
Key Features
- Built-In Tools: File I/O, CSV/JSON/XML parsing, calculator, statistics.
- ReAct Planning: Systematic data exploration and analysis.
- Multi-Turn Context: Ask follow-up questions about the same data.
- Color-Coded Output: Reasoning (blue), tool calls (magenta), results (white).
- Zero Configuration: No API keys, no cloud accounts, no external dependencies.
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Query β
β "Analyze sales.csv and find the top regions" β
βββββββββββββββββββββ¬ββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β ReAct Planning Loop β
β β
β Think β Act β Observe β Think β ... β
β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β β IO Tools β βData Toolsβ β Numeric β β
β β β β β β Tools β β
β β fs_read β βcsv_parse β βcalculatorβ β
β β fs_list β βjson_parseβ βstatisticsβ β
β β β βxml_parse β β β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
β β
βββββββββββββββββββββ¬ββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Structured Insights β
β Key metrics, trends, anomalies, and summary β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Built-In Tools
| Tool | Category | Description |
|---|---|---|
filesystem_read |
IO | Read file contents from local disk |
filesystem_list |
IO | List directory contents |
csv_parse |
Data | Parse CSV into structured rows and columns |
json_parse |
Data | Parse JSON documents |
xml_parse |
Data | Parse XML documents |
calculator |
Numeric | Arithmetic, percentages, ratios |
statistics |
Numeric | Descriptive statistics (mean, median, min, max, std dev) |
Agent Configuration
using LMKit.Agents;
using LMKit.Agents.Tools.BuiltIn;
using LMKit.Model;
LM model = LM.LoadFromModelID("qwen3:8b");
var agent = Agent.CreateBuilder(model)
.WithPersona("Data Analyst Assistant")
.WithInstruction("You are an expert data analyst...")
.WithPlanning(PlanningStrategy.ReAct)
.WithTools(tools =>
{
// IO tools: read files and list directories
tools.Register(BuiltInTools.FileSystemRead);
tools.Register(BuiltInTools.FileSystemList);
// Data tools: parse structured formats
tools.Register(BuiltInTools.CsvParse);
tools.Register(BuiltInTools.JsonParse);
tools.Register(BuiltInTools.XmlParse);
// Numeric tools: compute and analyze
tools.Register(BuiltInTools.Calculator);
tools.Register(BuiltInTools.Statistics);
})
.WithMaxIterations(15)
.Build();
var executor = new AgentExecutor();
var result = executor.Execute(agent, "Analyze sales.csv", cancellationToken);
Example Use Cases
- Sales analysis: "Read sales_q4.csv and tell me which region grew the fastest"
- Financial data: "Parse budget.json and compute the total expenses by department"
- Data discovery: "List all CSV files in C:\data and describe what each contains"
- Statistical analysis: "Compute mean, median, and standard deviation of response times in metrics.csv"
- Comparative analysis: "Compare this quarter's revenue numbers against last quarter from the two CSV files"
βοΈ Getting Started
Prerequisites
- .NET 8.0 or later
- Sufficient VRAM for the selected model (6-18 GB depending on model choice)
- Data files to analyze (CSV, JSON, XML, or text)
Download
git clone https://github.com/LM-Kit/lm-kit-net-samples
cd lm-kit-net-samples/console_net/agents/data_analyst_agent
Run
dotnet build
dotnet run
Then:
- Select a model from the menu, or paste a custom model URI.
- Wait for the model to download (first run) and load.
- Enter a data analysis query (include file paths).
- Watch the agent reason, read files, parse data, and compute in real-time.
- Receive structured insights with supporting metrics.
- Type
qto exit.
π§ Troubleshooting
"File not found" errors
- Use full absolute paths (e.g.,
C:\data\file.csv). - Check file permissions.
- Use full absolute paths (e.g.,
Agent doesn't parse data correctly
- Ensure CSV files use standard delimiters (comma, semicolon).
- For complex JSON, try a larger model (14B+).
Slow analysis with large files
- Large files may exceed the model's context window.
- Consider splitting large datasets before analysis.
- Use a model with longer context (GPT OSS 20B supports 131k tokens).
Inaccurate calculations
- The agent uses built-in calculator/statistics tools for exact computation.
- If results seem wrong, check that the agent is using the right columns/fields.
π Extend the Demo
- Add spreadsheet support: register built-in tools for XLSX parsing.
- Visualization: export results to CSV for charting in Excel or other tools.
- Scheduled analysis: run automated daily/weekly reports on data files.
- Database connectivity: combine with Qdrant or other connectors for vector-augmented analysis.
- Permission policies: restrict file access to specific directories using
ToolPermissionPolicy. - Report generation: pipe analysis results into a Content Creation Pipeline for formatted reports.
π Additional Resources
- LM-Kit.NET Documentation
- BuiltInTools API Reference
- Agent API Reference
- AgentExecutor API Reference
- PlanningStrategy API Reference
- LM-Kit Samples Repository
π Related Content
- How-To: Equip Agent with Built-In Tools: Learn how to register and configure built-in tools from multiple categories on an agent.
- How-To: Choose the Right Planning Strategy: Understand when to use ReAct, Chain-of-Thought, or no planning for your agent.
- Glossary: AI Agent Tools: Core concepts behind tool registration, invocation, and result handling in agentic workflows.
- Glossary: AI Agent Planning: Overview of planning strategies that guide how agents reason and act.
- Research Assistant Demo: Another ReAct agent demo that combines web search with custom tools for autonomous research.