Skip to content

NexusLabs.Needlr.AgentFramework.Workflows.Budget

NexusLabs.Needlr.AgentFramework.Workflows

NexusLabs.Needlr.AgentFramework.Workflows.Budget Namespace

Classes
ContextWindowGuardMiddleware Microsoft.Extensions.AI.DelegatingChatClient safety net that estimates cumulative context size across LLM calls and emits a warning when approaching a configurable limit. Optionally prunes oldest non-system messages to keep context under the limit.
TokenBudgetChatMiddleware Microsoft.Extensions.AI.DelegatingChatClient that accumulates token usage from each LLM call into an NexusLabs.Needlr.AgentFramework.Budget.ITokenBudgetTracker and aborts when the budget is exceeded. Emits NexusLabs.Needlr.AgentFramework.Progress.BudgetUpdatedEvent and NexusLabs.Needlr.AgentFramework.Progress.BudgetExceededEvent to the progress reporter in real-time.
TokenBudgetExtensions Extension methods for wiring token-budget enforcement into the agent framework.