Repository navigation
Conversation
|
@veria-ai Please review the current branch for authorization boundaries, memory isolation, protocol compatibility, accounting, and deployment correctness. |
|
bugbot run Please review the current branch, especially memory policy enforcement, request recursion, tenant isolation, and client tool continuation. |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
@greptileai Please review the updated branch, including the Render build fixes, memory authorization, protocol handling, and request accounting. |
Greptile SummaryThis PR introduces gateway-managed persistent memory, including policy-based activation and namespace isolation, protocol-aware preparation for three inference APIs, management endpoints and dashboard controls, database persistence, request accounting coordination, and an isolated forwarding pilot. Since the previous review, it additionally enforces an atomic 1,000-entry limit per memory namespace using a transaction-scoped advisory lock.
Confidence Score: 5/5The updated PR appears safe to merge; no new actionable failure was found and no previous blocking finding remains outstanding. The new quota path serializes count-and-create operations per stable namespace, uses established Prisma transaction APIs, and leaves correction and deletion outside the creation cap. moe-berri accepted the documented feature-specific critical-path database tradeoff because bounded memory operations require fresh primary data; that resolved finding does not remain outstanding. The FastAPI dependency and lowercase-bearer threads were manually resolved without explanation.
|
| Filename | Overview |
|---|---|
| litellm/proxy/memory/store.py | Adds an atomic, namespace-scoped entry quota while preserving revision-based corrections and authorization revalidation. |
| tests/test_litellm/proxy/memory/test_memory_v2_boundaries.py | Covers full-scope rejection and verifies that corrections, deletion, and subsequent creation remain available. |
| tests/test_litellm/proxy/memory/test_memory_v2_management.py | Updates management-test database fixtures for transaction, count, and advisory-lock behavior. |
| deploy/memory-pilot/README.md | Documents the atomic 1,000-entry limit and recovery through deletion. |
| litellm/proxy/memory/gateway.py | Performs bounded protocol-aware memory preparation with per-operation authorization revalidation and final access checking. |
| deploy/memory-pilot/pilot.py | Validates preserved upstream credentials while delegating inference to the standard gateway application. |
Reviews (7): Last reviewed commit: "fix(memory): enforce an atomic namespace..." | Re-trigger Greptile
|
@greptileai Please review the updated branch, including the Render build fixes, memory authorization, protocol handling, and request accounting. |
|
@veria-ai Please review the current branch for authorization boundaries, memory isolation, protocol compatibility, accounting, and deployment correctness. |
|
bugbot run Please review the current branch, especially memory policy enforcement, request recursion, tenant isolation, and client tool continuation. |
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 2 · PR risk: 0/10 |
|
@greptileai Please review the updated branch, including the Render build fixes, memory authorization, protocol handling, and request accounting. |
|
@veria-ai Please review the current branch for authorization boundaries, memory isolation, protocol compatibility, accounting, and deployment correctness. |
|
bugbot run Please review the current branch, especially memory policy enforcement, request recursion, tenant isolation, and client tool continuation. |
|
@greptileai Please review the updated branch, including the Render build fixes, memory authorization, protocol handling, and request accounting. |
|
@veria-ai Please review the current branch for authorization boundaries, memory isolation, protocol compatibility, accounting, and deployment correctness. |
|
bugbot run Please review the current branch, especially memory policy enforcement, request recursion, tenant isolation, and client tool continuation. |
|
@greptileai Please review the updated branch, including the Render build fixes, memory authorization, protocol handling, and request accounting. |
|
@veria-ai Please review the current branch for authorization boundaries, memory isolation, protocol compatibility, accounting, and deployment correctness. |
|
bugbot run Please review the current branch, especially memory policy enforcement, request recursion, tenant isolation, and client tool continuation. |
|
@greptileai Please review the updated branch, including the Render build fixes, memory authorization, protocol handling, and request accounting. |
|
@veria-ai Please review the current branch for authorization boundaries, memory isolation, protocol compatibility, accounting, and deployment correctness. |
|
bugbot run Please review the current branch, especially memory policy enforcement, request recursion, tenant isolation, and client tool continuation. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit ecf23d7. Configure here.
|
Closing because this implementation confines memory tools to preparation. The replacement will expose them to the active model throughout gateway-managed tool execution. |
TLDR
Problem this solves:
How it solves it:
User Flow
Before: a developer loses their saved project preference in a fresh conversation.
POST http://localhost:4019/v1/chat/completionswith “Remember my demo project's staging port is 8753.”unknown.http://localhost:4019/ui/memoryand see a deprecation banner and manual memory administration.After: the developer's enabled gateway remembers the preference across conversations.
POST http://localhost:4018/v1/chat/completionswith “Remember my demo project's staging port is 8753.” An administrator has enabled automatic, private-per-key memory athttp://localhost:4018/ui/memory.8753using the same gateway key.http://localhost:4018/ui/memoryto inspect, correct, or delete their memories. Administrators can choose automatic, opt-in, or disabled policies for existing gateway, organization, team, project, user, and key targets.The Render forwarding pilot preserves each caller's original upstream key and model. Colleagues change only the base URL. Its memories are private per key; full organization sharing requires installing this feature in the gateway that owns those identities.
Relevant issues
Linear ticket
Pre-Submission checklist
Screenshots / Proof of Fix
Real provider:
vertex_ai/claude-sonnet-5through the existing upstream gateway. Before uses a clean merge-base checkout on port 4019 with thememory-testalias; After uses this branch's forwarding pilot on port 4018 with the original model name and caller key. Each case uses a fresh random project name and two independent conversations. Keys are supplied through a private curl configuration, never embedded in the evidence.Shared command shape, with
$BODYcontaining the endpoint-native JSON:Chat/Messages bodies use
messages: [{role: "user", content: PROMPT}]andmax_tokens: 250. Responses usesinput: PROMPT,max_output_tokens: 250, andstore: false. Seed usesstream: false; fresh recall usesstream: true. Seed asks to remember the project's staging port, 8753. Recall asks for that project's port without repeating it.Before (9071ca5)
Chat Completions
/v1/chat/completions: HTTP 200, acknowledges the port for this conversation.Responses
/v1/responses: HTTP 200, acknowledges the port for this conversation.Anthropic Messages
/v1/messages: HTTP 200, acknowledges the port for this conversation.Memory dashboard
/ui/loginform and open/ui/memory.After (ecf23d7)
Chat Completions
/v1/chat/completions: HTTP 200, confirms saving the project port.8753; no gateway memory tool events appear in the stream.Responses
/v1/responses: HTTP 200, confirms saving the project port.8753; no gateway memory tool events appear in the stream.Anthropic Messages
/v1/messages: HTTP 200, acknowledges the project port.8753; no gateway memory tool events appear in the stream.Memory dashboard
/ui/loginform and open/ui/memory.Additional verification: 12 real-provider E2E cases passed against both the monolithic gateway and separate gateway/backend processes. The same 12 cases also passed with
gpt-5.5andclaude-haiku-4-5, matching CI's model selection, with tracing enabled and a Redis cluster. 95 focused Python tests, 219 capability tests, 3 dashboard integration tests, and 41 navigation tests passed.make check, the dashboard production build, and fresh Postgres migrations passed. A real PostgreSQL concurrency test seeded 999 entries and raced five creates: exactly one succeeded, four returned 429, and storage remained at 1000 entries. Correction at capacity and deletion followed by a new save both passed. Real Claude Code saved a preference, recalled8629in a new process, and used its normal Read tool while recalling the same preference.The Render pilot is deployed at https://litellm-memory-pilot.onrender.com. The deployed revision is
ecf23d761d. It passed all three real-provider streamed recall checks and the hosted dashboard login, search, correction, and deletion flow. Real Claude Code also passed on this revision: independent processes saved and recalled port8629, and its normal Read tool remained usable while recalling that preference. It has automatic key-private memory enabled. No upstream provider credential is stored in its configuration.Final revision validation: all 33 branch-required checks passed. The stage-mirror changed-test gate passed 40 tests three consecutive times (231.45s, 227.38s, 225.46s). Greptile scored the current commit 5/5, Bugbot found no new issues, and Veria reported both findings addressed with no open security issues. No review threads remain unresolved. The separate, non-required Buildkite check is still pending. Human approvals, including the migration reviewer requirement, remain necessary before merge.
Type
New Feature
Caveats (if any)
Severe
Medium
Memory repository operations intentionally run in the request path. Existing authentication supplies identity; fresh primary policy checks prevent revocation during preparation from permitting later saves. The existing identity helpers do not store or retrieve memory records.
Without shared Redis, first-time activation can take up to 30 seconds to reach another worker.
Models must support function calling; preparation has a 60-second deadline.
Long conversations repeat prompt tokens during bounded preparation.
Pilot namespaces follow keys; shared keys share memories.
Upstream organization policies require deployment within the authoritative gateway.
Keyword search only; no embeddings or nightly consolidation.
Each memory namespace holds up to 1000 entries; corrections remain available at capacity.
Forwarding pilot supports three inference protocols and memory management.
QA runbook
Prerequisites: a live Postgres-backed gateway, administrator key, and a real tool-capable model configured as
CHEAP_OPENAI_MODELandCHEAP_ANTHROPIC_MODEL. Create two users, one team, two keys for the first user and a separate key for the second user. Limit each key to one concurrent request. Remove created entries, policies, preferences, keys, team, and users after checking.tests/e2e/management/test_memory_v2_e2e.py::TestMemoryV2::test_gateway_stores_and_recalls_without_client_memory_toolsproves capture and fresh recall across six protocol/stream combinations./v2/memory/policiesas admin with{"target_type":"team","target_id":"TEAM","activation":"automatic","scope":"key"}./v1/chat/completionsas the owner, asking to remember a unique project codename. GET/v2/memory/entriesand find the exact word./v1/chat/completions,/v1/responses,/v1/messages, with streaming both false and true; expect HTTP 200 and that word. Streaming must emit multiple chunks without memory tool events.tests/e2e/management/test_memory_v2_e2e.py::TestMemoryV2::test_admin_selects_opt_in_or_automatic_and_key_override_winsproves activation precedence./v2/memory/statusreports inactive. A remember request creates no entry./v2/memory/preferenceas owner with{"enabled":true}; both that user's team keys become active, unrelated key stays inactive.tests/e2e/management/test_memory_v2_e2e.py::TestMemoryV2::test_private_entries_are_isolated_even_for_sibling_keys_and_legacy_apiproves tenant isolation./v2/memory/entriesas owner with key, title, content, and evidence; record its ID.key_id=OWNER_HASH: denied./v1/memoryas sibling: either denied or excludes the private entry. Owner's content remains unchanged.tests/e2e/management/test_memory_v2_e2e.py::TestMemoryV2::test_members_cannot_enable_or_broaden_memoryproves admin-only policy writes.tests/e2e/management/test_memory_v2_e2e.py::TestMemoryV2::test_corrections_require_current_revision_and_deleted_memory_is_not_recalledproves correction safety and deletion.updated_atasexpected_revision; expect the same ID and corrected content.tests/e2e/management/test_memory_v2_e2e.py::TestMemoryV2::test_client_tool_call_and_continuation_remain_owned_by_clientproves client tool compatibility.verify_release, requiredword, andtool_choice: "required".verify_releasecall containing the saved word and a tool call ID.tests/e2e/management/test_memory_v2_e2e.py::TestMemoryV2::test_preparation_and_answer_are_charged_once_to_the_calling_keyproves accounting./spend/logsfor that key: expect 2–4 records with distinct request IDs, correct key hash, user, team, positive spend, and nonzero prompt/completion tokens.Final Attestation
Note
Medium Risk
Hooks the main inference pre-call path with extra billed LLM rounds and new authorization/namespace rules; failures or misconfiguration can affect latency, spend, and recall isolation for enabled keys.
Overview
Introduces gateway Memory V2: administrators can enable automatic or opt-in persistent memory for Chat Completions, Responses, and Anthropic Messages without client-side memory tools. Policies target gateway/org/team/project/user/key with configurable sharing scope; users can opt in when required.
Inference path: Before the visible model call,
prepare_gateway_memorymay run bounded server-side tool rounds (search/read/capture) via in-process ASGI dispatch, then injects retrieved facts as untrusted reference context while leaving the client’s original tools and streaming settings intact. Storage: Postgres gainsnamespaceon memory rows plusLiteLLM_MemoryPolicy/LiteLLM_MemoryPreference; entries are isolated by namespace with keyword search and revision-checked updates. API/UI: New/v2/memory/*routes (policies backend-only; status/preference/entries on gateway too) and dashboard sections for policies, preference, and per-key saved memories; legacy/v1/memoryreads exclude namespaced rows.Ops: Parallel-request limiter v3 defers the next internal prep round until the prior call releases its slot.
deploy/memory-pilotadds a Render forwarding gateway that validates upstream keys, maps them to local virtual keys, and proxies inference for an isolated pilot.Reviewed by Cursor Bugbot for commit 142088d. Bugbot is set up for automated code reviews on this repo. Configure here.