Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(voice): surface narrate-instead-of-call as a toast so user knows the action didn't land
Adam Eivyc37d42770387
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex ebaa48709e..8d775959d4 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -42,6 +42,8 @@## Fixed+- **Voice agent said "I opened that" / "Added to your inbox" but nothing actually happened** — small tool-use models (Qwen3-4B class) occasionally narrate an action as their spoken reply without ever issuing the matching `tool_call`. The system-prompt biasing (enumerated trigger phrases, NEVER-echo directives) catches most of these, but leaks remain on long tool lists and fuzzy phrasings. The user heard a confident confirmation but no navigation/capture/fill happened. `pipeline.js` now detects the pattern after the turn completes — when no tool ran, the final reply is non-empty, and the reply matches a narrow action-claim regex ("I opened", "I've saved", "Navigating to", "Adding that", etc.) — and emits a `voice:error` toast ("I said I'd do that but didn't actually call the tool. Try rephrasing — e.g. 'open my daily log' or 'go to tasks'.") so the user knows the action didn't land and can rephrase. The regex is intentionally narrow on first-person past/progressive action-claim phrasings to avoid false-positives on conversational replies that mention the same verbs ("You saved that yesterday", "Your daily log is a good habit"). Also logs `🎙️ [turnId] narrate-without-call user="..." reply="..."` so we can grep server logs for recurrences. New `detectNarrationWithoutCall` helper is exported for unit testing; 6 new tests cover first-person past, progressive tense, confirmed-by-tool-run (no flag), empty reply (no flag), conversational false-negative cases, and missing-input tolerance.+- **Voice agent wrote to the brain inbox instead of filling the target form field, then captured its own TTS summary as a second brain entry** — two coupled bugs. (1) `brain_capture` was always-on in the per-turn tool list, so on UI form-fill turns ("fill description with X", "type Y in the title", "put Z in the body") the LLM saw both `ui_fill` and `brain_capture`. Because `brain_capture`'s description emphasizes "note/save/remember/jot" — words that overlap with field content — the model frequently picked capture over fill. Moved `brain_capture` into the `brain` group, expanded the brain intent regex to still catch natural phrasings ("remember to buy milk", "jot down", "note that…", "save this/that", "file this", "add this to my brain inbox"), and added a `UI_FILL_INTENT_RE` that detects form-fill verbs near a field-word ("description/name/title/subject/body/content/field/input/textarea/form/label/placeholder/caption") and forcibly suppresses `brain_capture` + `daily_log_append` for that turn (also force-activates the `ui` group so `ui_fill` reaches the LLM even when the verb wasn't already in the UI regex, e.g. "put Y in the body"). System prompt gains a CRITICAL section that explicitly forbids capture tools on field-fill turns regardless of content words. (2) In hands-free mode the VAD used `bargeInMul=1.15` and `ttsTailMs=300ms` — too permissive for typical speaker→mic coupling. The bot's TTS output crossed the raised threshold, VAD transitioned to "speaking", captured the bot's own voice, submitted it as a new `voice:turn`, and the LLM processed its own paraphrased summary as a user command — creating a duplicate brain entry. Raised `bargeInMul` to 2.5, extended `ttsTailMs` to 700ms for typical room reverb, and added `bargeInOnsetConfirmMs=220` so during TTS playback + echo tail the VAD requires sustained signal (not a brief echo spike) before confirming speech-onset. Deliberate barge-in still works (sustained speech above the raised threshold). 10 new tests cover the tool-filter behavior (fill patterns drop brain_capture; natural capture phrases keep it; UI-only turns exclude brain_capture; expanded brain regex matches "remember"/"jot"/"note that").- **Voice agent lost context after `ui_navigate`, couldn't chain "go to tasks and create a new one"** — the tool-calling loop only paused for a client UI-refresh push when a `ui:*` side effect fired (`ui_click`, `ui_fill`, etc.). `ui_navigate` emits a `navigate` side effect, so the next LLM iteration ran against the old page's UI summary — it couldn't see the new page and effectively ended the turn without acting on the user's next step. `pipeline.js` now treats `navigate` as UI-mutating too and awaits the post-navigation `voice:ui:index` push (1500ms timeout since a full React route change + lazy-loaded bundle is slower than a ~120ms post-click DOM mutation). The fresh page summary is attached to the tool result so the LLM can chain follow-up `ui_click`/`ui_fill`/etc. in the same turn. System prompt updated to include `ui_navigate` in the CHAINED UI FLOWS guidance with a worked "go to tasks and add a task" example.diff --git a/server/services/voice/pipeline.js b/server/services/voice/pipeline.jsindex 33e9a557f2..92789739bb 100644--- a/server/services/voice/pipeline.js+++ b/server/services/voice/pipeline.js@@ -180,6 +180,21 @@ export const isNonSpeechMarker = (text) => /^\s*\[[A-Z_ ]+\]\s*$/i.test(text);// LLM. Intentionally narrow — "I'm done writing" shouldn't match.const STOP_DICTATION_RE = /^(stop|end|exit|cancel|pause)\s+(dictation|dictating|logging|recording)[\.\!\s]*$/i;+// Detect the narrate-instead-of-call failure: the LLM replied with text that+// claims it just performed an action ("I opened your daily log", "Navigating+// to tasks now", "Added that to your inbox") but no tool actually fired.+// Small tool-use models (Qwen3-4B / Hermes-3-8B class) still leak this+// occasionally even with the strong system-prompt biasing in buildSystemPrompt.+// The user hears a confident confirmation but nothing changed.+//+// Deliberately narrow: only fires on first-person action-claim phrasings, so+// conversational replies that happen to mention the same verbs ("I saved a+// file last year") don't false-positive. Exported for unit testing.+const ACTION_CLAIM_RE = /\b(?:I(?:'ve| have| just| already)?\s+(?:open(?:ed|ing)?|navigat(?:ed|ing)|sav(?:ed|ing)|add(?:ed|ing)|not(?:ed|ing)|captur(?:ed|ing)|remember(?:ed|ing)?|fill(?:ed|ing)|click(?:ed|ing)|select(?:ed|ing)|switch(?:ed|ing)|set|filed|logg(?:ed|ing))|(?:opening|navigating|saving|adding|noting|capturing|filing|logging|filling|clicking|selecting|switching)\s+(?:to\s+|your|the|that|this|it))\b/i;++export const detectNarrationWithoutCall = ({ finalText, toolRuns }) =>+ toolRuns?.length === 0 && !!finalText?.trim() && ACTION_CLAIM_RE.test(finalText);+// Short correlation id so overlapping turns in the logs can be told apart// (user interrupts, late-arriving retries). 5 chars of base36 randomness is// plenty for single-user PortOS.@@ -503,6 +518,15 @@ export const runTurn = async ({ audio, text, mimeType, source, history = [], emi: `Model ${lastLlm?.model || cfg.llm.model} returned no response.`;console.warn(`🎙️ empty LLM output — ${hint}`);emit('voice:error', { stage: 'llm', message: hint });+ } else if (!signal?.aborted && toolsEnabled && detectNarrationWithoutCall({ finalText, toolRuns })) {+ // Narrate-instead-of-call: the model claimed to do something but never+ // invoked a tool. User already heard the narration via TTS; surface a+ // toast so they know the action didn't actually happen and can rephrase.+ console.warn(`🎙️ [${turnId}] narrate-without-call user="${userText.slice(0, 80)}" reply="${finalText.slice(0, 120)}"`);+ emit('voice:error', {+ stage: 'llm',+ message: "I said I'd do that but didn't actually call the tool. Try rephrasing — e.g. \"open my daily log\" or \"go to tasks\".",+ });}emit('voice:llm:done', { text: finalText, model: lastLlm?.model, ttfbMs: firstLlm?.ttfbMs });diff --git a/server/services/voice/pipeline.test.js b/server/services/voice/pipeline.test.jsindex 0c98955151..827baf0bec 100644--- a/server/services/voice/pipeline.test.js+++ b/server/services/voice/pipeline.test.js@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest';-import { splitSentences, isNonSpeechMarker } from './pipeline.js';+import { splitSentences, isNonSpeechMarker, detectNarrationWithoutCall } from './pipeline.js';describe('splitSentences', () => {it('returns empty when no terminator is present', () => {@@ -73,3 +73,63 @@ describe('isNonSpeechMarker', () => {expect(isNonSpeechMarker('note: [TODO]')).toBe(false);});});++describe('detectNarrationWithoutCall', () => {+ it('flags first-person past-tense action claims with no tool calls', () => {+ expect(detectNarrationWithoutCall({+ finalText: "I've opened your daily log.",+ toolRuns: [],+ })).toBe(true);+ expect(detectNarrationWithoutCall({+ finalText: 'I added that to your inbox.',+ toolRuns: [],+ })).toBe(true);+ expect(detectNarrationWithoutCall({+ finalText: 'I just saved it for you.',+ toolRuns: [],+ })).toBe(true);+ });++ it('flags progressive-tense action claims with no tool calls', () => {+ expect(detectNarrationWithoutCall({+ finalText: 'Navigating to your tasks page now.',+ toolRuns: [],+ })).toBe(true);+ expect(detectNarrationWithoutCall({+ finalText: 'Opening the daily log.',+ toolRuns: [],+ })).toBe(true);+ });++ it('does not flag when a tool ran — claim is backed by action', () => {+ expect(detectNarrationWithoutCall({+ finalText: "I've opened your daily log.",+ toolRuns: [{ name: 'daily_log_open', ok: true, ms: 10 }],+ })).toBe(false);+ });++ it('does not flag empty / whitespace-only replies (covered by the empty-output check)', () => {+ expect(detectNarrationWithoutCall({ finalText: '', toolRuns: [] })).toBe(false);+ expect(detectNarrationWithoutCall({ finalText: ' ', toolRuns: [] })).toBe(false);+ });++ it('does not flag conversational replies that mention the same verbs', () => {+ expect(detectNarrationWithoutCall({+ finalText: 'Your daily log is a good habit to keep.',+ toolRuns: [],+ })).toBe(false);+ expect(detectNarrationWithoutCall({+ finalText: 'You saved that note yesterday, I think.',+ toolRuns: [],+ })).toBe(false);+ expect(detectNarrationWithoutCall({+ finalText: "It's 3:14 PM on Monday.",+ toolRuns: [],+ })).toBe(false);+ });++ it('tolerates missing inputs without throwing', () => {+ expect(detectNarrationWithoutCall({ finalText: undefined, toolRuns: undefined })).toBe(false);+ expect(detectNarrationWithoutCall({})).toBe(false);+ });+});