AgentSandbox.Extensions
5.1.0
dotnet add package AgentSandbox.Extensions --version 5.1.0
NuGet\Install-Package AgentSandbox.Extensions -Version 5.1.0
<PackageReference Include="AgentSandbox.Extensions" Version="5.1.0" />
<PackageVersion Include="AgentSandbox.Extensions" Version="5.1.0" />
<PackageReference Include="AgentSandbox.Extensions" />
paket add AgentSandbox.Extensions --version 5.1.0
#r "nuget: AgentSandbox.Extensions, 5.1.0"
#:package AgentSandbox.Extensions@5.1.0
#addin nuget:?package=AgentSandbox.Extensions&version=5.1.0
#tool nuget:?package=AgentSandbox.Extensions&version=5.1.0
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 optionaloutput
- Parameters:
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, andoutput(joined file content) - Line indexes are 1-based (
startLineinclusive,endLineexclusive) - Example:
read_file('/logs.txt', 100, 120)returns lines 100-119
- Parameters:
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
- Parameters:
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
- Parameters:
get_skill- Retrieve skill information and instructions- Parameters:
skillName(string) - Returns: Skill metadata and instructions, or error if not found
- Parameters:
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
- AgentSandbox.Core - Core sandbox functionality
- Semantic Kernel Documentation
| Product | Versions 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. |
-
net8.0
- AgentSandbox.Core (>= 5.1.0)
- Microsoft.ApplicationInsights (>= 2.22.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.SemanticKernel (>= 1.68.0)
- OpenTelemetry (>= 1.11.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.