Sycophant.ToolExecutor (sycophant v0.4.2)

Copy Markdown

Automatic tool execution loop.

When a response contains tool calls and the corresponding Tool structs have a :function set, this module executes them, builds tool_result messages, and re-submits to the LLM until it produces a final text response or :max_steps is reached (default: 10).

Tools without a :function are skipped -- their tool calls appear in response.tool_calls for manual handling by the caller.

Summary

Functions

Runs the tool auto-execution loop until no more tool calls remain or max_steps is reached.

Functions

run(response, tools, opts, call_fn)

@spec run(Sycophant.Response.t(), [Sycophant.Tool.t()], keyword(), (list() ->
                                                                {:ok,
                                                                 Sycophant.Response.t()}
                                                                | {:error,
                                                                   term()})) ::
  {:ok, Sycophant.Response.t()} | {:error, term()}

Runs the tool auto-execution loop until no more tool calls remain or max_steps is reached.