-
Notifications
You must be signed in to change notification settings - Fork 4
User Profile
The User Profile System is a structured learning mechanism that builds a comprehensive understanding of your preferences, patterns, workflows, and skill level from your conversation history.
Starting in v2.2, OpenCode Memory replaces user-scoped memories with a structured profile system. Instead of storing individual memory items, the system analyzes batches of prompts to build and maintain a unified profile.
- Structured Data: Organized into preferences, patterns, workflows, and skill assessment
- Confidence Scoring: Preferences tracked with confidence levels (0.0-1.0)
- Frequency Tracking: Patterns and workflows ranked by occurrence
- Versioning: Full changelog with snapshot support
- Automatic Decay: Unused preferences gradually lose confidence
- Evidence-Based: Preferences backed by example prompts
User preferences with confidence scores and evidence.
Structure:
{
category: string // e.g., "Code Style", "Communication"
description: string // e.g., "Prefers code without comments"
confidence: number // 0.0-1.0, based on evidence strength
evidence: string[] // 1-3 example prompts
lastUpdated: number // Timestamp
}Examples:
-
[Code Style] Prefers TypeScript over JavaScript(confidence: 0.9) -
[Communication] Likes concise responses(confidence: 0.8) -
[Tools] Prefers Bun over npm(confidence: 0.7)
Limits: Max 20 preferences (configurable via userProfileMaxPreferences)
Recurring topics and interests with frequency tracking.
Structure:
{
category: string // e.g., "Technical Domain", "Problem Type"
description: string // e.g., "Often asks about database optimization"
frequency: number // Number of occurrences
lastSeen: number // Timestamp
}Examples:
-
[Technical Domain] Frequently works on authentication(frequency: 15) -
[Problem Type] Often debugs async/await issues(frequency: 8) -
[Technology] Regular questions about Docker(frequency: 12)
Limits: Max 15 patterns (configurable via userProfileMaxPatterns)
Development sequences and habits.
Structure:
{
description: string // Workflow description
steps: string[] // Sequence of steps
frequency: number // Number of times observed
}Examples:
-
Usually asks for tests after implementation(frequency: 10)- Steps: ["Implement feature", "Request tests", "Review coverage"]
-
Always requests code review before committing(frequency: 8)- Steps: ["Complete code", "Ask for review", "Apply feedback"]
Limits: Max 10 workflows (configurable via userProfileMaxWorkflows)
Overall and per-domain skill assessment.
Structure:
{
overall: "beginner" | "intermediate" | "advanced"
domains: {
[domain: string]: "beginner" | "intermediate" | "advanced"
}
}Example:
{
"overall": "intermediate",
"domains": {
"typescript": "advanced",
"docker": "beginner",
"database": "intermediate",
"testing": "intermediate"
}
}Profile analysis triggers every N prompts (default: 10, configurable via userMemoryAnalysisInterval).
Process:
- System accumulates uncaptured prompts
- When threshold reached, AI analyzes batch
- Profile created (first time) or updated (subsequent)
- Changelog entry created
- Prompts marked as analyzed
On first analysis:
- AI analyzes prompt batch
- Identifies preferences, patterns, workflows, skill level
- Assigns initial confidence scores (conservative)
- Creates profile with version 1
- Stores changelog snapshot
On subsequent analyses:
- AI receives existing profile + new prompts
- Merges new insights with existing data
- Updates confidence scores for reinforced preferences
- Increments frequency for recurring patterns
- Adds new items if space available
- Removes low-confidence/low-frequency items if limits exceeded
- Increments version number
- Creates changelog entry
Preferences automatically decay over time if not reinforced.
Mechanism:
- Decay threshold: 30 days (configurable via
userProfileConfidenceDecayDays) - After threshold, confidence gradually decreases
- Preferences below 0.3 confidence are removed
- Decay factor:
max(0.5, 1 - (age - threshold) / threshold)
Example:
- Preference at confidence 0.8
- Not seen for 45 days (threshold: 30)
- Age beyond threshold: 15 days
- Decay factor:
1 - 15/30 = 0.5 - New confidence:
0.8 * 0.5 = 0.4
When updating profile:
Preferences:
- Existing preference reinforced → increase confidence by 0.1 (max 1.0)
- New preference → add with initial confidence from AI
- Sort by confidence, keep top N
Patterns:
- Existing pattern seen → increment frequency
- New pattern → add with frequency 1
- Sort by frequency, keep top N
Workflows:
- Existing workflow observed → increment frequency
- New workflow → add with frequency 1
- Sort by frequency, keep top N
Skill Level:
- Overall: Take higher of existing vs new
- Domains: Merge, taking higher level per domain
Every profile update creates a changelog entry.
Changelog Entry:
{
id: string
profileId: string
version: number
changeType: "create" | "update"
changeSummary: string // e.g., "+3 preferences, +2 patterns"
profileDataSnapshot: string // Full profile JSON
createdAt: number
}Retention: Last 5 versions kept (configurable via userProfileChangelogRetentionCount)
Use Cases:
- Debug profile evolution
- Rollback to previous version
- Audit what changed
- Track learning progress
memory({ mode: "profile" })Response:
{
"success": true,
"profile": {
"preferences": [...],
"patterns": [...],
"workflows": [...],
"skillLevel": {...},
"version": 5,
"lastAnalyzed": "2026-01-12T10:30:00Z",
"totalPromptsAnalyzed": 50
}
}Get Profile:
GET /api/profileGet Changelog:
GET /api/profile/changelog?limit=5Get Snapshot:
GET /api/profile/snapshot/:changelogIdForce Refresh:
POST /api/profile/refreshBefore (v2.1 and earlier):
- User learning created individual memory items
- Stored as user-scoped memories
- No structure or organization
- No confidence scoring
- No versioning
After (v2.2+):
- User learning creates/updates structured profile
- Single profile per user
- Organized into categories
- Confidence and frequency tracking
- Full versioning and changelog
-
User-scoped
addMemorydeprecated:// ❌ No longer works memory({ mode: "add", content: "...", scope: "user" }) // Returns error: "User-scoped memories are deprecated"
-
Profile API changed:
// ❌ Old structure (v2.1) { profile: { static: ["fact1", "fact2"], dynamic: ["fact3", "fact4"] } } // ✅ New structure (v2.2) { profile: { preferences: [{...}], patterns: [{...}], workflows: [{...}], skillLevel: {...} } }
-
Update code using
mode: "profile":- Handle new structure (preferences/patterns/workflows/skillLevel)
- Remove references to
staticanddynamicfields
-
Remove user-scoped
addcalls:- Delete any code calling
memory({ mode: "add", scope: "user" }) - Profile is now built automatically from prompts
- Delete any code calling
-
Add new config options (optional):
{ "userProfileMaxPreferences": 20, "userProfileMaxPatterns": 15, "userProfileMaxWorkflows": 10, "userProfileConfidenceDecayDays": 30, "userProfileChangelogRetentionCount": 5 } -
Existing user memories:
- Remain readable in database
- No longer created or updated
- Will be used for search if queried
- Consider exporting if needed
The web UI includes a dedicated Profile Viewer:
Features:
- View current profile (preferences/patterns/workflows/skill level)
- Browse changelog history
- View snapshots of previous versions
- See confidence scores and frequencies
- Track profile evolution over time
Access: Navigate to "Profile" tab in web UI at http://127.0.0.1:4747
- Consistent interaction: Regular usage improves accuracy
- Clear communication: Explicit preferences are captured better
- Varied topics: Diverse prompts reveal more patterns
- Feedback loop: Review profile periodically
-
Adjust interval: Lower
userMemoryAnalysisIntervalfor faster learning (higher cost) - Tune limits: Reduce max items if profile too large
-
Disable if unused: Set
userMemoryAnalysisInterval: 0to disable
- Review profile: Check what's captured via web UI
- Manual cleanup: Delete profile if needed (via database)
-
Disable injection: Set
injectProfile: falseto exclude from context
Symptoms: mode: "profile" returns no profile
Causes:
- Not enough prompts analyzed yet (need at least
userMemoryAnalysisInterval) - User learning disabled (
userMemoryAnalysisInterval: 0) - AI provider not configured
Solutions:
- Wait for threshold to be reached
- Check config:
userMemoryAnalysisInterval> 0 - Verify
memoryProvider,memoryModel,memoryApiKeyconfigured
Symptoms: Profile version not incrementing
Causes:
- Prompts not accumulating
- Analysis failing silently
- AI returning no changes
Solutions:
- Check logs for errors
- Verify API key valid
- Try
POST /api/profile/refreshto force update
Symptoms: All preferences have low confidence
Causes:
- Inconsistent behavior
- Insufficient evidence
- Conflicting preferences
Solutions:
- Be more consistent in requests
- Explicitly state preferences
- Review and remove conflicting items
- Configuration Guide - Configure profile settings
- Memory Operations - Use the memory tool
- Web Interface - View profile in UI
- Auto-Capture System - How prompts are captured
{ // Analysis trigger "userMemoryAnalysisInterval": 10, // Profile limits "userProfileMaxPreferences": 20, "userProfileMaxPatterns": 15, "userProfileMaxWorkflows": 10, // Decay settings "userProfileConfidenceDecayDays": 30, // Changelog retention "userProfileChangelogRetentionCount": 5, // Inject profile into AI context "injectProfile": true }