Skip to content

Package Ecosystem

Strategos is distributed as multiple NuGet packages, allowing you to include only what you need.

Package Overview

PackagePurposeRequired
StrategosCore fluent DSL, abstractions, and type definitionsYes
Strategos.GeneratorsRoslyn source generators for compile-time code generationYes
Strategos.InfrastructureProduction implementations (Thompson Sampling, loop detection, budgets)Recommended
Strategos.AgentsMicrosoft.Extensions.AI integration for LLM-powered stepsFor AI workflows
Strategos.RagVector store adapters for RAG patternsFor RAG workflows

Strategos

The core package containing the fluent DSL for defining workflows and all foundational abstractions.

Key Types

TypePurpose
Workflow<TState>Entry point for fluent workflow definitions
IWorkflowStep<TState>Interface for implementing workflow steps
IWorkflowDefinition<TState>Interface for workflow definition classes
StepResult<TState>Result type returned from step execution
StepContextExecution context passed to steps (correlation ID, timestamp, metadata)

Thompson Sampling Types

TypePurpose
AgentBeliefBeta(alpha, beta) distribution representing agent performance belief
TaskCategoryEnumeration of task categories (Analysis, Coding, Research, etc.)
TaskFeaturesExtracted features from task descriptions
IAgentSelectorInterface for agent selection strategies
IBeliefStoreInterface for persisting agent beliefs

State Attributes

AttributePurpose
[Append]Merge lists by appending new items to existing
[Merge]Merge dictionaries, new values overwrite existing keys
[WorkflowState]Marks a record as workflow state (enables source generation)

Installation

bash
dotnet add package LevelUp.Strategos

Strategos.Generators

Roslyn source generators that transform fluent DSL definitions into type-safe artifacts at compile time.

Generated Artifacts

ArtifactDescription
Phase EnumType-safe enumeration of workflow phases
CommandsWolverine message types for step transitions
EventsMarten event types for audit trail
Saga ClassComplete Wolverine saga with handlers
State ReducersProperty merge logic based on [Append]/[Merge] attributes
DI ExtensionsService registration helpers

Compiler Diagnostics

The generator reports errors and warnings at compile time. See Diagnostics Reference for the complete list.

CodeSeverityDescription
AGWF001ErrorWorkflow name cannot be empty
AGWF002WarningNo steps found in workflow
AGWF003ErrorDuplicate step name (use instance names)
AGWF009ErrorWorkflow must begin with StartWith<T>()
AGWF010WarningWorkflow should end with Finally<T>()
AGWF012ErrorEvery Fork must be followed by Join<T>()

Installation

bash
dotnet add package LevelUp.Strategos.Generators

Development Dependency

This is a compile-time dependency. It runs during build and produces no runtime overhead.


Strategos.Infrastructure

Production-ready implementations of core abstractions including Thompson Sampling, loop detection, and budget enforcement.

Thompson Sampling

TypePurpose
ContextualAgentSelectorSelects agents using Thompson Sampling with contextual bandits
InMemoryBeliefStoreIn-memory persistence for agent beliefs (dev/testing)
KeywordTaskFeatureExtractorExtracts task features for category classification

Loop Detection

Detects stuck workflows using four strategies:

DetectorDescription
ExactRepetitionDetectorIdentical action sequences
SemanticRepetitionDetectorSimilar outputs (cosine similarity > threshold)
OscillationDetectorA-B-A-B patterns
NoProgressDetectorActivity without state change

Budget Guard

TypePurpose
BudgetGuardEnforces resource limits (steps, tokens, wall time)
ScarcityLevelAbundant, Normal, Scarce, Critical
BudgetOptionsConfiguration for budget thresholds

Installation

bash
dotnet add package LevelUp.Strategos.Infrastructure

Usage

csharp
services.AddStrategos()
    .AddThompsonSampling(options => options
        .WithPrior(alpha: 2, beta: 2))
    .AddLoopDetection()
    .AddBudgetGuard(options => options
        .WithMaxSteps(100)
        .WithMaxTokens(50_000));

Strategos.Agents

Integration with Microsoft.Extensions.AI for LLM-powered workflow steps.

Key Types

TypePurpose
IAgentStep<TState>Base interface for LLM-powered steps
AgentStepContextExtended context with conversation thread access
IConversationalStateInterface for state that includes conversation history
IStreamingCallbackCallback for real-time token streaming

Dependencies

  • Microsoft.Extensions.AI (10.0.1)
  • Microsoft.Extensions.AI.Abstractions (10.0.1)

Installation

bash
dotnet add package LevelUp.Strategos.Agents

Usage

csharp
public class AnalyzeDocumentStep : IAgentStep<DocumentState>
{
    private readonly IChatClient _chatClient;

    public AnalyzeDocumentStep(IChatClient chatClient)
    {
        _chatClient = chatClient;
    }

    public async Task<StepResult<DocumentState>> ExecuteAsync(
        DocumentState state,
        AgentStepContext context,
        CancellationToken ct)
    {
        var response = await _chatClient.GetResponseAsync(
            $"Analyze this document: {state.Content}",
            ct);

        return state
            .With(s => s.Analysis, response)
            .AsResult();
    }
}

Strategos.Rag

Vector store adapters for Retrieval-Augmented Generation (RAG) patterns.

Implemented Adapters

AdapterStatusUse Case
InMemoryVectorSearchAdapterAvailableDevelopment and testing

Planned Adapters

AdapterStatusUse Case
PgVectorAdapterPlannedPostgreSQL with pgvector extension
AzureAISearchAdapterPlannedAzure AI Search

Key Interfaces

TypePurpose
IVectorSearchAdapterInterface for vector similarity search
SearchResultResult containing content, score, and metadata

Installation

bash
dotnet add package LevelUp.Strategos.Rag

Usage

csharp
public class RetrieveContextStep : IWorkflowStep<QueryState>
{
    private readonly IVectorSearchAdapter _vectorSearch;

    public async Task<StepResult<QueryState>> ExecuteAsync(
        QueryState state,
        StepContext context,
        CancellationToken ct)
    {
        var results = await _vectorSearch.SearchAsync(
            state.Query,
            topK: 10,
            minRelevance: 0.7);

        return state
            .With(s => s.RetrievedContext, results)
            .AsResult();
    }
}

Installation Scenarios

Minimal (Non-AI Workflows)

For workflows that don't involve LLM agents:

bash
dotnet add package LevelUp.Strategos
dotnet add package LevelUp.Strategos.Generators

Standard (LLM-Powered Workflows)

Most common setup for AI agent workflows:

bash
dotnet add package LevelUp.Strategos
dotnet add package LevelUp.Strategos.Generators
dotnet add package LevelUp.Strategos.Agents
dotnet add package LevelUp.Strategos.Infrastructure

Full (With RAG)

For workflows that include retrieval-augmented generation:

bash
dotnet add package LevelUp.Strategos
dotnet add package LevelUp.Strategos.Generators
dotnet add package LevelUp.Strategos.Agents
dotnet add package LevelUp.Strategos.Infrastructure
dotnet add package LevelUp.Strategos.Rag

Package Dependencies

plaintext
Strategos (core)
+-- No external dependencies

Strategos.Generators
+-- Microsoft.CodeAnalysis.CSharp
+-- [Compile-time only]

Strategos.Infrastructure
+-- Strategos
+-- Microsoft.Extensions.Caching.Memory
+-- Microsoft.Extensions.DependencyInjection.Abstractions

Strategos.Agents
+-- Strategos
+-- Microsoft.Extensions.AI
+-- Microsoft.Extensions.AI.Abstractions
+-- Microsoft.Extensions.DependencyInjection.Abstractions

Strategos.Rag
+-- Strategos.Agents

Released under the MIT License.