Table of Contents

👉 Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/coding/code_analysis_assistant

Code Analysis Assistant with Built-In Tools for C# .NET Applications


🎯 Purpose of the Demo

This demo shows how to build a multi-turn coding assistant that uses built-in tools to read files, list directories, search code, and search the web. Instead of manually pasting code into prompts, the model calls tools autonomously to navigate and understand your codebase.


👥 Who Should Use This Demo

  • Developers who want to add local code analysis and navigation to their .NET tooling.
  • Teams looking for a private, on-premises coding assistant with no cloud dependency.
  • Educators building interactive code explanation tools for students.

🚀 What Problem It Solves

Traditional coding chatbots require you to copy and paste code into the prompt window. This demo lets the model read files and explore directories on its own, giving it the context it needs to answer accurately. Everything runs locally with no data leaving your machine.


💻 Demo Application Overview

The demo is a console app that:

  • Lets you select a coding-focused model (or enter a custom model URI)
  • Downloads and loads the model with progress feedback
  • Creates a MultiTurnConversation with four built-in tools registered
  • Runs an interactive chat loop with streaming output
  • Shows performance metrics after each response

✨ Key Features

  • Built-in tool calling: FileSystemRead, FileSystemList, FileSystemSearch, WebSearch
  • Multi-turn conversation: full history preserved across turns
  • Color-coded output: blue for reasoning, magenta for tool calls, white for normal text
  • Session control: /reset clears history, /regenerate redoes the last response

Minimal Integration Snippet

using LMKit.Agents.Tools.BuiltIn;
using LMKit.Model;
using LMKit.TextGeneration;

using LM model = LM.LoadFromModelID("qwen3-coder:30b-a3b");

var chat = new MultiTurnConversation(model)
{
    SystemPrompt = "You are a coding assistant. Use your tools to read files before answering."
};

chat.Tools.Register(BuiltInTools.FileSystemRead);
chat.Tools.Register(BuiltInTools.FileSystemList);
chat.Tools.Register(BuiltInTools.FileSystemSearch);
chat.Tools.Register(BuiltInTools.WebSearch);

var result = chat.Submit("Read Program.cs and explain what it does");
Console.WriteLine(result.Completion);

⚙️ Getting Started

Prerequisites

  • .NET 8.0 or later
  • A tool-calling capable model (~7 GB VRAM for Qwen 3.5 9B, ~18 GB for Qwen 3 Coder 30B-A3B)

Download the Project

Running the Application

  1. Clone the repository:
git clone https://github.com/LM-Kit/lm-kit-net-samples
  1. Navigate to the project directory:
cd lm-kit-net-samples/console_net/coding/code_analysis_assistant
  1. Build and run the application:
dotnet build
dotnet run
  1. Follow the on-screen prompts to select a model and start chatting about code.

Example Usage

Read and explain a file

You: Read Program.cs in the current directory and explain what it does

Explore a project

You: List the files in ../src and tell me what this project is about

Search across a codebase

You: Search for files named *.csproj and summarize the project structure

Look up documentation

You: Search the web for how to use LM-Kit.NET built-in tools

🚀 Extend the Demo

  • Add BuiltInTools.FileSystemWrite to let the assistant create or modify files.
  • Add BuiltInTools.FileSystemTree for a quick overview of project structure.
  • Add BuiltInTools.RegexMatch for searching code patterns within files.
  • Combine with BuiltInTools.ProcessShell to let the assistant run build or test commands.
  • Switch to the Agent + AgentExecutor pattern with PlanningStrategy.ReAct for multi-step autonomous workflows.

Share