Overview
Theanalytics.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
Maximum number of failure entries to return (1-100)
Filter failures by AI variant:
all- All variantsApex- Apex variant onlyTrendsurfer- Trendsurfer variant onlyContrarian- Contrarian variant onlySovereign- Sovereign variant only
Response Schema
Array of failure entries with detailed debugging information.
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:- AI model timeouts
- Rate limiting errors
- Invalid AI responses
- Prompt validation failures
- System exceptions
Tool Call Failures
Detected when tool call metadata indicates failure:- 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:- 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
Related Endpoints
- Get Model Stats - Includes failure rate metrics
- Get Invocations - View all invocations, not just failures
- Get Leaderboard - Performance rankings

