Skip to content

fix(umans): normalize API base and show quota without proxy requests - #64

Merged
b3nw merged 1 commit into
devfrom
fix/umans-quota-webui
Jun 23, 2026
Merged

fix(umans): normalize API base and show quota without proxy requests#64
b3nw merged 1 commit into
devfrom
fix/umans-quota-webui

Conversation

@claw-io

@claw-io claw-io commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to merged #62. Fixes Umans quota not appearing in the Web UI after deploy.

Root causes

  1. HTTP 404 on quota fetch — When UMANS_API_BASE is 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.
  2. Provider hidden in APIget_quota_stats dropped providers with total_requests == 0, so Umans had no row/bars until proxy traffic existed, even when /v1/usage baselines were stored.

Changes

  • umans_quota_tracker.py: _normalize_umans_api_base(), _resolve_umans_api_key() for env://umans/N
  • umans_provider.py: same base normalization for /v1/models
  • quota.py: _stats_has_quota_data() — include providers with quota windows but zero requests
  • test_umans_quota_tracker.py: regression tests + stable ISO parse assertion

Test plan

  • uv run pytest tests/test_umans_quota_tracker.py -q (36 passed)
  • uv run ruff check on touched modules
  • Redeploy → logs show Umans quota fetched (not 404)
  • Web UI Quota → Force Refresh shows Umans 5h-requests (code_pro)

Related

- 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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kilo-code-bot

kilo-code-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 2

The bug fix is well-scoped and correct: _normalize_umans_api_base strips a trailing /v1 so UMANS_API_BASE=https://api.code.umans.ai/v1 no longer triggers /v1/v1/usage, and _resolve_umans_api_key correctly maps env://umans/N to the corresponding UMANS_API_KEY_N env var. The hardcoded ISO timestamp regression test (1782106903.0 for 2026-06-22T05:41:43Z) is accurate. The quota.py filter change intentionally broadens the visibility rules cross-provider to support Umans's API-only quota baselines, which is appropriate given the documented intent.

Two minor suggestions only:

Issue Details (click to expand)

SUGGESTION

File Line Issue
src/rotator_library/client/quota.py 26 Credential-window check uses limit is not None while provider-window check uses total_max > 0 — inconsistent semantics could include providers with limit == 0.
src/rotator_library/providers/utilities/umans_quota_tracker.py 126 Silent fallback to raw credential_path when UMANS_API_KEY_N is unset produces a confusing 401 instead of a diagnostic warning log.
Files Reviewed (5 files)
  • .fork/features/umans.md - 0 issues
  • src/rotator_library/client/quota.py - 1 issue
  • src/rotator_library/providers/umans_provider.py - 0 issues
  • src/rotator_library/providers/utilities/umans_quota_tracker.py - 1 issue
  • tests/test_umans_quota_tracker.py - 0 issues

Fix these issues in Kilo Cloud


Reviewed by minimax-m3 · Input: 83.5K · Output: 20.2K · Cached: 285.4K

@b3nw
b3nw merged commit 955c194 into dev Jun 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants