Class SkillActivator
Handles skill activation and context injection for agent conversations.
The activator prepares skill instructions for injection into the agent's context, managing the transformation from raw skill content to properly formatted prompts.
public sealed class SkillActivator
- Inheritance
-
SkillActivator
- Inherited Members
Remarks
Context Injection Strategies
The activator supports multiple injection strategies:
- SystemPrompt: Prepend to system prompt.
- UserMessage: Insert as a user message.
- ToolResult: Return as tool invocation result.
Usage
var activator = new SkillActivator();
// Prepare skill context for injection
var context = activator.PrepareContext(skill, userRequest);
// Get formatted prompt with skill instructions
string prompt = activator.FormatForInjection(skill, SkillInjectionMode.SystemPrompt);
Constructors
- SkillActivator(SkillRegistry)
Initializes a new instance of the SkillActivator class.
Properties
- DefaultInjectionMode
Gets or sets the default injection mode for skill activation.
- IncludeResourceListing
Gets or sets whether to include resource listings in the activation context.
- MaxInstructionLength
Gets or sets the maximum instruction length to include directly. Instructions exceeding this length may be truncated or summarized.
Methods
- Activate(AgentSkill, string)
Activates a skill and prepares its context for injection.
- Activate(string, string)
Activates a skill by name and prepares its context for injection.
- CreateDiscoveryPrompt()
Creates a discovery prompt listing all available skills.
This is useful for system prompts that need to inform the agent about available skills without fully activating any of them.
- FormatForInjection(AgentSkill, SkillInjectionMode, string)
Formats a skill's instructions for injection into the agent context.
- GetResourceContent(AgentSkill, string)
Gets a resource's content from a skill, loading it on demand.
- GetResourceContentAsync(AgentSkill, string, CancellationToken)
Gets a resource's content asynchronously.