惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
F
Fortinet All Blogs
D
Docker
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
罗磊的独立博客
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
J
Java Code Geeks
T
The Blog of Author Tim Ferriss
U
Unit 42
N
Netflix TechBlog - Medium
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
云风的 BLOG
云风的 BLOG
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Stack Overflow Blog
Stack Overflow Blog
爱范儿
爱范儿
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Proofpoint News Feed
G
Google Developers Blog
H
Help Net Security

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Built a C# AI Agent That Researches Errors and Suggests F...
Kaushal Kuma · 2026-05-27 · via DEV Community
Cover image for Built a C# AI Agent That Researches Errors and Suggests Fixes

Kaushal Kumar

We've all done this.

  • You hit an exception
  • You copy the stack trace
  • Open Google
  • Read StackOverflow
  • Open GitHub issues
  • Check Microsoft docs
  • Read random blogs
  • Open three more tabs

Thirty minutes later you're still debugging.

Modern AI tools help, but there is a problem: They often answer from memory.

Sometimes they produce fixes that sound right but were never actually validated against real developer discussions, GitHub issues, or official documentation.

I wanted an AI agent that behaves more like a senior engineer sitting next to me:

  • Understand the exception
  • Research external sources
  • Analyze community findings
  • Rank likely causes
  • Suggest fixes with evidence

So I built a .NET Error Research Agent using:

  • C#
  • Semantic Kernel
  • Azure OpenAI
  • Tavily Search API
  • Function Calling
  • Plugin-based architecture

The goal wasn't:

Let's connect ChatGPT with C#

The goal was:

Let's teach an AI how developers actually debug software.


Building the Agent

I used Semantic Kernel's ChatCompletionAgent.

The agent itself contains explicit instructions that force research before responding.

        ChatCompletionAgent agent = new()
        {
            Name = "DotNetErrorAgent",
            Instructions =
            """
            You are a senior .NET troubleshooting expert specializing in:

                        - C#
                        - ASP.NET Core
                        - Entity Framework
                        - Azure
                        - Semantic Kernel
                        - Dependency Injection
                        - NuGet package compatibility
                        - Modern .NET applications

                        CRITICAL RULES:

                        - Always call SearchErrorSolutions before responding.
                        - Never answer only from internal knowledge.
                        - Research first using external sources.
                        - Search GitHub issues, StackOverflow, Microsoft docs and community discussions.
                        - Use search findings as evidence.

                        ANALYSIS PROCESS:

                        1. Understand the exception type
                        2. Analyze stack trace details
                        3. Identify framework and package clues
                        4. Research external findings
                        5. Determine likely causes
                        6. Rank causes by probability
                        7. Identify version compatibility issues
                        8. Suggest practical fixes
                        9. Provide corrected code
                        10. Explain why the fix works

                        WHEN INFORMATION IS INCOMPLETE:

                        - Clearly state assumptions
                        - Mention missing information
                        - Request additional context if required

                        WHEN MULTIPLE ROOT CAUSES EXIST:

                        - Rank them:
                           High probability
                           Medium probability
                           Low probability

                        RESPONSE FORMAT:

                        Exception Summary:
                        ...

                        Root Cause Analysis:
                        ...

                        Possible Causes:
                        1.
                        2.
                        3.

                        Why It Happens:
                        ...

                        Recommended Fix:
                        ...

                        Corrected Code:
                        ```

csharp
                        ...

            """,
            Kernel = kernel,
            Arguments = new KernelArguments(settings)
        };


Enter fullscreen mode Exit fullscreen mode

The interesting part here is not the prompt.
It's the process design.
The AI is intentionally restricted from immediately answering.
Before generating a response, it must investigate.


Creating the Search Plugin
To give the agent external knowledge, I created a Semantic Kernel plugin.
The plugin searches for:

  • GitHub issues
  • StackOverflow discussions
  • Official documentation
  • Community troubleshooting threads


public class WebSearchPlugin
{
    private readonly HttpClient _httpClient;
    private readonly string _apiKey;

    public WebSearchPlugin(HttpClient httpClient, IConfiguration configuration)
    {
        _httpClient = httpClient;
        _apiKey = configuration["Tavily:ApiKey"]!;
    }

    [KernelFunction]
    [Description("Searches the web for software errors, fixes, GitHub issues and troubleshooting discussions")]
    public async Task<string> SearchErrorSolutions([Description("Full exception message including stack trace")] string error)
    {
        var body = new
        {
            query =
                    $"""
                        Find solutions for:

                        {error}

                        Include:GitHub issues,StackOverflow,official docs, root causes
                        """,
            max_results = 5,
            include_answer = "advanced",
            search_depth = "advanced"
        };

        var request = new HttpRequestMessage(HttpMethod.Post, "https://api.tavily.com/search");

        request.Content = new StringContent(JsonSerializer.Serialize(body), Encoding.UTF8, "application/json");

        request.Headers.Add("Authorization", $"Bearer {_apiKey}");

        var response = await _httpClient.SendAsync(request);

        return await response.Content.ReadAsStringAsync();
    }
}



Enter fullscreen mode Exit fullscreen mode


The Agent Response Structure
I wanted outputs to feel like a senior engineer's analysis rather than random generated text.

So the agent follows a structured format:

  • Exception Summary
  • Root Cause Analysis
  • Possible Causes
    • High probability
    • Medium probability
    • Low probability
  • Why It Happens
  • Recommended Fix
  • Corrected Code

Example Flow
Developer input:



Paste your .NET exception:
System.InvalidOperationException: Unable to resolve service for type IUserService while activating UserController


Enter fullscreen mode Exit fullscreen mode

Behind the scenes:

  • Semantic Kernel receives exception
  • AI invokes plugin
  • Tavily searches external sources
  • Results return
  • AI analyzes findings
  • Root causes ranked
  • Fix generated

Output:

Instead of generic guessing, the answer is supported by actual findings

What I Learned
AI agents become valuable when they follow operational workflows rather than simply generating text.

The quality of an AI system depends less on model intelligence and more on process design.

That's the shift I'm starting to see:

Prompt engineering matters.

But workflow engineering matters more.

I'm curious:
How would you improve an AI debugging assistant?