fix(umans): normalize API base and show quota without proxy requests - #64
Conversation
- Strip trailing /v1 from UMANS_API_BASE before /v1/usage (fixes 404 when env matches docs: https://api.code.umans.ai/v1) - Resolve env://umans/N to UMANS_API_KEY_N for quota Bearer auth - Include providers in quota-stats when baselines exist but total_requests is 0 - Tests for URL normalization and env key resolution Follow-up to merged #62.
| for cred in (stats.get("credentials") or {}).values(): | ||
| for group in (cred.get("group_usage") or {}).values(): | ||
| for win in (group.get("windows") or {}).values(): | ||
| if win.get("limit") is not None: |
There was a problem hiding this comment.
SUGGESTION: Inconsistent threshold vs. the provider-level branch above.
Line 21 checks (win.get("total_max") or 0) > 0, but line 26 checks win.get("limit") is not None. A credential window with limit == 0 (typically meaning "no quota" or "untracked") would still pass and cause the provider to be included in the Web UI quota view with no displayable bar.
Consider using the same > 0 semantics for consistency:
| if win.get("limit") is not None: | |
| if (win.get("limit") or 0) > 0: |
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| return key | ||
| return credential_path | ||
| key = os.getenv(f"UMANS_API_KEY_{idx}", "").strip() | ||
| return key or credential_path |
There was a problem hiding this comment.
SUGGESTION: Silent fallback to the raw credential_path will produce a confusing 401 Unauthorized from the Umans API when the corresponding UMANS_API_KEY_<idx> env var is unset.
A lib_logger.warning(...) here would surface the misconfiguration directly in logs ("Umans env://umans/N has no UMANS_API_KEY_N set") instead of forcing users to debug an opaque 401 in _fetch_usage_for_credential's except branch.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
The bug fix is well-scoped and correct: Two minor suggestions only: Issue Details (click to expand)SUGGESTION
Files Reviewed (5 files)
Fix these issues in Kilo Cloud Reviewed by minimax-m3 · Input: 83.5K · Output: 20.2K · Cached: 285.4K |
Summary
Follow-up to merged #62. Fixes Umans quota not appearing in the Web UI after deploy.
Root causes
UMANS_API_BASEis set per Umans docs (https://api.code.umans.ai/v1), the tracker appended/v1/usage→…/v1/v1/usage(404). Chat may still work via LiteLLM using the same env var.get_quota_statsdropped providers withtotal_requests == 0, so Umans had no row/bars until proxy traffic existed, even when/v1/usagebaselines were stored.Changes
umans_quota_tracker.py:_normalize_umans_api_base(),_resolve_umans_api_key()forenv://umans/Numans_provider.py: same base normalization for/v1/modelsquota.py:_stats_has_quota_data()— include providers with quota windows but zero requeststest_umans_quota_tracker.py: regression tests + stable ISO parse assertionTest plan
uv run pytest tests/test_umans_quota_tracker.py -q(36 passed)uv run ruff checkon touched modulesUmans quota fetched(not 404)5h-requests(code_pro)Related
UMANS_API_BASEmay be unset,https://api.code.umans.ai, orhttps://api.code.umans.ai/v1after this fix