MATIH Platform is in active MVP development. Documentation reflects current implementation status.
14. Context Graph & Ontology
Agent Thinking
Reasoning Analytics

Reasoning Analytics

Reasoning analytics provides insights into agent thinking patterns, model performance, cost optimization, and path frequency analysis. The analytics are powered by aggregations over thinking traces stored in Dgraph and exposed through the analytics API endpoints.


Overview

The analytics subsystem answers operational questions such as:

  • Which LLM models are most cost-effective for different task types?
  • What are the most common agent reasoning paths?
  • Where do agents spend the most time and tokens?
  • Which reasoning patterns lead to successful outcomes?

Analytics Endpoints

EndpointMethodDescription
/api/v1/context-graph/analytics/model-performanceGETPer-model token, cost, and quality statistics
/api/v1/context-graph/analytics/path-analysisGETAgent path frequency and outcome analysis
/api/v1/context-graph/analytics/cost-breakdownGETCost breakdown by model, tenant, or session
/api/v1/context-graph/analytics/latency-distributionGETLatency percentiles per step type

Model Performance Statistics

The model performance endpoint returns per-model metrics:

MetricDescription
total_callsTotal number of calls to this model
total_input_tokensTotal input tokens consumed
total_output_tokensTotal output tokens produced
total_thinking_tokensTotal thinking/reasoning tokens
total_cost_usdTotal estimated cost in USD
avg_latency_msAverage call latency
avg_confidenceAverage confidence score
p50_latency_msMedian latency
p95_latency_ms95th percentile latency
p99_latency_ms99th percentile latency

Path Analysis

Path analysis identifies the most common sequences of agent steps and correlates them with outcomes:

MetricDescription
pathOrdered list of step types taken
countNumber of traces following this path
success_countTraces with successful outcome
failure_countTraces with failed outcome
success_ratePercentage of successful traces
avg_duration_msAverage execution time for this path
avg_cost_usdAverage cost for this path

Cost Breakdown

Cost breakdown can be grouped by different dimensions:

DimensionDescription
by_modelCost per LLM model
by_step_typeCost per thinking step type
by_sessionCost per user session
by_timeCost over time periods

Latency Distribution

Latency metrics are provided as percentile distributions per step type:

{
  "step_type": "SQL_GENERATION",
  "p50_ms": 450,
  "p75_ms": 780,
  "p90_ms": 1200,
  "p95_ms": 1800,
  "p99_ms": 3500,
  "count": 15234
}

RBAC Protection

All analytics endpoints are RBAC-protected. Users need the context_graph:metrics:read permission to access analytics data. The visibility level determines how much detail is returned:

PermissionVisibilityData Shown
context_graph:traces:readSummaryAggregate counts and rates
context_graph:metrics:readStandardPer-model and per-path breakdowns
context_graph:thinking:readDetailedIndividual trace details
context_graph:adminFullRaw data including tokens and costs

Query Parameters

All analytics endpoints accept common query parameters:

ParameterTypeDescription
tenant_idstringRequired. Tenant scope
start_timedatetimeStart of the time window
end_timedatetimeEnd of the time window
model_idstringFilter by specific model
session_idstringFilter by specific session