Skip to main content

run_tool_loop

Function run_tool_loop 

Source
pub fn run_tool_loop(
    account_id: &str,
    token: &SecretString,
    base_url: &str,
    model_id: &str,
    timeout: Duration,
) -> Result<ToolLoopOutcome, CloudflareError>
Expand description

Run the LIVE multi-turn tool-loop conformance suite for one model.

Gated: refuses with CloudflareError::MissingEnv naming LIVE_TESTS_ENV unless live_tests_enabled is true, so this can never fire a paid call by accident. The loop POSTs OpenAI-format chat completions to {base_url}/chat/completions (Bearer auth via auth_header), executes the model’s tool calls in memory, appends role: tool results with matching tool_call_id, and continues until a final answer (no tool calls), a violation, or the turn budget is spent. On violation the run stops immediately with the specific FailureClass.