ExAgent.Patterns.Skills (ExAgent v0.4.1)

Copy Markdown View Source

Progressive disclosure pattern.

Allows a single agent to dynamically load specialized system prompts and tool sets based on conversation context. Skills are evaluated before each LLM call and the matching skill's persona is applied.

Summary

Functions

Applies a skill to the agent state by updating the active_skill and injecting the skill's system prompt into the provider.

Deactivates the active skill, restoring the agent's own system prompt.

Returns the effective tools: base tools plus active skill tools.

Evaluates all skills against the current context.

Functions

apply_skill(state, skill)

@spec apply_skill(map(), ExAgent.Skill.t()) :: map()

Applies a skill to the agent state by updating the active_skill and injecting the skill's system prompt into the provider.

Providers with no :system_prompt field keep the skill's tools; the prompt simply has nowhere to go.

clear_skill(state)

@spec clear_skill(map()) :: map()

Deactivates the active skill, restoring the agent's own system prompt.

Skills are evaluated before every turn, so one that stops matching has to be undone - otherwise the first activation would overwrite the agent's persona permanently.

effective_tools(map)

@spec effective_tools(map()) :: [ExAgent.Tool.t()]

Returns the effective tools: base tools plus active skill tools.

evaluate(skills, context)

@spec evaluate([ExAgent.Skill.t()], ExAgent.Context.t()) :: ExAgent.Skill.t() | nil

Evaluates all skills against the current context.

Returns the first skill whose activation_fn returns true, or nil if no skill matches or has an activation function.