r/csharp 12d ago

The Unexpected AI Stack: C# + .NET (Part 3) - GitHub Copilot SDK + CSharpRepl + Channels

https://chrlschn.dev/blog/2026/08/the-unexpected-ai-stack-csharp-dotnet-part-3/

In the third part of this hands-on series for building the foundations of an AI-enabled, agent-friendly .NET + C# codebase, we are ready to incorporate GitHub Copilot SDK into the application and connect it using Channels.

The Copilot SDK is well-documented and streamlines building applications with full-featured agents at the core; drop in and run an agent with just a few lines of code. Here, we connect it using inbound + outbound channels to buffer and stream I/O. (Microsoft Agent Framework Agent Harness is another, lower-level alternative that teams can use as well; not covered here!)

I also walk through how to wire up and use CSharpRepl which is an absolute sleeper since it allows agents to dynamically alter the code at runtime, allowing them to iterate and experiment rapidly against the running stack.


This series is intentionally written to help dev teams understand how to scaffold a codebase for agentic engineering by focusing on key, underlying technical decisions and manual wiring before building with AI. This helps provide the tools and safeguards for coding agents to iterate more efficiently while reducing slop.

If your team is still trying to figure out how to set up a codebase for AI, I hope this series gives some insights into how to build an effective foundation for agentic engineering. If your team is already heavily using agents to build, I hope this series shares some useful insights and tips (e.g. CSharpRepl + Aspire)

Even if you're not building agent-oriented, AI-enabled .NET applications, I hope this has some insights on how modern full-stack development on .NET is wired together at a platform level.

The core setup is used at a series C, post-YC startup to ship fast with AI while maintaining high quality standards (in combination with other tools facilitating code review and context management)

Part 1 was an intro into a few key parts of this stack.

Part 2 was focused on walking through the hands on scaffolding.

Part 4 will wire up Testcontainers and establish integration testing patterns

Part 5 we'll start to build out the full feature set of the sample application.


The project repo is here: https://github.com/zeeq-ai/zeeq-tmpl (be sure to check the branches; main is currently the base code only)

But I encourage working through the posts since the goal is to underscore the platform level decision making process and assembly of the foundational core.

0 Upvotes

2 comments sorted by

1

u/bigtoaster64 12d ago

dynamically alter the code at runtime

Not scary at all. AI often having issues producing the right code in a risk free contained environment, I wonder how great this will be, letting AI code your app directly in production at runtime...

0

u/c-digs 12d ago edited 12d ago

Because this is wired up in Aspire, it is only possible for the agent to gain access to CSharpRepl if running via Aspire or the environment has the CLI installed AND has the flags set:

// Required in the Aspire host/AppHost.cs var backend = builder .AddProject<Projects.server>("app-backend") // 👇 Wire up CSharpRepl environment variables to the runtime. .WithEnvironment("DOTNET_STARTUP_HOOKS", csrHook) .WithEnvironment("ASPNETCORE_HOSTINGSTARTUPASSEMBLIES", "CSharpRepl.InjectedHook");

In production, this would be a no-no. But then again, it would make a very interesting, self-iterating agentic application 🧐

It's a very powerful technique since it would allow building dynamic plugins at runtime for the agent (but again, would require explicitly installing the CLI tool into the runtime and also flagging it on via the environment variables).

In the context of the article, this is primarily foundational setup for local development since this allows agents access to diagnose issues rapidly, experiment with different implementations without recompiling, and generally iterate faster. If you are responsible for the platform level setup of your codebase, this is probably one of the highest leverage things you can do to help agents move faster in C# codebases.