ControlAgentNet.Runtime 0.1.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package ControlAgentNet.Runtime --version 0.1.5
                    
NuGet\Install-Package ControlAgentNet.Runtime -Version 0.1.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ControlAgentNet.Runtime" Version="0.1.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ControlAgentNet.Runtime" Version="0.1.5" />
                    
Directory.Packages.props
<PackageReference Include="ControlAgentNet.Runtime" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ControlAgentNet.Runtime --version 0.1.5
                    
#r "nuget: ControlAgentNet.Runtime, 0.1.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ControlAgentNet.Runtime@0.1.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ControlAgentNet.Runtime&version=0.1.5
                    
Install as a Cake Addin
#tool nuget:?package=ControlAgentNet.Runtime&version=0.1.5
                    
Install as a Cake Tool

ControlAgentNet.Runtime

Shared runtime composition, orchestration, and middleware pipeline for ControlAgentNet.


Purpose

ControlAgentNet.Runtime implements the execution engine that powers every ControlAgentNet agent. It contains:

  • Orchestration - Request/response flow management
  • Middleware Pipeline - Pluggable request processing
  • Registries - Tool and channel management
  • Manifest Generation - Agent introspection

Architecture

Request Flow

IncomingMessage
       │
       ▼
┌──────────────────┐
│ Middleware       │  ← Exception Handling
│ Pipeline         │  ← Prompt Injection Defense
│                  │  ← Logging
│                  │  ← Custom Middleware
└────────┬─────────┘
         │
         ▼
┌──────────────────┐
│ IAgentEngine    │  ← Microsoft Agents (default)
│ (MAF)            │
└────────┬─────────┘
         │
         ▼
    OutgoingMessage

Middleware Pipeline

Middleware runs in registration order (first registered = outermost):

builder.Services.AddControlAgentAgent(config)
    .AddAgentMiddleware<LoggingMiddleware>()      // Runs first
    .AddAgentMiddleware<CustomMiddleware>()        // Runs second
    .AddAgentMiddleware<MetricsMiddleware>();     // Runs third

Each middleware can:

  • Inspect the request before passing to next
  • Modify the context
  • Short-circuit by returning early
  • Handle exceptions

Key Components

ControlAgentOrchestrator

The main entry point - orchestrates the entire flow:

public sealed class ControlAgentOrchestrator : IAgentOrchestrator
{
    public async Task<OutgoingMessage> ProcessAsync(
        IncomingMessage message,
        CancellationToken cancellationToken)
    {
        // 1. Create context
        // 2. Run middleware pipeline
        // 3. Execute engine
        // 4. Return response
    }
}

AgentMiddlewarePipeline

Builds and executes the middleware chain:

public sealed class AgentMiddlewarePipeline
{
    public async Task<OutgoingMessage> ExecuteAsync(
        IncomingMessage message,
        Func<AgentContext, Task<OutgoingMessage>> terminal,
        CancellationToken cancellationToken)
    {
        // Chain middleware: A → B → C → terminal
    }
}

Registries

ToolRegistry - Manages tool registration and guard wrapping:

// Tools are automatically wrapped with guards
var tools = toolRegistry.GetEnabledTools();

ChannelRegistry - Manages channel descriptors:

var channels = channelRegistry.GetChannelStates();

AgentManifest

Introspection endpoint for tooling:

var manifest = manifestRegistry.GetManifest();
// {
//   AgentId: "my-agent",
//   Tools: [...],
//   Channels: [...]
// }

ToolRegistrationFactory

Creates tool invocations that are automatically wrapped with structured error handling. When a tool throws an unhandled exception the invocation does not throw — instead it returns a ToolInvocationError payload that the LLM receives as the tool result:

{
  "error": true,
  "errorCode": "TOOL_EXCEPTION",
  "message": "CalDAV request timed out after 30 s",
  "tool": "QueryCalendarEvents"
}

The error and errorCode fields can be referenced in system prompts so the LLM knows how to communicate failures to the user:

If a tool result contains "error": true, tell the user that the action could not be completed and include the message in your reply.

OperationCanceledException is not converted — it propagates normally so that cancellation is always respected.


Built-in Middleware

ExceptionHandlingMiddleware

Catches all unhandled exceptions and returns a safe error message:

// Default: "An internal error occurred..."
// Configurable via AgentOptions.ErrorMessage

PromptInjectionDefenseMiddleware

Lightweight heuristic defense against prompt injection attacks:

// Blocks: "ignore previous instructions", "you are now a...", etc.
// Configurable via PromptInjectionDefenseOptions

Extending Runtime

Custom Middleware

public sealed class MyMiddleware : IAgentMiddleware
{
    public async Task<OutgoingMessage> InvokeAsync(
        AgentContext context,
        AgentDelegate next,
        CancellationToken cancellationToken)
    {
        // Before
        Console.WriteLine($"Processing: {context.Message.Text}");

        var response = await next(context, cancellationToken);

        // After
        Console.WriteLine($"Response: {response.Text}");

        return response;
    }
}

// Register
builder.Services.AddControlAgentAgent(config)
    .AddAgentMiddleware<MyMiddleware>();

Dependencies

Runtime depends on:

  • ControlAgentNet.Core - Interfaces and models

This keeps Runtime focused on orchestration without coupling to specific implementations.


Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on ControlAgentNet.Runtime:

Package Downloads
ControlAgentNet.Channels.Telegram

Telegram bot channel for ControlAgentNet agents with polling and webhook modes.

ControlAgentNet.Agents

Base facade package for ControlAgentNet agents on .NET 10 using the default Microsoft Agents stack.

ControlAgentNet.Channels.Console

Interactive console channel for ControlAgentNet agents.

ControlAgentNet.Tools.Greeting

Simple greeting capability package for ControlAgentNet agents.

ControlAgentNet.Features.CronJobs

Cron-based code execution for ControlAgentNet hosts.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.10 111 5/7/2026
0.1.7 242 4/21/2026
0.1.6 140 4/18/2026
0.1.5 96 4/18/2026
0.1.1 287 4/14/2026
0.1.0 109 4/14/2026