Jido.AI.Skill.Prompt (Jido AI v2.3.0)

Copy Markdown View Source

Renders skills into prompt text for agent system prompts.

Provides utilities to format skill manifests and bodies into structured text that can be prepended/appended to agent prompts.

Summary

Functions

Collects all allowed tools from a list of skills.

Filters a list of tool modules by the allowed tools from skills.

Renders a list of skills into a formatted prompt section.

Renders a compact, model-facing skill index.

Renders a single skill into formatted prompt text.

Renders a compact index for skills currently registered in the runtime registry.

Functions

collect_allowed_tools(skills)

@spec collect_allowed_tools([module() | Jido.AI.Skill.Spec.t() | String.t()]) :: [
  String.t()
]

Collects all allowed tools from a list of skills.

Returns the union of all allowed_tools from the given skills.

filter_tools(tools, skills)

@spec filter_tools([module()], [module() | Jido.AI.Skill.Spec.t() | String.t()]) :: [
  module()
]

Filters a list of tool modules by the allowed tools from skills.

Returns only the tools whose names match the union of allowed_tools from the given skills. If no skills specify allowed_tools, returns all tools.

render(skills, opts \\ [])

@spec render(
  [module() | Jido.AI.Skill.Spec.t() | String.t()],
  keyword()
) :: String.t()

Renders a list of skills into a formatted prompt section.

Options

  • :include_body - Include skill body content (default: false). Prefer render_index/2 plus Jido.AI.Actions.Skill.LoadSkill for progressive disclosure.
  • :header - Custom header text (default: "You have access to the following skills:")

Example

skills = [MyApp.Skills.Calculator, "code-review"]
Skill.Prompt.render(skills)
# => "You have access to the following skills:\n\n## calculator\n..."

render_index(skills, opts \\ [])

@spec render_index(
  [module() | Jido.AI.Skill.Spec.t() | String.t()],
  keyword()
) :: String.t()

Renders a compact, model-facing skill index.

Unlike render/2, this function intentionally omits skill bodies so prompts can advertise available skills without loading their full instructions. Pair the rendered index with Jido.AI.Actions.Skill.LoadSkill so a model can load the selected skill body on demand.

Options

  • :tags - String, atom, or list of tags used to filter skills.
  • :tag_match - :any (default) or :all when multiple tags are provided.
  • :header - Header text (default: "## Skills"). Set to false or nil to omit.
  • :load_instruction - Instruction appended after the index. Set to false or nil to omit.
  • :include_allowed_tools - Append allowed tool names to each entry.

render_one(skill, opts \\ [])

@spec render_one(
  module() | Jido.AI.Skill.Spec.t() | String.t(),
  keyword()
) :: String.t()

Renders a single skill into formatted prompt text.

render_registry_index(opts \\ [])

@spec render_registry_index(keyword()) :: String.t()

Renders a compact index for skills currently registered in the runtime registry.

This is the common entry point for lazy skill loading: register runtime skills, render a filtered index into the agent system prompt, and expose the load_skill action so the agent can retrieve the full body only when needed.