AgentSandbox.Extensions 5.1.0

dotnet add package AgentSandbox.Extensions --version 5.1.0
                    
NuGet\Install-Package AgentSandbox.Extensions -Version 5.1.0
                    
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="AgentSandbox.Extensions" Version="5.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AgentSandbox.Extensions" Version="5.1.0" />
                    
Directory.Packages.props
<PackageReference Include="AgentSandbox.Extensions" />
                    
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 AgentSandbox.Extensions --version 5.1.0
                    
#r "nuget: AgentSandbox.Extensions, 5.1.0"
                    
#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 AgentSandbox.Extensions@5.1.0
                    
#: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=AgentSandbox.Extensions&version=5.1.0
                    
Install as a Cake Addin
#tool nuget:?package=AgentSandbox.Extensions&version=5.1.0
                    
Install as a Cake Tool

AgentSandbox.Extensions

Extensions for AgentSandbox including AI function generation, dependency injection, and observability.

Installation

dotnet add package AgentSandbox.Extensions

AI Function Generation

Convert sandbox operations into AIFunction objects for use with AI chat APIs, Semantic Kernel, or agents:

using AgentSandbox.Core;
using AgentSandbox.Extensions;

var sandbox = new Sandbox();

// Get all sandbox functions as AIFunction
var functions = sandbox.GetSandboxFunctions();

// Or create individual functions
var bashFunction = sandbox.GetBashFunction();
var readFileFunction = sandbox.GetReadFileFunction();
var writeFileFunction = sandbox.GetWriteFileFunction();
var patchFunction = sandbox.GetApplyPatchFunction();
var skillFunction = sandbox.GetSkillFunction();

// Use with ChatClient or Semantic Kernel
var options = new ChatOptions { Tools = functions.ToList() };

Available Functions

  • bash_shell - Execute shell commands with dynamic help text

    • Parameters: command (string)
    • Returns: Structured response with success, message, and optional output
  • read_file - Read file contents with line-range support

    • Parameters: path (string), startLine (int?, default null), endLine (int?, default null)
    • Returns: Structured response with success, message, and output (joined file content)
    • Line indexes are 1-based (startLine inclusive, endLine exclusive)
    • Example: read_file('/logs.txt', 100, 120) returns lines 100-119
  • write_file - Write or create files

    • Parameters: path (string), content (string)
    • Returns: Structured success response; validation failures surface as tool errors
    • Auto-creates parent directories
  • edit_file - Apply unified diff patches

    • Parameters: path (string), patch (string)
    • Returns: Structured success response; validation failures surface as tool errors
    • Supports standard unified diff format
  • get_skill - Retrieve skill information and instructions

    • Parameters: skillName (string)
    • Returns: Skill metadata and instructions, or error if not found

Usage Example

using AgentSandbox.Core;
using AgentSandbox.Extensions;
using Microsoft.Extensions.AI;

var sandbox = new Sandbox();
var functions = sandbox.GetSandboxFunctions();

// Register with chat client
var client = new ChatClient(model: openAiModel);
var response = await client.CompleteAsync(
    messages: new[] { new ChatMessage(ChatRole.User, "List files in /tmp") },
    tools: functions.ToList()
);

Dependency Injection

using AgentSandbox.Extensions.DependencyInjection;

services.AddAgentSandbox(options =>
{
    options.WorkingDirectory = "/workspace";
    options.MaxTotalSize = 1024 * 1024;
});

// Or with sandbox manager for multi-tenant scenarios
services.AddSandboxManager();

Observability

OpenTelemetry

using AgentSandbox.Extensions.Observability;

services.AddOpenTelemetry()
    .WithTracing(builder => builder.AddSandboxInstrumentation())
    .WithMetrics(builder => builder.AddSandboxInstrumentation());

Application Insights

services.AddApplicationInsightsTelemetry();
services.AddSandboxApplicationInsights();

Logging

services.AddSandboxLogging();

Shell Extensions

Shell command extensions are in AgentSandbox.Core.Shell.Extensions:

using AgentSandbox.Core;
using AgentSandbox.Core.Shell.Extensions;

var options = new SandboxOptions
{
    ShellExtensions = [
        new CurlCommand(),  // HTTP requests
        new JqCommand(),    // JSON processing
        new GitCommand()    // Git operations
    ]
};

var sandbox = new Sandbox(options: options);

// Now available in shell
sandbox.Execute("curl https://api.example.com/data");
sandbox.Execute("echo '{\"name\":\"test\"}'");
sandbox.Execute("git init");

See Also

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.1.0 101 3/23/2026
5.0.0 118 2/24/2026
3.0.1 121 1/27/2026
3.0.0 116 1/22/2026
2.0.0 108 1/22/2026
1.3.0 120 1/20/2026
1.2.1 117 1/18/2026