Fix/memory events endpoint #46
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix Rate Limiting & Align Development/Production Parity
Summary
This PR fixes critical issues with the rate limiting feature and ensures functional parity between the development entry point (
main.py) and production entry point (attach/gateway.py).Issues Fixed
Rate Limiting Not Working
TokenQuotaMiddlewarewas looking for user info inrequest.headers.get("x-attach-user")but this header is only set in the response by session middlewarerequest.state.sub(set by auth middleware) for user identificationMAX_TOKENS_PER_MINnow properly enforces token quotas with 429 responsesDevelopment vs Production Inconsistencies
main.pyandattach/gateway.pyhad different middleware configurations, route setups, and behaviorTokenQuotaMiddlewareloadinglogs_router,/a2aprefix,/auth/config)["timestamp", "event", "user", "state"])Code Quality & Production Readiness
main.pyto look professionalmem_writefunction was imported but never usedapp.add_middleware()consistentlyTesting
📋 Environment Variables
Updated documentation for OpenMeter integration:
Impact
uvicorn main:appandattach-gatewaybehave identicallyBreaking Changes
None - this is purely a bug fix and alignment update.