Class AdaptiveInstructionsUpdater
Embedding-based dynamic instructions updater.
Register multiple InstructionsRule entries; before each request the updater embeds the user message, computes cosine similarity against every rule description, and returns the instructions of the best-matching rule.
Returns null (leaving instructions unchanged) when no rule exceeds MinSimilarity.
var updater = new AdaptiveInstructionsUpdater(embeddingModel)
.AddRule("user is asking about billing or payments", billingInstructions)
.AddRule("user is reporting a bug or technical issue", techSupportInstructions)
.SetMinSimilarity(0.72f);
agent.SetInstructionsUpdater(updater);
Inheritance
Implements
Inherited Members
Namespace: Glitch9.AIDevKit.Agents
Assembly: Glitch9.AIDevKit.dll
Syntax
public sealed class AdaptiveInstructionsUpdater : InstructionsUpdaterBase<IAdaptiveInstructionsUpdaterSettings>, IInstructionsUpdater
Constructors
| Edit this page View SourceAdaptiveInstructionsUpdater(IAdaptiveInstructionsUpdaterSettings, ILogger)
Declaration
public AdaptiveInstructionsUpdater(IAdaptiveInstructionsUpdaterSettings settings, ILogger logger)
Parameters
| Type | Name | Description |
|---|---|---|
| IAdaptiveInstructionsUpdaterSettings | settings | |
| ILogger | logger |
Methods
| Edit this page View SourceInvalidate()
Forces the embedding index to be rebuilt on the next call. Call this manually when rules are replaced at runtime.
Declaration
public void Invalidate()
ShouldSkip(string)
Returns true if the message is trivially short or meaningless and should skip instruction update. Override in subclasses to add additional skip conditions; call base.ShouldSkip() first.
Declaration
public override bool ShouldSkip(string lastUserMessage)
Parameters
| Type | Name | Description |
|---|---|---|
| string | lastUserMessage |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
| Edit this page View SourceUpdateInstructionsAsync(string, CancellationToken)
Returns updated system instructions for the next request.
Called automatically before every SendAsync(string, int, CancellationToken) call.
Return null to keep the current instructions unchanged.
Declaration
public override UniTask<string> UpdateInstructionsAsync(string lastUserMessage, CancellationToken ct = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | lastUserMessage | The user's message that triggered this request. |
| CancellationToken | ct | Cancellation token. |
Returns
| Type | Description |
|---|---|
| UniTask<string> |