Repository navigation
fix(cli): accept backend flags only on commands that honour them - #4310
Conversation
`gaia prompt --use-claude` and `--base-url` were accepted and then ignored, so the answer came from local Lemonade while the user believed it came from Claude or a remote server. Twenty subcommands inherited eight agent-backend flags from one shared parent parser, and most of them never read those flags. - Split the shared parent into logging/common flags for every command plus model, base-url, Claude, trace, and agent-loop parents. Each command now gets only the flags its handler reads. An unread flag is a usage error (exit 2) instead of a silent no-op. - `gaia prompt` now passes --base-url to the Lemonade client, and --use-claude/--claude-model build a Claude client. - `gaia email` keeps --trace for the in-flight daemon-relay trace fix. Fixes amd#4217
Verdict: Approve with suggestionsThis makes One thing worth fixing before merge: Real-world evidenceNo The one gap the author already calls out: 🔍 Technical details🟡
|
…mand `gaia llm --use-chatgpt` printed a bare "unrecognized arguments" instead of the migration message explaining where the provider went, so a user following an old doc or script got no hint about what to do next. Same for `gaia email`. Splitting the backend flags into per-capability parents put the hidden `--use-chatgpt` on the Claude parent, which only chat, prompt and talk take. But `--use-chatgpt` is not a backend capability — it names a REMOVED provider and exists only so main() can answer with the migration guidance. It now has its own parent, attached to every command that picks an LLM backend: chat, prompt, talk, llm and email. Commands that never pick a provider (kill, stats, api …) still reject it as a plain usage error, which is the behaviour this PR intends. Caught by CI on Linux py3.10/py3.12 and the macOS smoke job via tests/unit/test_removed_llm_providers.py. Parametrized the new coverage across all five commands so a later parser change can't drop the message from one of them unnoticed.
# Conflicts: # docs/reference/cli.mdx
|
Fixed the CI regression, and
🔍 Technical detailsRoot cause. Splitting the backend flags into per-capability parents put the hidden Fix. It now has its own Verified on the real CLIRun against this checkout ( The last line is the intended behaviour, not a miss — Tests
Added to
Without the fix: 3 fail ( Merge
Full sweep Still open from the reviewThe 🟡 |
…g another (amd#4334) `gaia email --base-url <url>` used to health-check the given Lemonade server and then triage on a different one: whatever the daemon's email sidecar was already using. So users pointing email at another server got a passing check and requests to the wrong place. The flag now fails with exit 2 and says what works: restart the daemon with `LEMONADE_BASE_URL` set. The email agent already honours that variable. Rejecting the flag was one of the two options in the issue. Wiring it through would mean adding a per-request server field to the frozen sidecar query contract, and letting any daemon client repoint the email agent's inference. That's a design decision, so this PR doesn't make it. Overlaps: - amd#4310 lists `email` as accepting `--base-url`. With this PR it's still accepted at parse time and then rejected in the handler, so that table needs a note if both merge. - amd#3346 adds a row to the same `gaia email` options table. Expect a trivial doc conflict there. ## Test plan - [x] `python -m pytest tests/unit/test_email_cli.py -q`: the new test fails on `main` (1 failed, 3 passed) and passes on this branch (4 passed) - [x] `python -m pytest tests/unit/cli tests/unit/test_email_cli.py tests/unit/test_email_autonomy_cli.py tests/unit/test_amd_gaia_urls.py tests/unit/test_email_sidecar_relay.py -q`: 348 passed, 7 skipped - [x] `gaia email --base-url http://x:1/api/v1 -q hi` exits 2 with the guidance, and no daemon or Lemonade call is made - [x] black, isort, pylint (repo config) on `src/gaia/cli.py`; `python util/check_doc_links.py --internal-only` Fixes amd#4312 --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
gaia prompt "hi" --use-claudeand--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). Nowprompthonours--base-url,--use-claudeand--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 3andgaia llm --use-claudenow fail with "unrecognized arguments". No in-tree script, CI workflow or doc used any of these combinations.--use-claude/--claude-modelgo to chat, prompt and talk.--modelgoes to those plus llm and email.--base-urlgoes to those plus api, stats and mcp start.--max-steps,--list-toolsand--streamare chat-only. The table is under Global Options in the CLI reference.gaia emailkeeps--trace: fix(email): make --trace write a real trace on the daemon-relay path #3346 wires it up, and removing it here would break that PR.--claude-modeldefault, which moved into the new Claude parent. Whichever merges second needs a one-line rebase. Talk keeps the backend flags that fix(talk,ui): mic echo, dropped talk flags, server stdin hang #3616 makes it read.Test plan
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, andprompt --base-urlreachingcreate_client(base_url=…)throughmain().GAIA_HOME/GAIA_DAEMON_HOME: 861 passed, 2 skippedutil/check_doc_links.pypassesgaia kill --use-claudeexits 2;gaia prompt hi --list-toolsis rejectedgaia prompt "say ok" --base-url http://127.0.0.1:9/api/v1 --no-lemonade-checknow tries the given URL instead of localhostgaia prompt "hi" --use-claudeagainst the real Claude API (the local venv lacksanthropicand a key)Fixes #4217