Skills.Runtime (fnord v0.9.29)

View Source

Runtime helpers for executing skills.

This module owns the glue between skill definitions (TOML) and the runtime components used to execute them:

  • model preset parsing (skill model string -> AI.Model.t())
  • tool tag mapping (skill tools -> AI.Tools.toolbox())
  • response_format validation

Keeping these helpers in one place avoids duplicating the execution rules between the agent (AI.Agent.Skill) and the tool entry points.

Summary

Functions

Return the list of allowed model presets.

Return the list of allowed toolboxes.

Resolve a model preset string (from skill TOML) into an AI.Model struct.

Returns the reasoning preamble that is prepended to every skill's system prompt.

Build a toolbox from skill tool tags.

Validate a response_format value from a skill.

Types

model_error()

@type model_error() :: {:unknown_model_preset, String.t()}

response_format_error()

@type response_format_error() ::
  {:invalid_response_format, term()} | {:missing_response_format_type, map()}

tool_tag()

@type tool_tag() :: String.t()

toolbox_error()

@type toolbox_error() ::
  {:unknown_tool_tag, tool_tag()} | {:missing_basic_tool_tag, [tool_tag()]}

Functions

allowed_model_presets()

@spec allowed_model_presets() :: [String.t()]

Return the list of allowed model presets.

This list is intended for interactive selection.

allowed_toolboxes()

@spec allowed_toolboxes() :: [tool_tag()]

Return the list of allowed toolboxes.

Toolboxes are the skill's tool tags; they select tool groups.

model_from_string(model)

@spec model_from_string(String.t()) :: {:ok, AI.Model.t()} | {:error, model_error()}

Resolve a model preset string (from skill TOML) into an AI.Model struct.

Supported values:

  • smart
  • balanced
  • fast
  • web
  • large_context
  • large_context:<speed> where speed is smart|balanced|fast

The plain large_context form preserves the default behavior by calling AI.Model.large_context/0.

reasoning_preamble()

@spec reasoning_preamble() :: String.t()

Returns the reasoning preamble that is prepended to every skill's system prompt.

This establishes baseline reasoning discipline for all skill agents.

toolbox_from_tags(tags)

@spec toolbox_from_tags([tool_tag()]) ::
  {:ok, AI.Tools.toolbox()} | {:error, toolbox_error()}

Build a toolbox from skill tool tags.

Tags are mapped to AI.Tools.with_* groupers. Toolbox construction is deterministic and ignores input order.

The basic tag is required; it acts as the toolbox entrypoint.

validate_response_format(map)

@spec validate_response_format(nil | map()) ::
  {:ok, nil | map()} | {:error, response_format_error()}

Validate a response_format value from a skill.

nil is allowed and means default text responses.

When present, the response format must be a map and should include a type key.