RunAgent 0.1.48
dotnet add package RunAgent --version 0.1.48
NuGet\Install-Package RunAgent -Version 0.1.48
<PackageReference Include="RunAgent" Version="0.1.48" />
<PackageVersion Include="RunAgent" Version="0.1.48" />
<PackageReference Include="RunAgent" />
paket add RunAgent --version 0.1.48
#r "nuget: RunAgent, 0.1.48"
#:package RunAgent@0.1.48
#addin nuget:?package=RunAgent&version=0.1.48
#tool nuget:?package=RunAgent&version=0.1.48
RunAgent C# SDK
C# SDK for RunAgent - Secured, reliable AI agent deployment at scale. Run your stack. Let us run your agents.
Features
- Multi-Language Support: Access Python AI agents from C#/.NET applications
- Local & Remote Deployment: Support for both local development and cloud deployments
- Streaming & Non-Streaming: Execute agents synchronously or with real-time streaming
- Persistent Memory: Enable stateful interactions with user-isolated memory
- Type-Safe: Full C# type safety with async/await patterns
- Framework Agnostic: Works with any Python agent framework (LangGraph, CrewAI, Letta, etc.)
Installation
NuGet Package Manager
dotnet add package RunAgent
Package Manager Console
Install-Package RunAgent
Quick Start
Remote Agent Execution
using RunAgent.Client;
using RunAgent.Types;
// Create client configuration
var config = RunAgentClientConfig
.Create("YOUR_AGENT_ID", "solve_problem")
.WithApiKey("your-api-key"); // Or set RUNAGENT_API_KEY environment variable
// Initialize client
var client = await RunAgentClient.CreateAsync(config);
// Execute agent
var result = await client.RunAsync(new Dictionary<string, object>
{
["query"] = "My laptop is slow",
["num_solutions"] = 3,
["constraints"] = new List<object>
{
new Dictionary<string, object>
{
["type"] = "budget",
["value"] = 100
}
}
});
Console.WriteLine(JsonSerializer.Serialize(result, new JsonSerializerOptions
{
WriteIndented = true
}));
// Cleanup
client.Dispose();
Streaming Execution
// Create client for streaming entrypoint
var config = RunAgentClientConfig
.Create("YOUR_AGENT_ID", "solve_problem_stream")
.WithApiKey("your-api-key");
var client = await RunAgentClient.CreateAsync(config);
// Stream results in real-time
await foreach (var chunk in client.RunStreamAsync(new Dictionary<string, object>
{
["query"] = "Fix my phone",
["num_solutions"] = 4
}))
{
Console.Write(chunk);
}
client.Dispose();
Local Agent Development
// Connect to local agent
var config = RunAgentClientConfig
.Create("local-agent-id", "generic")
.WithLocal(true)
.WithHostAndPort("127.0.0.1", 8450); // Optional: auto-discovers if not specified
var client = await RunAgentClient.CreateAsync(config);
// Execute local agent
var result = await client.RunAsync(new Dictionary<string, object>
{
["message"] = "Hello from C# SDK!"
});
client.Dispose();
Persistent Memory
Enable stateful interactions with persistent memory:
// Create client with persistent memory
var config = RunAgentClientConfig
.Create("YOUR_AGENT_ID", "chat")
.WithApiKey("your-api-key")
.WithUserId("user123") // User identifier for memory isolation
.WithPersistentMemory(true); // Enable persistent memory
var client = await RunAgentClient.CreateAsync(config);
// First interaction - agent learns preference
var result1 = await client.RunAsync(new Dictionary<string, object>
{
["message"] = "I prefer dark mode interfaces"
});
// Second interaction - agent remembers the preference
var result2 = await client.RunAsync(new Dictionary<string, object>
{
["message"] = "What's my UI preference?"
});
// Agent responds: "You prefer dark mode interfaces"
client.Dispose();
Configuration
Configuration Precedence
Configuration values are resolved in the following order:
- Explicit constructor arguments (highest priority)
- Environment variables
- Library defaults (lowest priority)
Configuration Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
AgentId |
string |
Yes | - | Agent identifier |
EntrypointTag |
string |
Yes | - | Entrypoint tag to invoke |
Local |
bool |
No | false |
Enable local mode |
Host |
string |
No | 127.0.0.1 |
Local agent host |
Port |
int |
No | 8450 |
Local agent port |
ApiKey |
string |
No | - | API key for remote auth |
BaseUrl |
string |
No | https://backend.run-agent.ai |
Remote deployment URL |
UserId |
string |
No | - | User ID for memory isolation |
PersistentMemory |
bool |
No | false |
Enable persistent memory |
ExtraParams |
Dictionary<string, object> |
No | - | Extra metadata parameters |
Environment Variables
RUNAGENT_API_KEY- API key for remote authenticationRUNAGENT_BASE_URL- Base URL for remote deployments
Builder Pattern
Use the fluent builder API for configuration:
var config = RunAgentClientConfig
.Create("agent-id", "entrypoint")
.WithApiKey("key")
.WithUserId("user123")
.WithPersistentMemory(true)
.WithExtraParams(new Dictionary<string, object>
{
["custom_field"] = "value"
});
Error Handling
The SDK provides a comprehensive error taxonomy:
| Error Type | Description |
|---|---|
AuthenticationError |
Missing or invalid API key (HTTP 401, 403) |
PermissionError |
Access denied (HTTP 403) |
ConnectionError |
Network issues, timeouts, DNS failures |
ValidationError |
Bad config, missing agent, invalid entrypoint (HTTP 400, 404, 422) |
ServerError |
Backend failures (HTTP 5xx) |
RunAgentExecutionError |
Structured execution errors with code, message, suggestion, details |
UnknownError |
Unclassified errors |
Example Error Handling
try
{
var client = await RunAgentClient.CreateAsync(config);
var result = await client.RunAsync(kwargs);
}
catch (AuthenticationError ex)
{
Console.WriteLine($"Auth Error: {ex.Message}");
Console.WriteLine("Set RUNAGENT_API_KEY or pass apiKey in config");
}
catch (ValidationError ex)
{
Console.WriteLine($"Validation Error: {ex.Message}");
}
catch (RunAgentExecutionError ex)
{
Console.WriteLine($"Execution Error [{ex.Code}]: {ex.Message}");
if (ex.Suggestion != null)
Console.WriteLine($"Suggestion: {ex.Suggestion}");
}
catch (ConnectionError ex)
{
Console.WriteLine($"Connection Error: {ex.Message}");
}
API Reference
RunAgentClient
Static Methods
CreateAsync(RunAgentClientConfig config)- Create and initialize clientCreateFromEnvironmentAsync(string agentId, string entrypointTag)- Create client from environment variables
Instance Methods
RunAsync(Dictionary<string, object>? kwargs)- Execute agent synchronouslyRunAsync(List<object>? args, Dictionary<string, object>? kwargs)- Execute with positional and keyword argumentsRunStreamAsync(Dictionary<string, object>? kwargs)- Execute with streamingRunStreamAsync(List<object>? args, Dictionary<string, object>? kwargs)- Stream with positional and keyword argumentsGetAgentArchitecture()- Get agent architecture definitionHealthCheckAsync()- Check agent availabilityGetAgentId()- Get agent IDGetEntrypointTag()- Get entrypoint tagIsLocal()- Check if running in local modeGetUserId()- Get user ID for persistent memoryIsPersistentMemoryEnabled()- Check if persistent memory is enabledGetExtraParams()- Get extra parametersDispose()- Cleanup resources
Entrypoint Validation
The SDK enforces correct usage of streaming vs non-streaming entrypoints:
- Streaming entrypoints (tags ending with
_stream): Must useRunStreamAsync() - Non-streaming entrypoints: Must use
RunAsync()
Attempting to use the wrong method will throw a ValidationError with a helpful suggestion.
Local Agent Setup
To use local agents:
Start your local agent:
cd my-agent runagent serve .Connect from C#:
var config = RunAgentClientConfig .Create("local-agent-id", "entrypoint") .WithLocal(true); var client = await RunAgentClient.CreateAsync(config);
Persistent Memory
Persistent Memory enables stateful agent interactions:
- User Isolation: Each
UserIdhas isolated memory space - Cross-Execution: State persists across multiple agent invocations
- Multi-Language: Works seamlessly with all RunAgent SDKs
- Serverless: Built on serverless infrastructure that scales automatically
Use Cases
- Conversational AI with context retention
- Personalized user experiences
- Multi-step workflows
- Learning systems that improve over time
Security Best Practices
- Never hardcode API keys - Use environment variables or secure configuration
- Validate inputs - Always validate user inputs before passing to agents
- Handle errors gracefully - Implement proper error handling for production use
- Use HTTPS - Always use secure connections for remote agents
- Isolate users - Use unique
UserIdvalues for multi-tenant applications
Examples
See the examples directory for complete working examples:
BasicExample.cs- Non-streaming agent executionStreamingExample.cs- Real-time streaming responsesLocalExample.cs- Local agent deploymentPersistentMemoryExample.cs- Stateful interactions with persistent memory
Requirements
- .NET 8.0 or higher
- C# 12.0 or higher
Dependencies
System.Text.Json9.0.0
Troubleshooting
"Authentication failed" error
Cause: Missing or invalid API key
Solution: Set RUNAGENT_API_KEY environment variable or pass apiKey in config:
var config = RunAgentClientConfig
.Create("agent-id", "entrypoint")
.WithApiKey("your-api-key");
"Entrypoint not found" error
Cause: Specified entrypoint tag doesn't exist
Solution: Check the error message for available entrypoints, or fetch architecture:
var architecture = client.GetAgentArchitecture();
foreach (var ep in architecture.Entrypoints)
{
Console.WriteLine($"Available: {ep.Tag}");
}
Connection timeout
Cause: Network issues or agent not responding
Solution:
- For local agents: Ensure agent is running with
runagent serve . - For remote agents: Check network connectivity and agent status in dashboard
"STREAM_ENTRYPOINT" or "NON_STREAM_ENTRYPOINT" error
Cause: Using wrong method for entrypoint type
Solution:
- For
*_streamtags: UseRunStreamAsync() - For other tags: Use
RunAsync()
Contributing
Contributions are welcome! Please see the main RunAgent repository for contribution guidelines.
License
MIT License - see LICENSE file for details.
Support
- Documentation: https://docs.run-agent.ai
- Discord: Join our Discord community
- GitHub Issues: Report bugs or request features
Related Projects
- runagent-py - Python SDK (CLI + Client)
- runagent-js - JavaScript/TypeScript SDK
- runagent-rs - Rust SDK
- runagent-go - Go SDK
- runagent-dart - Dart SDK
Made with ❤️ by the RunAgent Team
| 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
- System.Text.Json (>= 9.0.0)
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 |
|---|---|---|
| 0.1.48 | 97 | 2/3/2026 |