Repository navigation
fix(security): bind conversation history to its workspace and bound it - #37
Merged
Merged
Conversation
The shared pod kept every conversation's history in one dict keyed by conversation id alone, never removed. A turn from another workspace naming the same id continued that conversation, and new ids grew the pod's memory without limit. The list was also mutated outside the lock. - New conversations.ConversationStore keyed by customer, checked workspace path, workspace and user ids, and conversation id. - At most 256 conversations (least recently used dropped), an hour of idle time, and 60 messages and 200,000 characters per history after its system prompt, dropping whole exchanges. - A turn works on a copy and saves it back whole under the lock. Refs #35
This was referenced Nov 15, 2026
Contributor
Author
|
Merged into |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What: ExperimentsAgent now keeps each conversation's history under its workspace as well as its conversation id, and limits how many conversations and how much history the pod holds.
Why: The pod serves every workspace and looked history up by conversation id alone, so another workspace that knew the id could read or write into it, and new ids grew memory without limit (#35, G1 of https://github.com/oramasearch/orama-bridge/issues/273).
How: A small bounded store keyed by (customer, workspace, conversation), with least-recently-used eviction, idle expiry and a size cap per history; turns work on a copy saved back under the lock.
Changes
src/agent_experiments/conversations.py(new):ConversationKey(customer id, the checked workspace pathlake_url,workspace_idanduser_idwhen the turn has them, conversation id) andConversationStore: at most 256 conversations, least recently used dropped first; idle expiry after an hour; each history keeps its system prompt plus at most 60 messages and 200,000 characters, dropping the oldest whole exchanges so a tool reply never loses its call.service.py:run_turnchecks out a copy of the key's history, passes it toanswer_turn, and stores it back whole. The old unboundedState.conversationsdict andState.history()are gone.docs/operations/service.md(Conversation history) and the README.Lake's side
Lake's own check of the conversation id across workspaces is being fixed separately in lake. This PR makes the agent safe without relying on it.
Tests
New
tests/test_conversations.py: workspace B with A's conversation id gets an empty history and cannot write into A's; a turn's copy is not shared; 10,000 conversation ids (directly and throughrun_turn) stay within the bound; idle expiry; a long history keeps its prompt and newest whole exchanges within the message and character bounds.The tests were not run and nothing was built (Steve, 2026-11-14: tests run at review and release time).