core/loop
Conversation loop — the core orchestrator.
Types
pub type LoopResult {
Success(reply: String, history: List(completions.Message))
ToolLoopLimit(
reply: String,
history: List(completions.Message),
)
Failed(message: String)
}
Constructors
-
Success(reply: String, history: List(completions.Message)) -
ToolLoopLimit(reply: String, history: List(completions.Message)) -
Failed(message: String)
Values
pub fn client_error_to_string(
err: completions.ClientError,
) -> String
pub fn execute_tools(
history: List(completions.Message),
calls: List(completions.ToolCall),
all_tools: List(tool.Tool),
) -> List(completions.Message)
pub fn run(
client: completions.Client,
persona: String,
history: List(completions.Message),
user_message: String,
tool_defs: List(completions.ToolDefinition),
max_rounds: Int,
conn: sqlight.Connection,
user_key: String,
) -> LoopResult
Run the conversation loop with the default tool registry.
pub fn run_with(
client: completions.Client,
persona: String,
history: List(completions.Message),
user_message: String,
tool_defs: List(completions.ToolDefinition),
max_rounds: Int,
all_tools: List(tool.Tool),
conn: sqlight.Connection,
user_key: String,
) -> LoopResult
Run the conversation loop with a custom tool list (e.g. approval-enabled bash).
pub fn run_with_chat_fn(
chat_fn: fn(
completions.Client,
List(completions.Message),
List(completions.ToolDefinition),
) -> Result(completions.ChatResponse, completions.ClientError),
client: completions.Client,
persona: String,
history: List(completions.Message),
user_message: String,
tool_defs: List(completions.ToolDefinition),
max_rounds: Int,
all_tools: List(tool.Tool),
conn: sqlight.Connection,
user_key: String,
) -> LoopResult
Run the conversation loop with a custom chat function (for testing).
pub fn tool_names_string(all_tools: List(tool.Tool)) -> String
pub fn validate_tool_calls(
calls: List(completions.ToolCall),
all_tools: List(tool.Tool),
) -> List(#(completions.ToolCall, Result(Nil, String)))