Repository navigation
fix(talk,ui): mic echo, dropped talk flags, server stdin hang - #3616
Conversation
`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
Request changesThree good fixes here — the mic no longer hears the assistant, every The server-stdin fix also disables prompting for ordinary The self-hearing fix only covers one of the two voice entry points. Real-world evidenceNo 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 🔍 Technical details🔴 Critical1.
This contradicts the invariant documented on the class itself:
…plus 🟡 Important2.
🟢 Minor3. Overwrite auto-approval still logs "non-interactive context" ( 4. Two different 5. Unbounded joins can wedge a turn ( 6. Strengths
|
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
|
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. 🟡
Fix: change the 🔍 Technical detailsConflicting defaults across the same push:
The CLI overrides the class default, so end-users and SDK users get different behaviour from the same flags. Simplest fix in claude_model=kwargs.get("claude_model", "claude-sonnet-5"),and update 🟢 The join relies on |
# Conflicts: # src/gaia/rag/sdk.py
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]>
|
Verdict: Approve with suggestions The playback mute refactor is solid — mic is now paused before LLM generation starts and only resumed after Two things worth fixing before this lands: 🟡 The CLI default 🟢 The 🔍 Technical detailsclaude_model default divergence
speech_dropped dead code
|
…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]>
|
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. 🟡
The fix is to align the CLI fallback with the SDK/spec default ( Everything else looks correct:
🔍 Technical detailsInconsistency locations:
Suggested fix — change |
Co-Authored-By: Claude Opus 5 <[email protected]>
|
🟡 The CLI and the SDK dataclass use different default Claude models, and the spec docs reflect the inconsistency.
Pick one canonical default ( 🔍 Technical details
Note: there is also a second occurrence of the hard-coded old model at |
`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.
|
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
|
|
The one red check wasn't this PR's fault — the branch was 28 commits behind and missed a fix that already landed on 🔍 Technical detailsThe failure. "Test Gaia Agent" reported Findings verified fixed on head:
Validation. Every test file this PR touches, plus |
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.
|
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
Ran the module 5× locally: 16 passed each time, and ~1.8s instead of ~3.2s. |
|
The TTS queue in If it was, the Low stakes either way, which is why I'm asking rather than calling it a defect: nothing in the tree calls this method, and One thing that makes it easy to miss: the test pinning that guard asserts against the source text of the method and patches 🔍 Technical details
The
No doc change needed — |
# 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.
|
Answering the open question: the unbounding was not deliberate, and it had retired a guard. Fixed, along with two things the
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 Worth keeping in mind for the "nothing calls it" framing: Two things 🔍 Technical details1. The bound ( 2. The test ( 3. Merge conflict, 4.
5. Docs. Validation. All eight suites this PR names, plus The unbounded- |
|
🟡 The new When Fix: remove the early 🔍 Technical details
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."
)
Simplest fix — drop the guard entirely: |
…#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.
…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]>
gaia talkheard 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-urland--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 — andimport gaiacrashed in any process without a resolvable home directory. Also fixes the wrong port in.env.exampleand 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 onmainpass 16/16 therepython -m pytest hub/agents/chat/python/tests— 14 passed in 1.70sChatAgentwiring test fails if the validator'sinteractive_checkhook is removed — checked by removing itgaia talk --helplists every flag, andgaia talk --use-chatgptrefuses and exits 1import gaiain a subprocess with the home-directory variables removed succeeds