SkillKit.Tool behaviour (SkillKit v0.1.0)

Copy Markdown View Source

Describes a tool the LLM can call and defines the callback contract for tool implementations.

Struct

The %Tool{} struct describes a tool for the LLM's tool-use schema:

%SkillKit.Tool{name: "bash", description: "Execute a shell command", input_schema: %{...}}

Behaviour

Tool implementations must implement three callbacks:

  • execute/1 — run the tool, receiving a %SkillKit.ToolExecution{}
  • resume/3 — resume after suspension
  • definition/0 — return a %SkillKit.Tool{} describing the tool

Three-value return

  • {:ok, result} — execution complete
  • {:error, reason} — execution failed
  • {:pending, state} — needs input; caller provides it via SkillKit.respond/3

Summary

Types

t()

@type t() :: %SkillKit.Tool{
  description: String.t(),
  input_schema: map(),
  name: String.t()
}

Callbacks

definition()

@callback definition() :: t()

execute(execution)

@callback execute(execution :: SkillKit.ToolExecution.t()) ::
  {:ok, any()} | {:error, any()} | {:pending, any()}

resume(execution, state, decision)

@callback resume(
  execution :: SkillKit.ToolExecution.t(),
  state :: any(),
  decision :: any()
) :: {:ok, any()} | {:error, any()} | {:pending, any()}