Summary
ucode usage consistently reports 0 tokens for users who have real, heavy AI Gateway usage. The underlying query against system.ai_gateway.usage filters rows by a hard-coded allowlist of user_agent patterns. GitHub Copilot CLI usage is excluded because:
- copilot isn't in the allowlist
- more fundamentally, Copilot CLI traffic doesn't populate user_agent at all, so it can never match
The result: users see zero usage despite significant token consumption.
Environment
- Tool: ucode CLI (AI Gateway usage stats), GitHub Copilot CLI via Gateway
- Workspace:
- Warehouse:
- Affected user:
Steps to reproduce
- Use GitHub Copilot CLI through the Gateway and generate usage (155k+ tokens, 19 sessions on 2026-05-31).
- Run ucode usage.
- Observe the report:
text ✓ Databricks AI Gateway usage Today: 0 tokens Last 7 days: 0 tokens Last 30 days: 0 tokens GitHub Copilot CLI · Last 7 Days • No usage for GitHub Copilot CLI in the last 7 days.
Expected
ucode usage reports the user's actual token usage, including GitHub Copilot CLI.
Actual
0 tokens across all time windows, even though system.ai_gateway.usage contains the events.
Root cause
The generated query restricts results with a user_agent allowlist in the WHERE clause:
sql AND ( lower(user_agent) LIKE '%codex%' OR lower(user_agent) LIKE '%claude%' OR lower(user_agent) LIKE '%gemini%' OR lower(user_agent) LIKE '%opencode%' )
Two problems:
- copilot is missing from the allowlist.
- Adding %copilot% still returns nothing - Copilot CLI events don't carry a recognizable user_agent, so they're filtered out regardless.
The WHERE filter is also redundant and contradictory with the query's own CASE logic, which already buckets unrecognized agents into 'other'. The filter removes the very rows the 'other' branch is meant to catch.
Evidence
Removing the user_agent filter entirely returns correct, sensible results:
text requester_name tool usage_day total_tokens_used sessions models other 2026-05-31 155942 19 Claude Sonnet 4.6 other 2026-05-29 47726 6 Claude Sonnet 4.6
Proposed fix
Remove the user_agent allowlist from the WHERE clause and rely on the existing CASE statement to classify the tool:
- known agents → their name
- everything else → other
This captures Copilot CLI and any future tool that doesn't emit a matching user_agent.
If filtering is genuinely needed (e.g. to exclude non-CLI Gateway traffic), it should be based on a positive signal that's actually present for these tools, not an allowlist that silently drops valid usage.
Impact / severity
Low-severity paper cut, but it undermines trust in usage reporting - users reasonably conclude usage tracking is broken.
Summary
ucode usage consistently reports 0 tokens for users who have real, heavy AI Gateway usage. The underlying query against system.ai_gateway.usage filters rows by a hard-coded allowlist of user_agent patterns. GitHub Copilot CLI usage is excluded because:
The result: users see zero usage despite significant token consumption.
Environment
Steps to reproduce
text ✓ Databricks AI Gateway usage Today: 0 tokens Last 7 days: 0 tokens Last 30 days: 0 tokens GitHub Copilot CLI · Last 7 Days • No usage for GitHub Copilot CLI in the last 7 days.
Expected
ucode usage reports the user's actual token usage, including GitHub Copilot CLI.
Actual
0 tokens across all time windows, even though system.ai_gateway.usage contains the events.
Root cause
The generated query restricts results with a user_agent allowlist in the WHERE clause:
sql AND ( lower(user_agent) LIKE '%codex%' OR lower(user_agent) LIKE '%claude%' OR lower(user_agent) LIKE '%gemini%' OR lower(user_agent) LIKE '%opencode%' )
Two problems:
The WHERE filter is also redundant and contradictory with the query's own CASE logic, which already buckets unrecognized agents into 'other'. The filter removes the very rows the 'other' branch is meant to catch.
Evidence
Removing the user_agent filter entirely returns correct, sensible results:
text requester_name tool usage_day total_tokens_used sessions models other 2026-05-31 155942 19 Claude Sonnet 4.6 other 2026-05-29 47726 6 Claude Sonnet 4.6
Proposed fix
Remove the user_agent allowlist from the WHERE clause and rely on the existing CASE statement to classify the tool:
This captures Copilot CLI and any future tool that doesn't emit a matching user_agent.
If filtering is genuinely needed (e.g. to exclude non-CLI Gateway traffic), it should be based on a positive signal that's actually present for these tools, not an allowlist that silently drops valid usage.
Impact / severity
Low-severity paper cut, but it undermines trust in usage reporting - users reasonably conclude usage tracking is broken.