feat(memory): add user preferences and structured user context in system prompt#8264
feat(memory): add user preferences and structured user context in system prompt#8264Subash-Mohan merged 9 commits intomainfrom
Conversation
Greptile OverviewGreptile SummaryThis PR adds a new free-text Two merge-blockers were found: Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as SettingsPage (Web)
participant Hook as useUserPersonalization
participant API as PATCH /user/personalization
participant DB as update_user_personalization
participant Msg as process_message
participant Mem as get_memories(UserMemoryContext)
participant Prompt as build_system_prompt
participant ToolRun as run_tool_calls
participant Search as SearchTool
UI->>Hook: updateUserPreferences(value)
UI->>Hook: handleSavePersonalization()
Hook->>API: persistPersonalization({ user_preferences, ... })
API->>DB: update_user_personalization(..., user_preferences)
DB-->>API: commit
API-->>Hook: 200 OK
Msg->>Mem: get_memories(user)
Mem-->>Msg: UserMemoryContext
Msg->>Prompt: build_system_prompt(..., user_memory_context)
Prompt-->>Msg: system prompt w/ structured user sections
Msg->>ToolRun: run_tool_calls(..., user_memory_context)
ToolRun->>Search: override_kwargs.user_memory_context
Search->>Search: as_formatted_list() used for query expansion
Search-->>ToolRun: SearchDocsResponse/citations
|
Additional Comments (2)
|
There was a problem hiding this comment.
3 issues found across 17 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="backend/onyx/chat/prompt_utils.py">
<violation number="1" location="backend/onyx/chat/prompt_utils.py:161">
P3: Avoid adding USER_INFORMATION_HEADER when the formatted user context is empty; otherwise the system prompt includes a blank section.</violation>
</file>
<file name="backend/onyx/server/manage/models.py">
<violation number="1" location="backend/onyx/server/manage/models.py:218">
P2: Enforce the 500-character limit for user preferences in the update request so the API matches the stated feature constraints and prevents oversized inputs.</violation>
</file>
<file name="backend/onyx/db/memory.py">
<violation number="1" location="backend/onyx/db/memory.py:47">
P2: `User role` is omitted from the system prompt when a user has only a role set (no name/email) because `has_basic_info` ignores `self.user_info.role`. Include role in the check so role-only users still get their role in the Basic Information section.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…d user data handling
…ate related logic for cleaner user preference management
…success/error popups
… and enhance user memory context formatting
…emoryContext configuration
…ry context handling
9bf804a to
d5e1deb
Compare
…to correct reference
… with maxRows support
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="web/src/refresh-components/inputs/InputTextArea.tsx">
<violation number="1" location="web/src/refresh-components/inputs/InputTextArea.tsx:103">
P2: Auto-resize only re-runs when `props.value` changes, so uncontrolled textareas won’t resize as the user types. Consider wiring `adjustHeight` to an input/change handler to update height on user input.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| textarea.style.overflowY = contentHeight > maxHeight ? "auto" : "hidden"; | ||
| }, [autoResize, rows, maxRows]); | ||
|
|
||
| React.useEffect(() => { |
There was a problem hiding this comment.
P2: Auto-resize only re-runs when props.value changes, so uncontrolled textareas won’t resize as the user types. Consider wiring adjustHeight to an input/change handler to update height on user input.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At web/src/refresh-components/inputs/InputTextArea.tsx, line 103:
<comment>Auto-resize only re-runs when `props.value` changes, so uncontrolled textareas won’t resize as the user types. Consider wiring `adjustHeight` to an input/change handler to update height on user input.</comment>
<file context>
@@ -50,13 +50,62 @@ import {
+ textarea.style.overflowY = contentHeight > maxHeight ? "auto" : "hidden";
+ }, [autoResize, rows, maxRows]);
+
+ React.useEffect(() => {
+ adjustHeight();
+ }, [adjustHeight, props.value]);
</file context>
Description
user_preferencescolumnon the User model
UserMemoryContextto consolidate user info (name, email, role), preferences, and memories into a singlestructured object
## Basic Information,## User Preferences,## User Memories) using templates fromuser_info.pyHow Has This Been Tested?
I tested it by adding preferences and sending a message to confirm whether it is acting as preferred.
Additional Options
Summary by cubic
Adds a Personal Preferences field and a structured UserMemoryContext to render a clearer “User Information” section in system prompts, improving personalization and search query expansion. Updates Settings with a preferences textarea, 500-character counter, and save success/error toasts, and reorganizes Memory and Prompt Shortcuts.
New Features
Migration
Written for commit e349d68. Summary will update on new commits.