services/tool/executor

Tool execution — validation, grouping, sequential/parallel execution. Lives in services/ because it wires the approval service cache. Moved from services/tool/executor.gleam in Stage 2B.

Types

pub type ToolGroup {
  Sequential(calls: List(#(message.ToolCall, tool.Tool)))
  Parallel(calls: List(#(message.ToolCall, tool.Tool)))
}

Constructors

Values

pub fn execute_tools(
  history: List(message.Message),
  calls: List(message.ToolCall),
  all_tools: List(tool.Tool),
  approval_handler: fn(tool.ApprovalRequest) -> tool.ApprovalResponse,
  approval_cache: List(
    #(String, String, guardrails.ApprovalScope),
  ),
  session_id: String,
) -> #(
  List(message.Message),
  Bool,
  List(#(String, String, guardrails.ApprovalScope)),
)
pub fn extract_tool_results(
  history: List(message.Message),
  count: Int,
) -> List(String)

Extract the last N tool result contents from history for guardrails.

pub fn tool_names_string(all_tools: List(tool.Tool)) -> String
pub fn validate_tool_calls(
  calls: List(message.ToolCall),
  all_tools: List(tool.Tool),
) -> List(#(message.ToolCall, Result(Nil, String)))
Search Document