Skip to content

[BUG] User profile learning fragments profiles, never drains backlog, and can flip language #57

Description

@ZeR020

Surfaced by @ovizii's report in #55 (1,524 prompts stored, 1,484 awaiting, 40 analyzed → four separate anonymous profiles, one in the wrong language).

Bug 1 — Profile fragmentation when git email is unresolvable.
performUserProfileLearning falls back to userId = anonymous-${Date.now()}-${random} when tags.user.userEmail is empty (userEmailOverride unset + no git config user.email — common for non-coding use). A new random identity per run means getActiveProfile() never matches, so every 10-prompt batch creates a brand-new anonymous profile instead of updating one. 40 analyzed prompts = 4 batches = 4 profiles, exactly as reported.

Bug 2 — Analysis backlog never drains.
Each session-idle run analyzes exactly one batch of userProfileAnalysisInterval (10) prompts. A backlog of N prompts needs N/10 idle cycles; 1,524 stored prompts ≈ 148 idles. Learning permanently lags behind.

Bug 3 — Profile language can flip between batches.
The system prompt asks for "the same language as the user's prompts", but a mixed-language batch lets the model pick a different language per batch. Output language should be pinned (dominant language detection; existing profile's language when updating).

Fix direction: stable fallback identity (reuse latest active profile's userId, else constant anonymous), a per-idle drain loop bounded by a new userProfileMaxBatchesPerIdle config, and explicit language pinning via the existing language-detector service.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions