Installation
Installation
Section titled “Installation”This guide covers installing Strategos packages and configuring your .NET application for workflow development.
Package Options
Section titled “Package Options”Strategos is distributed as several NuGet packages. Choose the combination that fits your needs:
Minimal Setup
Section titled “Minimal Setup”For basic workflow functionality without persistence:
dotnet add package LevelUp.StrategosThis includes the core workflow DSL, step interfaces, and in-memory execution. Suitable for prototyping and testing.
Standard Setup (Recommended)
Section titled “Standard Setup (Recommended)”For production workflows with durable persistence:
dotnet add package LevelUp.Strategosdotnet add package LevelUp.Strategos.MartenThis adds PostgreSQL persistence via Marten and Wolverine, enabling workflows that survive process restarts.
Full Setup with RAG
Section titled “Full Setup with RAG”For AI agent workflows with retrieval-augmented generation:
dotnet add package LevelUp.Strategosdotnet add package LevelUp.Strategos.Martendotnet add package LevelUp.Strategos.Agentsdotnet add package LevelUp.Strategos.RAGThis adds Thompson Sampling agent selection and vector-based document retrieval.
Dependencies
Section titled “Dependencies”Required
Section titled “Required”- .NET 10 SDK - Strategos targets .NET 10
- PostgreSQL 14+ - Required for Marten persistence
Included Automatically
Section titled “Included Automatically”The following packages are pulled in as transitive dependencies:
- Wolverine - Message-based workflow orchestration
- Marten - Document database and event sourcing on PostgreSQL
- JasperFx - Core runtime components
Service Registration
Section titled “Service Registration”Configure Strategos in your Program.cs or startup class.
Minimal Configuration
Section titled “Minimal Configuration”var builder = WebApplication.CreateBuilder(args);
// Add workflow services with in-memory executionbuilder.Services.AddStrategos();
var app = builder.Build();app.Run();Standard Configuration with Persistence
Section titled “Standard Configuration with Persistence”var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("PostgreSQL");
// Add workflow services with Marten persistencebuilder.Services.AddStrategos() .AddMartenPersistence(connectionString);
// Optional: Configure Wolverine for advanced scenariosbuilder.Host.UseWolverine(opts =>{ opts.Durability.Mode = DurabilityMode.Solo;});
var app = builder.Build();app.Run();Full Configuration with Agents
Section titled “Full Configuration with Agents”var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration.GetConnectionString("PostgreSQL");
builder.Services.AddStrategos() .AddMartenPersistence(connectionString) .AddAgentSelection(options => options .WithPrior(alpha: 2, beta: 2) .WithCategories( TaskCategory.Analysis, TaskCategory.Coding, TaskCategory.Research));
// Register agentsbuilder.Services.AddAgent("analyst", new AgentConfig{ Name = "Data Analyst", Capabilities = ["data-analysis", "visualization"]});
var app = builder.Build();app.Run();PostgreSQL Setup
Section titled “PostgreSQL Setup”Marten automatically creates database schemas on startup. Ensure your PostgreSQL user has the necessary permissions.
Connection String
Section titled “Connection String”{ "ConnectionStrings": { "PostgreSQL": "Host=localhost;Database=workflows;Username=app;Password=secret" }}Docker Quick Start
Section titled “Docker Quick Start”For local development:
docker run -d \ --name workflow-postgres \ -e POSTGRES_USER=app \ -e POSTGRES_PASSWORD=secret \ -e POSTGRES_DB=workflows \ -p 5432:5432 \ postgres:16Schema Migrations
Section titled “Schema Migrations”Marten handles schema creation automatically. For production deployments, you can generate migration scripts:
// During developmentbuilder.Services.AddMarten(connectionString) .ApplyAllDatabaseChangesOnStartup();
// For production - generate scripts insteadvar store = app.Services.GetRequiredService<IDocumentStore>();await store.Storage.ApplyAllConfiguredChangesToDatabaseAsync();Verify Installation
Section titled “Verify Installation”Create a simple workflow to verify your setup works correctly.
1. Define State
Section titled “1. Define State”[WorkflowState]public record HelloState : IWorkflowState{ public Guid WorkflowId { get; init; } public string Message { get; init; } = string.Empty;}2. Create a Step
Section titled “2. Create a Step”public class SayHello : IWorkflowStep<HelloState>{ public Task<StepResult<HelloState>> ExecuteAsync( HelloState state, StepContext context, CancellationToken ct) { var result = state .With(s => s.Message, "Hello, Strategos!") .AsResult();
return Task.FromResult(result); }}3. Define the Workflow
Section titled “3. Define the Workflow”var workflow = Workflow<HelloState> .Create("hello-world") .StartWith<SayHello>();4. Register and Run
Section titled “4. Register and Run”// In Program.csbuilder.Services.AddStrategos() .AddWorkflow<HelloWorldWorkflow>();
// In a controller or servicepublic class TestController : ControllerBase{ private readonly IWorkflowStarter _starter;
public TestController(IWorkflowStarter starter) { _starter = starter; }
[HttpPost("test")] public async Task<IActionResult> Test() { var state = new HelloState { WorkflowId = Guid.NewGuid() }; await _starter.StartAsync("hello-world", state); return Ok("Workflow started"); }}5. Verify Output
Section titled “5. Verify Output”Start your application and call the test endpoint. Check your logs for:
info: Strategos[0] Workflow hello-world started with ID: a1b2c3d4-... Executing step: SayHello Step completed: SayHello Workflow hello-world completedTroubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Missing package reference
Section titled “Missing package reference”error CS0246: The type or namespace name 'IWorkflowState' could not be foundEnsure Strategos is referenced and you have using Strategos;
PostgreSQL connection failed
Section titled “PostgreSQL connection failed”Npgsql.NpgsqlException: Failed to connect to hostVerify PostgreSQL is running and the connection string is correct.
Schema creation failed
Section titled “Schema creation failed”42501: permission denied for schema publicGrant your database user permission to create tables, or run migrations as a superuser.
Key Points
Section titled “Key Points”- Start with the minimal setup for prototyping, add persistence for production
- Marten handles schema management automatically
- Wolverine provides durable message processing
- Verify installation with a simple hello-world workflow
- Connection strings go in
appsettings.json
Next Steps
Section titled “Next Steps”Now that you have Strategos installed, continue to Your First Workflow to build a complete order processing example.