Skip to main content

execute_actions

Function execute_actions 

Source
pub async fn execute_actions(
    actions: Vec<Value>,
    state: &AppState,
    protocol: Option<&dyn Server>,
    server_id: Option<ServerId>,
    client_id: Option<ClientId>,
) -> Result<ExecutionResult>
Expand description

Execute an array of actions from LLM response

§Arguments

  • actions - Array of action JSON objects from LLM
  • state - Application state
  • protocol - Optional protocol for protocol-specific actions
  • server_id - Optional server ID for context (used for feedback, memory, etc.)
  • client_id - Optional client ID for context (used for client feedback)

§Failure handling

A failing action does not abort the batch. Each failure is logged at error! and recorded in ExecutionResult::failures, and execution continues with the next action. Aborting would suppress the valid actions that follow a bad one — dropping the close_this_connection that was meant to terminate a request whose body already went out, for example — and would convert a single malformed action into a lost connection in protocols that today recover by falling back to their default response. The defect this addresses is that failures were invisible, not that they were tolerated, so they are now surfaced (access log, error!) rather than made fatal.

§Returns

  • Ok(ExecutionResult) - Results of execution; check failures for per-action errors
  • Err(_) - If execution failed critically