Skip to content

fix(talk,ui): mic echo, dropped talk flags, server stdin hang - #3616

Merged
kovtcharov-amd merged 15 commits into
amd:mainfrom
kovtcharov:fix/talk-and-ui-product-defects
Sep 26, 2026
Merged

kovtcharov-amd merged 15 commits into
amd:mainfrom
kovtcharov:fix/talk-and-ui-product-defects

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

gaia talk heard itself: the microphone stayed live while it spoke, so its own voice came back as the next request. It also accepted --model, --max-tokens, --use-claude, --use-chatgpt, --claude-model, --base-url and --stats, then ran without them. Now capture pauses for the whole of playback and every flag reaches the component that uses it.

Outside voice, an Agent UI chat turn could hang forever on an input() prompt printed to the server's own terminal — a server-side console now never prompts, while the CLI still does — and import gaia crashed in any process without a resolvable home directory. Also fixes the wrong port in .env.example and a length mismatch that could misalign RAG chunks with their embeddings.

Fixes #124

Test plan

  • python -m pytest tests/unit/test_audio_recorder_sd.py tests/unit/test_cli_talk_flags.py tests/unit/test_logger_home_unresolvable.py tests/unit/test_rag_encode_alignment.py tests/unit/test_talk_config.py tests/unit/test_talk_playback_mute.py tests/unit/test_ui_no_stdin_prompts.py — 63 passed; the two of these files that exist on main pass 16/16 there
  • python -m pytest hub/agents/chat/python/tests — 14 passed in 1.70s
  • The ChatAgent wiring test fails if the validator's interactive_check hook is removed — checked by removing it
  • gaia talk --help lists every flag, and gaia talk --use-chatgpt refuses and exits 1
  • import gaia in a subprocess with the home-directory variables removed succeeds
  • With a real microphone and speaker: talk over playback and confirm it is not transcribed (not run on the author's machine)
  • Agent UI started from a terminal: a turn that needs a path outside the allowlist is denied without prompting the server's stdin (not run end to end)

`gaia talk` answered its own voice on laptop speakers, ignored every
model/backend flag it accepted (amd#124), and exited 0 when the voice loop
crashed. An Agent UI chat turn could hang forever on an input() prompt
printed to the server's terminal, and `import gaia` died in any Windows
process with no resolvable home directory.

- talk (C33): the mic stays paused for the whole utterance and resumes
  only after a full join. KokoroTTS returns once playback has ended, and
  playback keeps draining after an interrupt so the join cannot deadlock.
  A TTS crash, including one before playback starts, resumes the mic
  and surfaces as an error. Transcriptions captured during playback are
  dropped. A paused recorder now discards device frames instead of
  letting them queue.
- talk (C34): --model, --max-tokens, --use-claude, --use-chatgpt,
  --claude-model, --base-url and --stats reach AgentSDK and AudioClient.
  --stats reads the dest argparse actually sets. --use-chatgpt requires
  --model rather than sending the local default model to OpenAI.
- talk (I60): one Enter listener per session. A loop crash or a dead
  microphone raises, so the CLI exits 1. is_recording tracks whether the
  capture thread is alive.
- UI (C37): consoles declare supports_stdin_prompts. Path-access,
  overwrite and max-steps prompts ask the requester's console, not the
  server's TTY.
- logger (C38): a RuntimeError from Path.home() falls back to the
  tempdir log and says so on stderr.
- rag (I50): a short or hollow embedding batch raises instead of pairing
  chunks with the wrong vectors.
- .env.example (I21): Lemonade's default port is 13305.

Fixes amd#124
@github-actions github-actions Bot added documentation Documentation changes talk Talk agent changes rag RAG system changes audio Audio (ASR/TTS) changes cli CLI changes tests Test changes security Security-sensitive changes performance Performance-critical changes agents labels Sep 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Request changes

Three good fixes here — the mic no longer hears the assistant, every gaia talk flag now reaches the thing that uses it, and a dead microphone finally produces an error instead of a silent "Listening…" forever. One change has a side effect that needs fixing before merge.

The server-stdin fix also disables prompting for ordinary gaia chat. gaia chat runs on the quiet console by default (anything but --debug), and that console is now treated as "nobody is on stdin" — so when the agent needs to touch a file outside the allowed list, the user is no longer asked, the request is just denied. Same for the "keep going?" question after the step limit. The quiet console is explicitly the one a real person sits in front of at a terminal (it still asks for tool confirmations), so it should still be allowed to ask; the browser and API consoles are the ones that must not.

The self-hearing fix only covers one of the two voice entry points. gaia talk is fixed. The other public method an SDK user would wire up — the one the audio-client spec's own example uses as its message processor — still turns the microphone back on after a fixed ~3 seconds regardless of how long the reply takes, so any reply longer than that still gets heard and answered.

Real-world evidence

No evidence bundle was produced for this PR, and no test environment is available on this runner, so this verdict rests on static review alone.

The PR's own test plan names the two checks that would have caught the issues above and marks both as not run: the microphone/speaker echo test ("not run on the author's machine") and the Agent UI deny-without-prompting test ("not run end to end"). The unit suites listed are reported as passing but every test-plan box is left unchecked. Worth adding the real gaia chat terminal case too — ask it for a file outside the allowed list and confirm you still get prompted rather than denied.

🔍 Technical details

🔴 Critical

1. SilentConsole is the default gaia chat console, so path grants and the max-steps prompt now auto-deny (src/gaia/agents/base/console.py:255)

cli.py:582 sets use_silent_mode = not debug_mode, and Agent._create_console returns SilentConsole whenever silent_mode is set — so every non---debug gaia chat run uses it. supports_stdin_prompts defaults to False on OutputHandler and SilentConsole doesn't override it, so PathValidator._can_prompt() returns False and _prompt_user_for_access (security.py:457) auto-denies instead of asking. The step-limit continue prompt (agent.py:6800) goes the same way.

This contradicts the invariant documented on the class itself:

Silence covers narration, not consent: gaia chat runs on this console with a real user at the terminal, so confirmation-gated tools still prompt when stdin/stdout are a TTY and are denied otherwise (#2210).

TerminalConfirmationMixin is already the "a person may be at this terminal" marker — both AgentConsole and SilentConsole mix it in, while ui.sse_handler.SSEOutputHandler and api.sse_handler.SSEOutputHandler derive from OutputHandler directly. Putting the flag there keeps both behaviours consistent and keeps your UI fix intact, since ui/agent_loop.py:392,416 and ui/_chat_helpers.py:1852,1935,2081 all assign agent.console = sse_handler before the turn runs. Worth confirming there's no UI path that runs a turn without that assignment — if one exists it already blocks on confirm_tool_execution today.

    supports_stdin_prompts: bool = False
    """Whether the person driving this handler is on the *process's* stdin.

    A server-side handler shares the process stdin with the operator but not
    with the requester, so a blocking ``input()`` there hangs the request
    forever while stealing the operator's keystrokes. Consoles mixing in
    ``TerminalConfirmationMixin`` set this True -- a real user is at the
    terminal, silent or not (#2210).
    """

…plus supports_stdin_prompts = True on TerminalConfirmationMixin (then AgentConsole's own override at console.py:854 becomes redundant), and flip the (SilentConsole, False) row in tests/unit/test_ui_no_stdin_prompts.py:30 to True.

🟡 Important

2. AudioClient.process_voice_input still resumes the mic on a timeout, not on playback end (src/gaia/audio/audio_client.py:333-341)

speak_text got the full fix. process_voice_input did not: its finally does tts_finished.wait(timeout=2.0) then tts_thread.join(timeout=1.0) and calls resume_recording() regardless — so any reply with more than ~3s of audio has the microphone live mid-sentence, which is the exact bug this PR exists to fix. It's not dead code from an integrator's point of view: docs/spec/audio-client.mdx:117-118 and :292-293 present it as the message processor to pass to start_voice_chat. Either route it through the same pause/drain/full-join as speak_text, or mark it deprecated in the spec and point the example at speak_text.

🟢 Minor

3. Overwrite auto-approval still logs "non-interactive context" (src/gaia/security.py:660) — the sibling message at :459 was updated for the new semantics; this one now also fires for a TTY-attached server.

                "Auto-approving overwrite of %s (no interactive requester on "
                "this process's stdin, backup will be created)",

4. Two different claude_model defaults (src/gaia/cli.py:790) — argparse defaults --claude-model to claude-sonnet-4-20250514 (cli.py:1230), while TalkConfig, AgentConfig and AudioClient all default to claude-sonnet-5. The kwargs.get("claude_model", "claude-sonnet-5") fallback is unreachable (argparse always supplies a value) and reads as if sonnet-5 were the CLI default, which it isn't. Either align the argparse default or drop the misleading fallback.

5. Unbounded joins can wedge a turn (kokoro_tts.py:419, audio_client.py:441) — the reasoning is sound (a timeout here resumes the mic mid-sentence), but a stalled PortAudio stream.write now hangs the processor thread with no recovery except Ctrl+C. A bound derived from the synthesized audio duration plus slack would keep the correctness property while staying recoverable.

6. WhisperAsr._record_audio_streaming ignores is_paused (whisper_asr.py:133) — start_recording_streaming callers keep the echo bug. Out of the talk path (which uses the base start_recording), but the file was touched here, so worth a note or a matching drain branch.

Strengths

  • The is_recording / capture_failed liveness pair is the right fix for a genuinely nasty failure: a dead capture thread used to leave the app spinning "Listening…" forever, and it now produces an error naming the two commands that resolve it.
  • The RAG alignment guard is textbook fail-loudly — it catches the silent corruption (chunk i paired with vector j), and the message says what failed, what to check, and what to do next.
  • tests/unit/test_cli_talk_flags.py drives the real argparse parser and entry point with only the two consuming clients mocked, so an unwired flag fails its own parametrized case. That's exactly the shape that would have caught the original --stats/show_stats dest mismatch.
  • test_logger_home_unresolvable.py running the import in a fresh subprocess with the home vars stripped tests the real trigger rather than a mock of it.

kovtcharov and others added 2 commits September 11, 2026 16:24
Local repairs are ready for review in `worktrees/3616` on `codex/pr-3616-maintenance`; nothing committed, pushed, or posted.
# Conflicts:
#	docs/guides/talk.mdx
#	src/gaia/audio/audio_client.py
#	src/gaia/audio/whisper_asr.py
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

The TTS timeout, mic-drain-while-paused, and stdin-prompt gate fixes address real concurrency bugs cleanly, and the test coverage across all four new test files is solid. One model-default inconsistency is worth fixing before merge.


🟡 gaia talk --use-claude silently picks Claude Sonnet 4, not the latest Sonnet 5

cli.py hardcodes "claude-sonnet-4-20250514" as the fallback when --claude-model is not given. TalkConfig.claude_model and AudioClient's constructor both default to "claude-sonnet-5". A user calling gaia talk --use-claude gets the older model; the same user calling TalkSDK(TalkConfig(use_claude=True)) from Python gets the newer one. The spec docs (audio-client.mdx, talk-sdk.mdx) also say claude-sonnet-5. CLAUDE.md: "default to the latest and most capable Claude models."

Fix: change the cli.py fallback (kwargs.get("claude_model", "claude-sonnet-4-20250514")) to "claude-sonnet-5", or align the class defaults to the pinned version and call that out explicitly in the PR.

🔍 Technical details

Conflicting defaults across the same push:

  • src/gaia/talk/sdk.py:50: claude_model: str = "claude-sonnet-5"
  • src/gaia/audio/audio_client.py:54: claude_model="claude-sonnet-5"
  • src/gaia/cli.py (new hunk ~line 972): claude_model=kwargs.get("claude_model", "claude-sonnet-4-20250514")
  • docs/reference/cli.mdx (option table): lists claude-sonnet-4-20250514 as the documented default
  • docs/spec/audio-client.mdx and docs/spec/talk-sdk.mdx: both say claude-sonnet-5

The CLI overrides the class default, so end-users and SDK users get different behaviour from the same flags. test_defaults_without_backend_flags asserts claude-sonnet-4-20250514, which would need updating if the CLI default is fixed.

Simplest fix in cli.py:

claude_model=kwargs.get("claude_model", "claude-sonnet-5"),

and update cli.mdx and the test assertion to match.


🟢 audio_client.py finally: tts_thread.join() has no timeout

The join relies on generate_speech_streaming always returning (it now times out internally), but a future change to the TTS internals could silently re-introduce a hang here. A short comment noting the dependency would be enough.

Kalin Ovtcharov and others added 2 commits September 17, 2026 13:09
amd#3860 landed the same guard on main with different messages and a batch
retry in place of the one-by-one fallback; the invariant these pin — raise
rather than shift chunks against misaligned vectors — is unchanged.

Co-Authored-By: Claude Opus 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

The playback mute refactor is solid — mic is now paused before LLM generation starts and only resumed after tts_thread.join() in the finally block, which correctly prevents the assistant from hearing its own reply regardless of whether TTS fires an early status_callback(False). The interactive_check callback on PathValidator is a clean way to distinguish "server has a TTY" from "requester is on that TTY", and the new is_recording property / capture_failed flag give the voice loop the signals it needs to propagate device failures loudly. Test coverage for all these paths is thorough.

Two things worth fixing before this lands:

🟡 The CLI default claude_model ("claude-sonnet-4-20250514") diverges from the TalkConfig dataclass default ("claude-sonnet-5") and from the spec in docs/spec/audio-client.mdx / docs/spec/talk-sdk.mdx. Programmatic TalkSDK(TalkConfig(use_claude=True)) uses Sonnet 5; gaia talk --use-claude uses Sonnet 4. Users consulting the spec and users of the CLI get different models without any hint in the docs that the two paths differ. Either align the CLI default to "claude-sonnet-5" or add a note in the CLI reference that the default intentionally differs from the SDK default.

🟢 The speech_dropped / speak() helper in process_voice_input is dead code now that text_queue is unbounded (queue.Queue() with no maxsize). queue.Full can never be raised on an unbounded queue, so speech_dropped never becomes True. The original guard was meaningful when the queue had maxsize=100; at this point the helper just adds noise. Consider either restoring a bounded queue or removing the dropped-speech logic.

🔍 Technical details

claude_model default divergence

src/gaia/talk/sdk.py:47 and docs/spec/talk-sdk.mdx:196 declare claude_model: str = "claude-sonnet-5".
src/gaia/cli.py:972 hardcodes claude_model=kwargs.get("claude_model", "claude-sonnet-4-20250514"), overriding the dataclass default every time gaia talk runs.
docs/reference/cli.mdx:109 documents the CLI default as claude-sonnet-4-20250514.
test_cli_talk_flags.py:1444 asserts "claude-sonnet-4-20250514" for the CLI default, confirming the split is intentional — but it means the spec and the CLI are describing different models. If the intent is to keep the older model as the CLI default while the SDK exposes the newer one, the CLI reference should say "Note: the CLI default differs from TalkConfig's programmatic default (claude-sonnet-5)."

speech_dropped dead code

src/gaia/audio/audio_client.py:244: text_queue = queue.Queue() — no maxsize.
src/gaia/audio/audio_client.py:263: text_queue.put(item, timeout=5.0) — will never block on a queue with no maxsize cap; queue.Full is unreachable.
The speech_dropped latch and the speak() wrapper can therefore be replaced by a direct text_queue.put(item) without the try/except, which makes the code clearer about its intent.

Kalin Ovtcharov and others added 2 commits September 17, 2026 14:47
…k_text puts

capture_failed read thread liveness, which _record_audio's own flag reset
makes indistinguishable from a requested stop — and reads True for a
recorder whose thread was never started. It now keys on mic_error, cleared
at start and suppressed once stop_recording has been asked for.

speak_text keeps its unbounded join (that is the mic-mute window) but takes
main's bounded puts, so a TTS thread that died on a broken output device
cannot wedge the caller.

Co-Authored-By: Claude Opus 5 <[email protected]>
…vable

EMBEDDED_LEMONADE_STATE resolved Path.home() at module scope, which raises
on Windows when neither USERPROFILE nor HOMEDRIVE+HOMEPATH is set — turning
a missing optional credential into an import failure. Same guard the logger
already uses; the reader treats None as 'no embedded server'.

Co-Authored-By: Claude Opus 5 <[email protected]>
@github-actions github-actions Bot added the llm LLM backend changes label Sep 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

The mic-muting, bounded-TTS, and single-stdin-listener redesign is solid and the test coverage is thorough. One inconsistency is worth fixing before this ships.


🟡 gaia talk --use-claude silently uses a different model than TalkSDK(TalkConfig(use_claude=True))

cli.py hardcodes "claude-sonnet-4-20250514" as the fallback when --claude-model is not given, but TalkConfig and AudioClient both default to "claude-sonnet-5", and both spec docs (talk-sdk.mdx, audio-client.mdx) show "claude-sonnet-5". The CLI reference table (cli.mdx) also says claude-sonnet-4-20250514. CLAUDE.md says to default to the latest model. This means a user calling the CLI gets an older model than one using the SDK directly, with no documentation explaining why.

The fix is to align the CLI fallback with the SDK/spec default ("claude-sonnet-5") and update cli.mdx to match, or document the intentional divergence.


Everything else looks correct:

  • Mic-pause-before-thread-start in speak_text prevents the self-transcription race.
  • The unbounded tts_thread.join() relies on KokoroTTS's internal PLAYBACK_TIMEOUT_SLACK deadline, which is sound.
  • capture_failed keyed on mic_error and not _stop_requested correctly distinguishes device failures from clean stops.
  • Draining the device while paused (rather than sleeping) prevents the ring-buffer self-transcription on resume.
  • _start_stdin_listener starting only once per session is correct; the interrupt_event.clear() at each speak_text/process_voice_input call prevents stale Enter presses from cutting off the next reply.
  • _home_log_file() / _embedded_lemonade_state_path() guards are the right defensive pattern for no-home environments.
  • Test coverage for the new paths is thorough and correctly avoids mocking at the HTTP boundary.
🔍 Technical details

Inconsistency locations:

  • src/gaia/cli.py:986: claude_model=kwargs.get("claude_model", "claude-sonnet-4-20250514")
  • src/gaia/talk/sdk.py: claude_model: str = "claude-sonnet-5"
  • src/gaia/audio/audio_client.py: claude_model="claude-sonnet-5" (default param)
  • docs/spec/audio-client.mdx: claude_model="claude-sonnet-5"
  • docs/spec/talk-sdk.mdx: claude_model: str = "claude-sonnet-5"
  • docs/reference/cli.mdx: shows claude-sonnet-4-20250514

Suggested fix — change cli.py line 986 and cli.mdx default column to "claude-sonnet-5" to match the SDK and spec. The test_defaults_without_backend_flags assertion on line 1496 of tests/unit/test_cli_talk_flags.py would need to be updated to match.

@github-actions

Copy link
Copy Markdown
Contributor

🟡 The CLI and the SDK dataclass use different default Claude models, and the spec docs reflect the inconsistency.

TalkConfig.claude_model defaults to "claude-sonnet-5" in sdk.py, but cli.py overrides it with "claude-sonnet-4-20250514" when building the config from flags. SDK callers who pass use_claude=True without an explicit claude_model get the newer model; CLI users (gaia talk --use-claude) get the older one. The published spec (docs/spec/talk-sdk.mdx) shows "claude-sonnet-5" while the CLI reference table shows claude-sonnet-4-20250514, so the docs contradict each other too.

Pick one canonical default ("claude-sonnet-5" aligns with CLAUDE.md's "default to the latest model" guidance) and apply it to both sdk.py and cli.py, then update the CLI reference table and the test assertion in test_cli_talk_flags.py.

🔍 Technical details
  • src/gaia/talk/sdk.py:50 — claude_model: str = "claude-sonnet-5"
  • src/gaia/cli.py:798 — claude_model=kwargs.get("claude_model", "claude-sonnet-4-20250514")
  • docs/spec/talk-sdk.mdx (added in this PR) — shows "claude-sonnet-5"
  • docs/reference/cli.mdx — table default shows claude-sonnet-4-20250514
  • tests/unit/test_cli_talk_flags.py — test_defaults_without_backend_flags asserts "claude-sonnet-4-20250514" (it will keep passing; it's the inconsistency itself that's the problem)

Note: there is also a second occurrence of the hard-coded old model at cli.py:676 (the non-talk Claude path) — worth checking whether the same inconsistency applies there.

Kalin Ovtcharov added 2 commits September 18, 2026 23:40
`gaia talk --use-claude` ran Claude Sonnet 4 while `TalkSDK(TalkConfig(use_claude=True))`
ran Sonnet 5, and the CLI reference and SDK spec each documented a different
one. The `--claude-model` default, the chat and talk CLI paths, `TalkConfig`
and `AudioClient` now all read the Claude provider's `DEFAULT_CLAUDE_MODEL`
(`claude-sonnet-5`), so they cannot drift apart again. `gaia chat
--use-claude` moves to Sonnet 5 with them.
@kovtcharov

Copy link
Copy Markdown
Contributor Author

gaia talk --use-claude and TalkSDK(TalkConfig(use_claude=True)) now reach the same model, claude-sonnet-5 (4a96d09). The CLI flag, both CLI code paths, TalkConfig and AudioClient all read the Claude provider's own default, so they can't drift apart again. gaia chat --use-claude moves from Sonnet 4 to Sonnet 5 with them. Current main is merged in, which also re-runs the macOS smoke job that hit the flaky native faiss abort.

Two smaller notes are left for the author: the drop-on-full speech handling that can no longer trigger now that the queue is unbounded, and a comment on the unbounded TTS join.

🔍 Technical details
  • Shared constant: gaia.llm.providers.claude.DEFAULT_CLAUDE_MODEL. cli.py imports it as DEFAULT_CLAUDE_CHAT_MODEL because DEFAULT_CLAUDE_MODEL there already means the eval judge (gaia.eval.config, claude-opus-5). The provider module was already loaded by import gaia.cli, so startup cost doesn't change.
  • Uses: the --claude-model argparse default and help text, cli.py chat (:677) and talk (:799) kwargs.get fallbacks, TalkConfig.claude_model, AudioClient(claude_model=...).
  • Docs: cli.mdx talk options table now shows claude-sonnet-5; the talk guide's example shows the default and an explicit --claude-model claude-opus-5 override.
  • Tests: test_defaults_without_backend_flags asserts the constant. New test_claude_model_defaults_match_the_provider_default covers TalkConfig and AudioClient. The PR's listed suites plus test_claude_provider.py and hub/agents/chat/python/tests: 171 passed, 1 skipped. tests/unit/cli: 240 passed; the 4 test_gaia_binary_on_path failures also fail on origin/main (venv bin/ not on PATH here). black, isort, flake8 and pylint clean.
  • Not changed: the hub chat package's own CLI (hub/agents/chat/python/gaia_agent_chat/app.py, lite_agent.py) and several older spec pages still name claude-sonnet-4-20250514. They're outside this PR's surface and ship on their own version.
  • gaia talk --help now shows (default: claude-sonnet-5).

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

The one red check wasn't this PR's fault — the branch was 28 commits behind and missed a fix that already landed on main. Merged main in; no conflicts. All four review findings were already fixed on head before I touched it, so nothing is outstanding.

🔍 Technical details

The failure. "Test Gaia Agent" reported coding declares tools_required that no mixin registers: run_python. Fixed on main by 39c860b74 (#4051), which adds run_python to the inline set in tests/unit/test_starter_skills.py. Resolved here by git merge origin/main --no-edit — 135 files, clean.

Findings verified fixed on head:

  • console.py:712 — supports_stdin_prompts: bool = True now sits on TerminalConfirmationMixin, with OutputHandler keeping False at :202. AgentConsole (:862) and SilentConsole (:2553) both inherit it, which is exactly the suggested fix and preserves the ops-core: generic agent lifecycle API — daemon Phase 2 supervision of any hub agent #2210 invariant.
  • audio_client.py — process_voice_input's finally block now joins the TTS thread unbounded instead of the old ~3s timeout, and keeps capture muted when a device timed out.
  • security.py:904 — message reworded to "Auto-approving overwrite of %s (no interactive requester on …".
  • CLI and SDK both pinned to claude-sonnet-5.

Validation. Every test file this PR touches, plus test_starter_skills.py: 299 passed, 15 skipped, 2 failed — and both failures reproduce identically on untouched main (ed90d9ee3). One is test_speak_text_survives_a_consumer_that_never_reads, which trips the conftest network guard via pytest-asyncio's Windows event-loop self-pipe; the other passes in isolation and is an ordering artifact. Neither is a regression from this PR.

The mic-mute test slept 0.3s and then demanded more than three samples of
the mic's paused state. On a loaded macOS runner the sampler thread got
scheduled three times in that window, so the run went red while the
invariant it guards -- mic paused for the whole utterance, resumed once --
was actually satisfied.

The TTS double now signals an event once it has sampled enough times, and
the test waits on that instead of sleeping.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

The macOS smoke failure was a flaky test, not a defect in the fix — the mic-mute assertion counted how many times a background thread happened to run during a fixed 0.3s sleep, and a loaded runner scheduled it three times instead of the four the test demanded. Everything it actually guards (mic paused for the whole utterance, resumed exactly once afterwards) held in that failing run. The double now signals when it has sampled enough and the test waits on that, so the result no longer depends on runner load.

🔍 Technical details

tests/unit/test_talk_playback_mute.py::test_mic_is_paused_for_the_whole_utterance_and_resumes_after[process_voice_input] failed on assert len(tts.mic_paused_samples) > 3 with [True, True, True] — all three samples paused, mic.resumes == 1.

_PlayingTTS now sets a sampled_enough event once SAMPLES_THAT_PROVE_PLAYBACK samples have accumulated; the test waits on it (10s cap) in place of time.sleep(0.3), and the count assertion is expressed against that same constant. The assert runner.is_alive() check the sleep also served is unchanged — it still runs after the wait, so "speak_text returned while audio was still playing" is still caught.

Ran the module 5× locally: 16 passed each time, and ~1.8s instead of ~3.2s.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

The TTS queue in process_voice_input lost its bound, but the helper right below it still documents itself as bounded and still carries the drop-when-full path that depended on that bound. Was the unbounding deliberate?

If it was, the except queue.Full branch and the speech_dropped latch can never fire again, and the docstring above them now says the opposite of what the code does — so both should go rather than sit there looking live.

Low stakes either way, which is why I'm asking rather than calling it a defect: nothing in the tree calls this method, and speak_text — the path gaia talk actually takes — keeps its bound and explains inline why. That's also what makes the two read as an oversight rather than a decision.

One thing that makes it easy to miss: the test pinning that guard asserts against the source text of the method and patches queue.Queue to a size of 1, so it stays green whether or not the real queue is bounded.

🔍 Technical details

src/gaia/audio/audio_client.py:245 is now text_queue = queue.Queue(); main has queue.Queue(maxsize=100) there. Changed in 8e959ee6.

The speak() docstring at :256 still reads "The queue is bounded, so a consumer that died takes the LLM stream down with it once 100 chunks pile up." With no maxsize, text_queue.put(item, timeout=5.0) at :264 cannot raise queue.Full, so :266-267 and the speech_dropped latch at :251/:261 are unreachable.

speak_text at :467 keeps queue.Queue(maxsize=100), with the note that the join below it is unbounded on purpose because it's the mic-mute window.

tests/unit/test_mic_failure_reporting.py:366-368 asserts "speech_dropped = False" in source; :414 monkeypatches gaia.audio.audio_client.queue.Queue to real_queue_cls(maxsize=1).

No doc change needed — docs/spec/audio-client.mdx:142 describes the playback-duration bound, not this queue.

# Conflicts:
#	src/gaia/security.py
`8e959ee62` dropped `maxsize=100` from `process_voice_input`'s TTS queue
while leaving the docstring saying the queue is bounded and the
`except queue.Full` branch below it in place. Without a maxsize that
branch cannot fire, so the drop-on-full guard was retired silently —
`speak_text`, the path `gaia talk` takes, kept its bound and its inline
reason, which is what makes this read as an oversight. Bound restored.

The test that pinned the guard could not catch this: it asserts the
latch variable appears in the method's source, which stayed true. It now
also asserts the queue is constructed with a maxsize, and fails when the
bound is removed. `process_voice_input` is the processor the audio-client
spec tells integrators to pass to `start_voice_chat`, so the docstring
being true is not academic.

Merge resolution in `talk/sdk.py`: main retired the openai/litellm
providers (amd#3899) and reworded `use_chatgpt`'s comment; this branch added
`claude_model` and `base_url`, which main does not have. Kept all three.

That retirement also made two talk-flag tests wrong: `--use-chatgpt` no
longer reaches any client, it exits with migration guidance. The flag is
out of the wiring table, and its own test now asserts the refusal names
both the removal and Lemonade as the way forward, with and without
`--model`. The talk guide and CLI reference still advertised the flag as
working, contradicting `docs/sdk/sdks/llm.mdx`; both now describe it as
removed.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Answering the open question: the unbounding was not deliberate, and it had retired a guard. Fixed, along with two things the main merge broke.

process_voice_input's TTS queue has its bound back. queue.Full cannot be raised without a maxsize, so dropping it silently switched off the whole drop-on-full path while leaving the docstring describing behaviour the code no longer had. speak_text — the path gaia talk actually takes — kept its bound and its inline reason in the same change, which is what makes this an oversight rather than a decision.

The test that guarded it could not have caught this, exactly as you said. It asserted the latch variable appears in the method's source, which stayed true the whole time. It now also asserts the queue is built with a maxsize, and I verified it fails when the bound is removed.

Worth keeping in mind for the "nothing calls it" framing: docs/spec/audio-client.mdx tells integrators to pass this method to start_voice_chat, so it is public surface. That is why I restored the guard rather than deleting it and the docstring.

Two things main broke that needed deciding, not just merging: --use-chatgpt no longer exists, so a test asserting it reaches the clients was pinning a contract that is gone — and the talk guide and CLI reference were still advertising the flag as working.

🔍 Technical details

1. The bound (src/gaia/audio/audio_client.py:245). git log -S puts the change in 8e959ee62 ("address maintenance findings for PR #3616"), which took queue.Queue(maxsize=100) → queue.Queue() in process_voice_input only. speak_text:467 still has maxsize=100. Restored, with a one-line comment naming what depends on it.

2. The test (tests/unit/test_mic_failure_reporting.py). Kept test_the_real_guard_is_latched and added test_the_guarded_queue_is_actually_bounded, which regexes the text_queue = queue.Queue(...) construction and asserts maxsize= is in it. Confirmed both directions: passes as-is, and with the bound removed fails with process_voice_input's text_queue lost its bound, so the queue.Full branch below it can never fire. Also corrected that class's docstring, which claimed nothing calls the method — the spec points integrators at it.

3. Merge conflict, src/gaia/talk/sdk.py. One conflict. main reworded use_chatgpt's comment to "Removed; True raises migration guidance" (#3899); this branch added claude_model and base_url, neither of which exists on main. Kept all three — the two new fields are this PR's "every flag reaches the thing that uses it" work, and DEFAULT_CLAUDE_MODEL is still imported and still the single source for both.

4. --use-chatgpt (tests/unit/test_cli_talk_flags.py). Two failures after the merge, both real and both in this PR's own surface: cli.py now calls parser.error(REMOVED_PROVIDER_MESSAGE) and exits 2, so the flag reaches no client at all.

  • Removed the --use-chatgpt row from the flag-wiring table, with a comment saying why rather than leaving a gap.
  • Replaced test_use_chatgpt_without_model_is_refused (which asserted the old --use-chatgpt needs --model message on stdout) with test_use_chatgpt_is_refused_with_migration_guidance, parametrised with and without --model, asserting on stderr that the message names the removal and Lemonade as the way forward. A --model value cannot rescue a provider that no longer exists, so both shapes must refuse.

5. Docs. docs/guides/talk.mdx still showed gaia talk --use-chatgpt --model gpt-4o as a working example and told users it needs OPENAI_API_KEY; docs/reference/cli.mdx listed it as a live option and said --model is "Required with --use-chatgpt". Both contradicted docs/sdk/sdks/llm.mdx, which already said the flag is retired. Both now say removed and point at Lemonade + --base-url.

Validation. All eight suites this PR names, plus test_mic_failure_reporting.py: 108 passed. util/lint.py --black --isort --fix and --flake8 clean. util/check_doc_links.py --internal-only passes. No conflict markers; every touched .py AST-parses.

The unbounded-tts_thread.join() comment note from the earlier review is still the one open nit — left alone, since the reasoning for it is already inline at the join.

@github-actions

Copy link
Copy Markdown
Contributor

🟡 The new test_use_chatgpt_is_refused_with_migration_guidance will fail in CI for the ["--use-chatgpt"] parametrized case.

When --model is not passed, argparse supplies None (confirmed: parent_parser.add_argument("--model", default=None, ...)), so the early guard in async_main fires with a different message than REMOVED_PROVIDER_MESSAGE. That message reads "gaia talk --use-chatgpt needs --model …" — it contains neither "use_chatgpt" (underscore, which the test asserts) nor "removed" (which the test also asserts). The test's second parametrized case ["--use-chatgpt", "--model", "x"] skips the guard and correctly reaches REMOVED_PROVIDER_MESSAGE, so only the no---model case breaks.

Fix: remove the early ValueError in cli.py:764-768 — REMOVED_PROVIDER_MESSAGE already covers both cases clearly and satisfies all three assertions.

🔍 Technical details

src/gaia/cli.py:764:

if kwargs.get("use_chatgpt") and not kwargs.get("model"):
    raise ValueError(
        "gaia talk --use-chatgpt needs --model <openai-model-id> "
        "(for example --model gpt-4o); the default model is a local "
        "Lemonade model the OpenAI API does not serve."
    )

tests/unit/test_cli_talk_flags.py (new file) asserts both "use_chatgpt" and "removed" are in the error message. Neither appears in the early ValueError message above. The check is also logically redundant: create_client(use_openai=True, model=None) will raise REMOVED_PROVIDER_MESSAGE ("The openai/litellm providers and use_openai/use_chatgpt options were removed …"), which satisfies all three assertions.

Simplest fix — drop the guard entirely:

-        if kwargs.get("use_chatgpt") and not kwargs.get("model"):
-            raise ValueError(
-                "gaia talk --use-chatgpt needs --model <openai-model-id> "
-                "(for example --model gpt-4o); the default model is a local "
-                "Lemonade model the OpenAI API does not serve."
-            )
-
         config = TalkConfig(

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Sep 26, 2026
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Sep 26, 2026
…#4310)

`gaia prompt "hi" --use-claude` and `--base-url http://remote…` still
answered from local Lemonade, so users thought they had a Claude or
remote answer when they didn't. Twenty subcommands also accepted eight
backend flags they never read (e.g. `gaia kill --use-claude --stream`).
Now `prompt` honours `--base-url`, `--use-claude` and `--claude-model`.
Every command accepts only the flags its handler reads.

**Behaviour change:** a flag that used to be accepted and silently
ignored is now a usage error (exit 2). For example, `gaia kill
--use-claude`, `gaia prompt --max-steps 3` and `gaia llm --use-claude`
now fail with "unrecognized arguments". No in-tree script, CI workflow
or doc used any of these combinations.

- Who accepts what: `--use-claude`/`--claude-model` go to chat, prompt
and talk. `--model` goes to those plus llm and email. `--base-url` goes
to those plus api, stats and mcp start. `--max-steps`, `--list-tools`
and `--stream` are chat-only. The table is under Global Options in the
CLI reference.
- `gaia email` keeps `--trace`: amd#3346 wires it up, and removing it here
would break that PR.
- Overlaps with amd#3616 (talk flags) in one line, the `--claude-model`
default, which moved into the new Claude parent. Whichever merges second
needs a one-line rebase. Talk keeps the backend flags that amd#3616 makes
it read.

## Test plan
- [x] `pytest tests/unit/cli/test_cli_backend_flags.py`: 102 failed on
main, 128 passed + 1 skipped with the fix. Covers non-agent commands
rejecting the flags with exit 2, each command keeping the flags it
reads, and `prompt --base-url` reaching `create_client(base_url=…)`
through `main()`.
- [x] Neighbouring CLI/daemon/installer/config/llm unit tests, run with
isolated `GAIA_HOME`/`GAIA_DAEMON_HOME`: 861 passed, 2 skipped
- [x] black, isort and pylint pass on the changed files;
`util/check_doc_links.py` passes
- [x] `gaia kill --use-claude` exits 2; `gaia prompt hi --list-tools` is
rejected
- [x] `gaia prompt "say ok" --base-url http://127.0.0.1:9/api/v1
--no-lemonade-check` now tries the given URL instead of localhost
- [ ] `gaia prompt "hi" --use-claude` against the real Claude API (the
local venv lacks `anthropic` and a key)

Fixes amd#4217

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
…d parsers

`main` moved `--use-claude`/`--claude-model` off `parent_parser` onto a
dedicated `claude_parser` while this branch was making every talk flag reach
the client that uses it. The merge keeps `main`'s parser split and re-applies
this branch's single source for the Claude default, so `gaia talk --use-claude`
and `TalkSDK(TalkConfig(use_claude=True))` still land on the same model and
the CLI reference matches what `--help` prints.

Also drops the `gaia talk --use-chatgpt needs --model` guard: amd#3899 retired the
provider, so `main()` refuses the flag before that branch can run and its
advice ("pass --model") names a fix that no longer exists.
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 26, 2026
Merged via the queue into amd:main with commit e89162a Sep 26, 2026
53 of 55 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the fix/talk-and-ui-product-defects branch September 26, 2026 08:46
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Oct 4, 2026
…md#4662)

Every open PR shows these two failures; this clears them. The macOS one
is fixed here; the Windows one is fixed by amd#4585, so the smoke jobs go
green once both merge.

- **macOS, `test_memory_turn_recall`:** an audio test imported the
Whisper ASR module, and that import loaded torch. Once torch is loaded,
macOS has two OpenMP runtimes in the process (torch's and faiss's), so
memory recall refuses every faiss search for the rest of the run. torch
and whisper are now imported only when an ASR is actually created. The
recall test runs and passes; it isn't skipped. amd#4580 handles this
failure by skipping the test, so drop that half of amd#4580 when this
merges.
- **Windows, `test_resolves_direct_shebang_posix`:** the test faked
Linux by patching `sys.platform` for the whole process. pyfakefs
teardown then took the POSIX path and called `os.getuid`, which doesn't
exist on Windows. amd#4585 now patches only the uninstall module's view of
the platform, so this PR doesn't touch it.

The macOS failure dates from amd#4061 (Sep 28), which added the recall test
after the torch-loading audio test from amd#3616. The smoke job runs with
`-x`, so earlier failures hid it until amd#4562 fixed those on Oct 2.

## Test plan
- [x] New `test_importing_whisper_asr_does_not_load_torch` fails on main
and passes here
- [x] Locally on macOS, all audio and memory tests in CI order: 433
passed, `test_memory_turn_recall` included
- [x] Locally on macOS, every unit test up to and including the recall
test: torch never loads, and recall passes. The 13 failures are local
env noise (CLI binaries not on PATH, pip frontends); none import the
audio module
- [ ] CI: "Unit Tests (macOS smoke)" passes `test_memory_turn_recall.py`

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents audio Audio (ASR/TTS) changes cli CLI changes documentation Documentation changes llm LLM backend changes performance Performance-critical changes rag RAG system changes security Security-sensitive changes talk Talk agent changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Model selection does not work with gaia talk

2 participants