Build an AI code review team with .NET Microsoft Agent Framework background agents and Ollama
Authorised Territory demonstrates how to build a multi-agent AI code review workflow in .NET using Microsoft Agent Framework, coordinating specialist security, performance, and architecture reviewers via background agents. The setup runs fully locally with Ollama and adds OpenTelemetry tracing so you can see what each agent is doing during the review.
Overview
The video builds an AI-powered “code review team” where multiple specialised agents independently review an ASP.NET Core MVC application from different perspectives, and a lead agent consolidates the results into a single structured report.
Key ideas covered:
- Use Microsoft Agent Framework in a .NET console app to orchestrate multiple agents.
- Run the LLM locally using Ollama with the
granite4.1:8bmodel. - Connect to Ollama through an OpenAI-compatible local endpoint.
- Coordinate concurrent specialist reviews using BackgroundAgentsProvider.
- Add OpenTelemetry tracing (including console exporters) to observe agent activity.
Multi-agent code review design
Roles in the review team
The workflow is structured as:
- User → Lead Developer Agent → Specialist Agents
Specialist agents:
- Security Agent
- Looks for issues such as:
- SQL injection
- Authentication and authorization problems
- XSS
- CSRF
- Secrets and sensitive data exposure
- Insecure model binding
- Looks for issues such as:
- Performance Agent
- Looks for issues such as:
- N+1 queries
- Inefficient LINQ
- Unnecessary database round trips
- Excessive entity loading
- Missing
AsNoTracking() - Synchronous operations
- Looks for issues such as:
- Architecture Agent
- Evaluates:
- Separation of concerns
- Controller responsibilities
- Dependency boundaries
- Business logic placement
- Data access patterns
- Testability and maintainability
- Evaluates:
Lead Developer Agent responsibilities
The Lead Developer Agent coordinates the review using Microsoft Agent Framework’s BackgroundAgentsProvider:
- Delegates tasks to specialist agents
- Runs specialist reviews independently and concurrently
- Combines results into a single report by:
- Removing duplicates
- Resolving conflicts
- Prioritising issues
- Producing a structured final code review output
Guardrails for specialist agents
The specialist agents are instructed to:
- Focus strictly on their assigned responsibility (security/performance/architecture)
- Treat the supplied source code as the authoritative source
- Avoid inventing files, classes, methods, or vulnerabilities
Implementation topics highlighted
The video’s build steps and features include:
- Building a .NET console application with Microsoft Agent Framework
- Connecting Microsoft Agent Framework to Ollama
- Configuring an OpenAI-compatible local endpoint
- Creating specialised AI agents
- Using BackgroundAgentsProvider to coordinate background agents
- Building a lead developer agent
- Delegating tasks to specialist agents
- Running independent reviews concurrently
- Combining multiple AI reviews into a final report
- Using LoopAgent and streaming responses
- Adding OpenTelemetry tracing and console exporters
Why run locally with Ollama
The approach keeps the LLM running locally (via Ollama), enabling experimentation with multi-agent code review workflows without relying on a cloud-hosted model.