Sycophant.Agent.Callbacks (sycophant v0.4.2)

Copy Markdown

Callback function types for agent lifecycle hooks.

All callbacks are optional. When nil, the agent uses default behavior.

Summary

Functions

Creates a new Callbacks struct from keyword options.

Types

on_error()

@type on_error() :: (Splode.Error.t(), Sycophant.Context.t() ->
                 :retry
                 | {:retry, pos_integer()}
                 | {:continue,
                    String.t() | Sycophant.Message.t() | [Sycophant.Message.t()]}
                 | {:stop, term()})

on_max_steps()

@type on_max_steps() :: (non_neg_integer(), Sycophant.Context.t() ->
                     :continue | :stop)

on_response()

@type on_response() :: (Sycophant.Response.t() -> :ok)

on_tool_call()

@type on_tool_call() :: (Sycophant.ToolCall.t() ->
                     :approve | :reject | {:modify, Sycophant.ToolCall.t()})

t()

@type t() :: %Sycophant.Agent.Callbacks{
  on_error: on_error() | nil,
  on_max_steps: on_max_steps() | nil,
  on_response: on_response() | nil,
  on_tool_call: on_tool_call() | nil
}

Functions

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new Callbacks struct from keyword options.