Skip to main content

Overview

The analytics.getFailures endpoint provides detailed information about failed AI invocations, including workflow errors, tool call failures, and execution telemetry. This is essential for debugging AI behavior, identifying reliability issues, and improving model performance.

Endpoint

Input Parameters

number
default:50
Maximum number of failure entries to return (1-100)
enum
default:"all"
Filter failures by AI variant:
  • all - All variants
  • Apex - Apex variant only
  • Trendsurfer - Trendsurfer variant only
  • Contrarian - Contrarian variant only
  • Sovereign - Sovereign variant only

Response Schema

array
Array of failure entries with detailed debugging information.
array
Aggregated failure statistics for each model.

Failure Detection Logic

The system detects failures using multiple signals:

Workflow Failures

Detected when the AI response contains error indicators:
Common workflow failures:
  • AI model timeouts
  • Rate limiting errors
  • Invalid AI responses
  • Prompt validation failures
  • System exceptions

Tool Call Failures

Detected when tool call metadata indicates failure:
Common tool call failures:
  • API endpoint errors (exchange, data provider)
  • Validation failures (invalid parameters)
  • Insufficient balance
  • Order rejection
  • Network timeouts

Excluded from Failures

The following are not counted as failures:
  • Pending invocations (“No response yet”, “Pending”, empty responses)
  • Intentional skips (“No trade opportunity detected”)
  • Valid “pass” decisions

Step Telemetry Debugging

Step telemetry provides detailed execution traces for debugging:
Use cases:
  • Token usage analysis: Identify expensive prompts or long completions
  • Execution flow: See which tools were called and in what order
  • Performance profiling: Measure time between steps
  • Failure point identification: Find the exact step where execution failed

Usage Examples

Display Recent Failures

Model Failure Statistics Dashboard

Step Telemetry Viewer

Variant-Specific Failure Analysis

Source Code Reference

Implementation details:
  • Router: src/server/orpc/router/analytics.ts:228-241
  • Failure detection: src/server/features/analytics/queries.server.ts:383-442
  • Recent failures query: src/server/features/analytics/queries.server.ts:548-660
  • Failure stats query: src/server/features/analytics/queries.server.ts:447-543
  • Step telemetry normalization: src/server/features/analytics/queries.server.ts:70-108