services/loop/orchestrator

Conversation loop — the core orchestrator. Moved from core/loop/orchestrator.gleam (Stage 3). Uses service bundles instead of the monolithic LoopContext.

Types

pub type LoopResult {
  Success(reply: String, history: List(message.Message))
  ToolLoopLimit(reply: String, history: List(message.Message))
  AwaitingApproval(
    reply: String,
    history: List(message.Message),
    approval_cache: List(
      #(String, String, guardrails.ApprovalScope),
    ),
  )
  Failed(message: String)
}

Constructors

Values

pub fn loop(
  env: types.LoopEnv,
  history: List(message.Message),
  round: Int,
  guardrail_state: hooks.LoopState,
  cooldown_state: hooks.CooldownState,
  approval_cache: List(
    #(String, String, guardrails.ApprovalScope),
  ),
  logger: types.LoggerBundle,
  guardrails: types.GuardrailService,
  compression: types.CompressionService,
  context: types.ContextService,
  tokens: types.TokenService,
  llm: types.LLMService,
  all_tools: List(tool.Tool),
  conn: sqlight.Connection,
  user_key: String,
  session_id: String,
  approval_handler: fn(tool.ApprovalRequest) -> tool.ApprovalResponse,
) -> LoopResult
Search Document