Operations
Telemetry
An assistant that behaves oddly is not debuggable from logs. ai_request_telemetry records the
decisions a turn made, so "why did it not use my tool?" has an answer.
Where it lives
One row per request in ai_request_telemetry, written best-effort off the request path.
Loss-tolerant by design: analytics must never take a turn down. Indexed on
(organization_id, created_at) and on result_path.
Enabled with AI:Telemetry:Enabled, which defaults to on.
The fields
Identity
| Field | Notes |
|---|---|
request_id | Correlates with ai_usage_record rows for the same turn |
session_id | The conversation thread |
organization_id, location_id | Tenant and scope |
endpoint | Which API surface: chat, chat_stream, insights_ui and the others. starter is a turn the engine ran itself, in the background, to store the answer to one of the start screen's suggested questions |
capability_mode | standard or deep, after clamping |
key_kind | The kind of key the turn was made with: secret, publishable, agent, sandbox and the others on Authentication. null on rows written before 2026-10-22. The operator's onboarding funnel counts a workspace's first publishable turn, a visitor answered on the widget, as first_widget_turn |
Routing — why the turn did what it did
| Field | Notes |
|---|---|
route_kind | The router's decision: Navigation, Troubleshooting, LiveDataAnalysis, MixedGuidance, ActionExecution or GeneralConversation |
route | The path the turn then took: tool_calling, static_context, instant_greeting, handoff and the others; the stream's mostly carry a stream_ prefix. starter_cache and stream_starter_cache are a suggested question answered from its stored answer, with no model call |
intent | The intent classifier's opinion: navigation, analysis or action. It never sees your catalog and decides nothing; the router's decision is route_kind |
matched_alias | path_question_override when a where-do-I-find question named a screen and something your tools cover, else null. No alias detector ships, so no other value appears |
positive_signals, negative_signals | Which rules fired, and which downgraded a route |
routing_confidence | Margin between the top and runner-up route, 0–1 |
used_ambiguity_fallback | Low confidence triggered clarification or a tie-breaker |
used_prior_session_context | Always false: nothing sets it |
deterministic_bypass | Always false: the guide-catalog bypass that once answered navigation questions without a model call is deleted. Turns that make no model call show model: none and their own result_path |
selected_surface, surface_from_header | Client surface, and whether it was explicit |
Tools and grounding
| Field | Notes |
|---|---|
tool_count | Tools actually called |
selected_tool_count, selected_tool_domains | Tools offered to the model, and their domains |
context_sections, context_cache_hit | null on rows written since October 2026: the context step they described read nothing and is deleted |
retrieved_chunk_count, retrieved_chunk_ids | 0 and null: they counted the deleted guide catalog. Knowledge a turn drew on is named on the response's meta.knowledge |
source_types_used | tool when the turn offered at least one of your tools, else null. Rows written before October 2026 may say context for a context step that read nothing, or tool on a tool route that had nothing to offer |
Latency, in milliseconds
scope_ms, history_ms, openai_ms, validation_ms, total_ms. context_ms is 0 on rows
written since October 2026. Since November 2026 the session's history is read while the rest of the
turn is prepared, so history_ms is how long the turn then waited for it, not how long the query
took; 0 means it was ready.
| Field | Notes |
|---|---|
first_token_ms | From the start of the turn to the first text chunk on the stream. On a buffered turn answered from a stored answer, the time it was ready. null on other buffered turns and on rows written before November 2026 |
first_cards_ms | From the start of the turn to the first cards frame on the stream. Always null on a buffered turn, and on a turn that showed no cards |
Outcome
| Field | Notes |
|---|---|
schema_valid | Whether the model's output validated first time |
result_path | ok, fallback, handoff, out_of_scope, budget_exceeded, provider_error, error, canceled. provider_error_fallback appears only on rows written before October 2026, when a failed tool loop on /v1/chat was answered by a second model call |
fallback_mode | How it degraded — including the specific budget cap that tripped |
stop_reason | Why the model stopped, when it was not on its own: max_tool_turns (the last call the tool-turn ceiling allowed had to answer), turn_deadline (the same, once the turn deadline had passed), incomplete:<reason> from the provider (incomplete:max_output_tokens is an output ceiling set too low) or failed. Null otherwise |
model | The model the provider reported. none on a turn that never called a model |
prompt_tokens, completion_tokens, estimated_cost_usd | Summed across the turn's calls, including on an error or canceled row, which carries the calls answered before it ended |
cached_input_tokens | The part of prompt_tokens the provider read from its prompt cache, summed across the turn's calls. 0 on rows written before November 2026 |
answer_cache | starter when the answer was a stored answer to a suggested question: model is none and the cost 0. null otherwise |
The four questions it answers
"Why did it not use my tool?"
SELECT route, intent, selected_tool_count, selected_tool_domains, tool_count,
routing_confidence, negative_signals
FROM ai_request_telemetry
WHERE organization_id = 42 AND created_at >= now() - interval '1 hour'
ORDER BY created_at DESC
LIMIT 20;
selected_tool_count = 0 means nothing was offered: either the router decided the turn did not
need tools, or the route takes tools and none were left to offer (no catalog, a preview sandbox,
an image turn whose tools refuse images, a deep_analysis_only tool on a plan without deep
analysis). Either way, unless it was a navigation question, the model was told no records were
looked up. route tells the two apart:
tool_calling with selected_tool_count = 0 is the second.
selected_tool_count > 0 with tool_count = 0 means the tools were offered and the model chose
not to call them, which is a description problem, not a routing one.
"Why is it slow?"
SELECT date_trunc('hour', created_at) AS hour,
percentile_cont(0.5) WITHIN GROUP (ORDER BY total_ms) AS p50,
percentile_cont(0.95) WITHIN GROUP (ORDER BY total_ms) AS p95,
percentile_cont(0.95) WITHIN GROUP (ORDER BY openai_ms) AS p95_model,
avg(context_ms) AS ctx, avg(history_ms) AS hist
FROM ai_request_telemetry
WHERE created_at >= now() - interval '1 day'
GROUP BY 1 ORDER BY 1;
total_ms far above openai_ms puts the time in context assembly, history, or your tool
endpoint.
"Is the output contract holding?"
SELECT date_trunc('day', created_at) AS day,
count(*) FILTER (WHERE NOT schema_valid)::numeric / count(*) AS invalid_rate,
count(*) FILTER (WHERE fallback_mode IS NOT NULL) AS fallbacks
FROM ai_request_telemetry
WHERE created_at >= now() - interval '14 days'
GROUP BY 1 ORDER BY 1;
A rising invalid_rate after a model change is the earliest signal you get that answers are
degrading, and it arrives before anyone complains.
"What is failing?"
SELECT result_path, fallback_mode, count(*)
FROM ai_request_telemetry
WHERE created_at >= now() - interval '1 day'
GROUP BY 1, 2 ORDER BY 3 DESC;
result_path
| Value | Meaning |
|---|---|
ok | Normal, including turns that never called a model |
fallback | The model answered outside the contract and the answer was repaired or replaced. fallback_mode is schema_repair, fallback_text or navigation_guard |
out_of_scope | Policy refused before any spend |
budget_exceeded | The breaker refused. fallback_mode names the cap |
handoff | The customer asked for a person; no model was called |
provider_error | The provider call failed and the caller got the provider_error document. fallback_mode is provider_error |
provider_error_fallback | On /v1/chat, the tool loop failed, the static retry failed too, and the caller got the provider_error document |
error | The turn failed. fallback_mode is rate_limited (the provider throttled the turn, on either door), plan_quota_exceeded (a free tenant used its daily request quota, on either door), provider_validation, provider_error or similar |
canceled | The client disconnected mid-turn |
Worth alerting on
| Signal | Why |
|---|---|
result_path = 'budget_exceeded' appears at all | A customer is being refused right now |
invalid_rate up week over week | Output quality is drifting |
selected_tool_count = 0 on a rising share of turns | The router is declining to offer tools, or a catalog went missing |
p95(total_ms) up while p95(openai_ms) is flat | Something other than the model got slower |
result_path = 'error' with fallback_mode = 'rate_limited' | You are being throttled upstream |
stop_reason = 'max_tool_turns' on a rising share of turns | Questions need more tool rounds than the plan allows, or the model is looping |
stop_reason LIKE 'incomplete:max_output_tokens' | The output ceiling is cutting answers off, often in reasoning |
What it does not contain
No prompts, and no answers. Telemetry records decisions and measurements, not content.
Conversations live in ai_chat_message; tool results are never persisted at all.
No tool-level detail. There is no per-tool latency or failure breakdown — tool_count and
selected_tool_domains are the granularity. Your own endpoint's logs are the place to see which
tool was slow.