Skip to content

fix(compat): add usage retention pruning and Anthropic error responses#127

Closed
mojomast wants to merge 1 commit intofollowup/pr126-usage-correctnessfrom
followup/pr127-compat-retention
Closed

fix(compat): add usage retention pruning and Anthropic error responses#127
mojomast wants to merge 1 commit intofollowup/pr126-usage-correctnessfrom
followup/pr127-compat-retention

Conversation

@mojomast
Copy link
Collaborator

@mojomast mojomast commented Feb 14, 2026

Summary

  • add simple usage retention controls via USAGE_RETENTION_DAYS with startup pruning and admin-triggered prune endpoint (POST /api/admin/usage/prune)
  • return Anthropic-style JSON error payloads directly from /v1/messages and /v1/messages/count_tokens without FastAPI detail wrapping
  • document retention and admin-only quota visibility in README and .env.example
  • add tests for Anthropic error response shape, retention pruning, and admin actor guard regression

Verification

  • PYTHONPATH=src .venv/bin/python -m py_compile src/proxy_app/usage_recorder.py src/proxy_app/anthropic_errors.py src/proxy_app/routers/admin_api.py src/proxy_app/main.py tests/test_api_compat.py tests/test_usage_retention.py tests/test_auth.py
  • PYTHONPATH=src .venv/bin/pytest -q tests/test_api_compat.py tests/test_usage_retention.py tests/test_auth.py
  • PYTHONPATH=src .venv/bin/pytest -q

Important

Adds usage retention controls and Anthropic-style error responses, with tests and documentation updates.

  • Behavior:
    • Adds USAGE_RETENTION_DAYS for usage event retention, with startup pruning and POST /api/admin/usage/prune for manual pruning.
    • Updates /v1/messages and /v1/messages/count_tokens to return Anthropic-style JSON error payloads without FastAPI detail wrapping.
  • Documentation:
    • Documents usage retention and admin-only quota visibility in README.md and .env.example.
  • Testing:
    • Adds tests for Anthropic error response shape, retention pruning, and admin actor guard regression.

This description was created by Ellipsis for 68d0163. You can customize this summary. It will automatically update as commits are pushed.

@mojomast mojomast requested a review from Mirrowel as a code owner February 14, 2026 03:24
@mojomast
Copy link
Collaborator Author

Superseded by updates pushed to #123 to keep all MVP changes in one review thread.

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.

1 participant