Fix local LLM response quality: sanitize tokens, inject user name, strip examples
Details
Three fixes for the Duncan chat tray:
1. Removed example conversations from system prompt — local models were
parroting them verbatim instead of following the behavioral guidance.
Replaced with terse directive-only prompt.
2. Added response sanitizer that strips raw chat template tokens
(<|assistant|>, <|end|>, <|im_start|>, etc.) and role prefixes
("- User:", "Assistant:", "Duncan:") that local models leak into output.
3. Injected user's display name (from app settings) into the system prompt
so Duncan addresses the user by name naturally.
Add response tier classifier for context-aware chat response lengths
Details
Introduces a three-tier response budget system (Short/Medium/Long) that
classifies the user's message intent before sending the AI request. Short
tier (greetings, yes/no, can't-do topics) caps at 100 tokens with 1-2
sentence guidance. Medium tier (explanations, how-to, brainstorming) allows
300 tokens and 3-5 sentences. Long tier (summarize a page, draft an email,
long-form writing) allows 800 tokens with paragraph-level output. The
classifier uses keyword matching with message length heuristics, and the
system prompt length rule adapts per tier. All configuration remains
centralized in AiPersona.cs.
Overhaul Duncan chat system prompt for terse, personality-driven responses
Details
The previous system prompt was a single generic sentence that the model
ignored, producing wall-of-text responses with repetitive AI disclaimers.
Replaced with a strict rule-based prompt enforcing 1-2 sentence replies,
no self-identification, no filler, and clear boundaries around what Duncan
can and cannot do (no internet, local-only). Dropped MaxTokens from 1024
to 200 and Temperature from 0.7 to 0.4 to further constrain verbosity.
Moved the system prompt into AiPersona.cs alongside the Name constant so
all persona configuration lives in one file.
Centralize AI persona name into AiPersona.Name constant, rename to Duncan
Details
All user-facing AI name references now derive from AiPersona.Name (a single
const in AiPersona.cs). XAML uses x:Static bindings, C# uses string
interpolation. Changing the AI persona name is now a one-line edit. Renamed
from Hugo to Duncan. Updated command palette entries, tray header, tooltip,
speech balloon, chat watermark, system prompt, and fallback user labels.
Fix AI tray closing on click by removing it from generic overlay backdrop
Details
The IsAnyOverlayPanelOpen property included IsAiTrayOpen, which caused the
generic click-outside backdrop (ZIndex 999) to appear on top of the AI tray
drawer (ZIndex 12). Any click inside the tray hit the generic backdrop first,
immediately closing all panels. The AI tray already has its own dedicated
click-outside backdrop (AiTrayBackdrop at ZIndex 11) so it does not need the
generic overlay. Removed IsAiTrayOpen from IsAnyOverlayPanelOpen and from
CloseAllPanels to let the tray handle its own dismiss behavior.
Get notified about new releases