Infrastructure implementations for Strategos including Thompson Sampling agent selection, loop detection (repetition, semantic, oscillation, no-progress), and budget enforcement with scarcity levels.
$ dotnet add package LevelUp.Strategos.InfrastructureInfrastructure implementations for Strategos including Thompson Sampling agent selection, loop detection, and budget enforcement.
dotnet add package LevelUp.Strategos.Infrastructure
Contextual bandit algorithm for intelligent agent selection based on historical performance.
services.AddStrategosInfrastructure(options =>
{
options.ThompsonSampling.ExplorationWeight = 0.3;
options.ThompsonSampling.MinSamples = 10;
});
// In your step
var agent = await agentSelector.SelectAgentAsync(
availableAgents,
taskContext,
cancellationToken);
Detects stuck workflows using multiple strategies:
var loopResult = await loopDetector.DetectLoopAsync(
workflowHistory,
cancellationToken);
if (loopResult.IsLooping)
{
// Apply recovery strategy
var recovery = loopResult.SuggestedRecovery;
}
Enforces resource limits with scarcity-aware scoring:
var budget = new WorkflowBudget
{
MaxSteps = 50,
MaxTokens = 100_000,
MaxWallTime = TimeSpan.FromMinutes(30)
};
var canProceed = await budgetGuard.CheckBudgetAsync(
currentUsage,
budget,
cancellationToken);
Scarcity Levels:
services.AddStrategosInfrastructure(options =>
{
// Thompson Sampling
options.ThompsonSampling.ExplorationWeight = 0.3;
options.ThompsonSampling.SuccessWeight = 2.0;
// Loop Detection
options.LoopDetection.WindowSize = 10;
options.LoopDetection.SemanticThreshold = 0.85;
// Budget
options.Budget.DefaultScarcityLevel = ScarcityLevel.Normal;
});
MIT