Skip to content

fix(llm): retire providers that discard tool calls - #3899

Merged
kovtcharov-amd merged 5 commits into
amd:mainfrom
kovtcharov:codex/3811-retire-broken-providers
Sep 24, 2026
Merged

kovtcharov-amd merged 5 commits into
amd:mainfrom
kovtcharov:codex/3811-retire-broken-providers

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

The direct OpenAI and LiteLLM adapters silently discarded tool calls, making capable models appear unable to act. Remove those adapters and route local/on-prem model configuration through Lemonade. Legacy provider names and use_openai/use_chatgpt flags now fail with migration guidance before inference; they never silently select another backend. The OpenAI HTTP-client dependency stays.

Closes #3811. Related to #3630. Direct imports of the removed classes are an intentional API break. The docs and packaged chat changelog explain migration.

Test plan

  • 125 tests passed: migration, factory, Claude, cloud models, native tool calls, and packaged chat CLI.
  • Packaging/URL checks: 11 passed. Formatting/import checks and scoped lint passed. Code and architecture reviews approved.
  • Actual CLI: python -m gaia.cli llm --use-chatgpt hello exits 2 with “providers … were removed because they discarded tool calls” and the gateway-migration link.
  • Chat CI runs the packaged regression and now triggers on shared LLM changes.
  • Hosted CI and human review.
🔍 Technical details

Validation command (with flagship source available):

PYTHONPATH=hub/agents/gaia/python python -m pytest tests/unit/test_removed_llm_providers.py tests/unit/test_llm_client_factory.py tests/unit/test_claude_provider.py tests/unit/test_lemonade_cloud_models.py tests/unit/agents/test_parallel_tool_calls.py hub/agents/chat/python/tests/test_provider_migration.py -q

The broad legacy tests/test_sdk.py suite has 17 failures reproduced identically on base 481a0972; these are not counted as passes. Its separate real-server SDK suite skipped because it hardcodes unavailable port 13305. No live model-quality claim is made. The context-retention judge is currently blocked by its weekly usage limit.

@github-actions github-actions Bot added documentation Documentation changes dependencies Dependency updates devops DevOps/infrastructure changes talk Talk agent changes chat Chat SDK changes llm LLM backend changes cli CLI changes tests Test changes performance Performance-critical changes agents labels Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This removes the direct OpenAI and LiteLLM backends — which dropped tool calls and made capable models look unable to act — and turns every legacy way of asking for them into a loud, actionable error instead of a quiet switch to some other backend. The retained Lemonade and Claude paths are untouched, and the migration error is wired into all four entry points a user can reach it from (factory, SDK config, base agent, CLI).

Two things worth your attention before merge, neither of which breaks anything at runtime:

  • A couple of docs still tell people to set an OpenAI API key. The agent configuration walkthrough and the environment-variable reference both still list it as a cloud-provider key, even though nothing reads it now. One of them sits two lines below a line this PR already edited.
  • The LLM client spec lost more than the removed adapters. The rewrite drops roughly 1,200 lines, including the still-accurate guidance for pointing GAIA at a third-party OpenAI-compatible server, plus the capability table, the streaming/embedding/vision examples, and the troubleshooting section for connection and model-not-found errors. That capability still works in code; the new page replaces the how-to with a caveat. Worth confirming that's the intent rather than collateral from the trim.

Real-world evidence

No evidence-bundle.md was produced for this PR, so nothing was exercised in this review lane and my verdict rests on static review plus what the description reports.

The description does carry CLI evidence matched to the changed surface — python -m gaia.cli llm --use-chatgpt hello exiting 2 with the "discarded tool calls" message and the migration link — which is the right artifact for a CLI-visible behaviour change. It also discloses honestly that 17 failures in the legacy SDK suite reproduce identically on the base commit and that no live model-quality claim is made. I could not re-run any of it here (no pytest in this environment), so I am relaying those claims, not confirming them.

The default Lemonade inference path is unchanged by this diff, so the missing agent-eval judge run noted in the description does not look like a gap for this change specifically — but that is a judgement from reading the diff, not from a scorecard.

🔍 Technical details

Issues

🟡 Spec rewrite deletes content unrelated to the removed adapters (docs/spec/llm-client.mdx)

The file goes 1361 → 119 lines. Beyond the OpenAI/LiteLLM material, it removes: the per-provider capability matrix, usage examples 1–10 (streaming, embeddings, vision, model lifecycle, remote server, system prompts), the entire "Third-Party LLM Integration" section (required OpenAI-compatible endpoints, LEMONADE_BASE_URL configuration, URL-normalisation note), and the troubleshooting accordions. The third-party integration path is still implemented — LemonadeClient normalisation is unchanged — and the new text replaces its how-to with "a generic OpenAI-compatible server is not a drop-in replacement". Both statements can be true, but a user who followed that section now has no page to go to. Suggest either keeping the Lemonade/Claude reference material or moving it to the SDK guide in the same change.

🟢 Stale OpenAI key guidance in two docs

docs/sdk/core/agent-system.mdx:362 — inside the same config block this PR edited at line 353:

    # API key is read from environment: ANTHROPIC_API_KEY

docs/sdk/configuration.mdx:32 still has export OPENAI_API_KEY="sk-..." under "API Keys (for cloud providers)" — no provider reads it after this change; drop that line. (docs/glossary.mdx:340 is a generic definition of the variable and is fine as-is.)

🟢 Dead use_chatgpt branches left behind

Now that Agent.__init__ raises on a true value, the downstream handling is unreachable-with-True: src/gaia/agents/base/agent.py:1002 (if not (use_claude or use_chatgpt or skip_lemonade)) and :1092 (pass-through), hub/agents/chat/python/gaia_agent_chat/agent.py:320 and :434, and hub/agents/chat/python/gaia_agent_chat/app.py:994. Harmless, but they read as live logic to the next person. Worth one cleanup pass.

🟢 Subprocess CLI test overrides PYTHONPATH to src/ only (tests/unit/test_removed_llm_providers.py:2835)

The root conftest.py also pins hub/agents/*/python; the child process gets only src. It passes today because parser.error fires before any agent dispatch, but it will fail confusingly if build_parser() ever pulls in a hub agent. Adding the hub paths to the child env would make it robust.

Strengths

  • The error is unavoidable, not advisory. REMOVED_PROVIDER_MESSAGE is raised from the factory, AgentSDK, Agent.__init__, initialize_lemonade_for_agent, and both CLIs — and test_retired_selection_fails_before_provider_import asserts it fires before importlib.import_module, so rejecting a retired name never needs an optional dependency installed. That is exactly the fail-loudly contract in CLAUDE.md, and the message names what failed, what to do, and where to read more.
  • The regression test hits the real CLI, not the module: test_real_cli_returns_actionable_migration_error spawns python -m gaia.cli llm --use-chatgpt hello and asserts exit code 2 plus both the reason and the migration anchor in stderr. The packaged chat agent gets its own equivalent.
  • The doc URL keeps the /docs/ prefix in both the runtime string (src/gaia/llm/factory.py:19) and the hub README, so the test_amd_gaia_urls.py guard from [Bug]: Google Connector docs URL broken #1058 stays green, and #gateway-migration is a real anchor in docs/sdk/sdks/llm.mdx.
  • CI trigger widened with the blast radius — adding src/gaia/llm/** to test_chat_agent.yml means the next shared-LLM change can't skip the packaged chat regression.
  • Hub package doc surfaces are in sync: the chat package has only README.md and the new CHANGELOG.md (no SPEC.md/SKILL.md), and both describe the migration.

Kalin Ovtcharov added 2 commits September 18, 2026 19:17
# Conflicts:
#	.github/workflows/test_chat_agent.yml
The provider-removal trim had cut the LLM client spec from ~1,360 lines to
~120, taking the Lemonade/Claude reference, capability table, usage examples
and troubleshooting with it. Restore that material, removing only what
described the retired OpenAI/LiteLLM providers, and correct the third-party
section: a generic OpenAI-compatible server is not a drop-in for Lemonade.

Also stop documenting OPENAI_API_KEY (nothing reads it), remove use_chatgpt
checks that can no longer be true after the migration error, and let the
real-CLI regression inherit the full test PYTHONPATH.
@kovtcharov

Copy link
Copy Markdown
Contributor Author

The LLM client spec is back to full length: the Lemonade/Claude reference, capability table, examples, and troubleshooting are restored, with only the retired OpenAI/LiteLLM material removed. The branch is merged with current main, the stale OpenAI key docs are gone, and the dead use_chatgpt checks are cleaned up.

One restored section needed a correction. The old third-party page said any OpenAI-compatible server works as a drop-in. The current client also calls Lemonade's model-load API before a local request, so a plain OpenAI-compatible server fails there. The restored section keeps the endpoint shapes, LEMONADE_BASE_URL setup, URL normalisation, and troubleshooting, and now points users at a Lemonade server that fronts their model.

🔍 Technical details

Merge 0e14fcf0 (origin/main into the branch): the only conflict was .github/workflows/test_chat_agent.yml. I kept both sides: this PR's src/gaia/llm/** trigger plus main's new src/gaia/web/** and test-file triggers, in both the push and pull_request path lists.

Fixes in 5b26afe6:

  • 🟡 docs/spec/llm-client.mdx: rebuilt from the pre-PR version (481a0972), now 1303 lines. It drops the OpenAI column, OpenAIProvider, the OpenAI examples/tests/imports and the use_openai selection logic, and keeps this PR's migration, native tool-call and error-boundary sections. A few restored lines were wrong about the current code, so I corrected them:
    • Claude's default model is DEFAULT_CLAUDE_MODEL, and get_performance_stats is ✓ for Claude (it returns last-call usage).
    • LemonadeProvider.generate goes through chat.
    • The troubleshooting "Problem" lines now describe symptoms. The error strings they quoted don't exist in the code.
    • Third-party section: the opening claim is now a <Warning> saying _ensure_model_loaded calls /load. I dropped the "Compatibility Checklist" because it said OpenAI endpoints alone are enough and that lifecycle methods raise NotSupportedError on third-party servers; neither is true. I also dropped the "With Agent" example, which used a non-existent Agent(name=, model=) / self.llm API.
  • 🟢 Stale OPENAI_API_KEY: fixed docs/sdk/core/agent-system.mdx with your suggestion, and removed the line from docs/sdk/configuration.mdx. docs/cpp/integration.mdx and docs/glossary.mdx are left alone because they don't describe the Python providers.
  • 🟢 Dead use_chatgpt branches: removed at base/agent.py (the Lemonade-init condition and the AgentConfig pass-through), gaia_agent_chat/agent.py (use_local_llm), and gaia_agent_chat/app.py (parse_args already exits on the flag). Kept the use_chatgpt=config.use_chatgpt pass-through into super().__init__ in gaia_agent_chat/agent.py. It isn't dead: it's the only route by which ChatAgentConfig(use_chatgpt=True) reaches the migration error, and removing it would make that flag silently do nothing. No tests referenced the removed lines.
  • 🟢 Subprocess PYTHONPATH: test_real_cli_returns_actionable_migration_error no longer overrides PYTHONPATH. It now inherits the root conftest's pinned path (src plus hub agent roots), so it can't drift from the conftest logic.

Tests: 130 passed / 1 skipped across the removed-provider, factory, Claude, cloud-model, parallel-tool-call, packaged-chat migration, email local-LLM and URL-guard suites. 1026 passed / 50 skipped across hub/agents/chat/python/tests, tests/unit/agents, and tests/test_chat_agent.py. Internal doc links: 997/997 OK. Doc code blocks parse. black/isort clean.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Refreshed this branch against current main so it can merge again — the branch had fallen far enough behind that GitHub could no longer compute a merge.

The update was a clean merge: nothing was resolved by hand, and no commit on this branch was rewritten. CI now runs against an up-to-date base.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 24, 2026
Merged via the queue into amd:main with commit 60656af Sep 24, 2026
52 checks passed
pull Bot pushed a commit to bhardwajRahul/gaia that referenced this pull request Sep 24, 2026
…st (amd#4183)

`main`'s Unit Tests lane is red on py3.10, py3.12 and macOS, and has
been since amd#3899 merged. That PR retired the OpenAI provider and deleted
`src/gaia/llm/providers/openai_provider.py`, but left a test importing
it. The import sits inside the test function and runs for *both*
parameters, so the Claude case fails too — it is two failures, not one.
Every PR opened against `main` since then inherits a red lane that has
nothing to do with its own change.

This keeps the Claude case (the only cloud provider left) and drops the
OpenAI half, and clears the same retirement's leftover file references
in `CLAUDE.md` and three agent docs so they stop pointing at a file that
no longer exists.

## Test plan

- [x] `python -m pytest tests/unit/test_chat_system_prompt_owner.py -q`
— 15 pass. On `origin/main` the same command gives 2 failed / 14 passed:
  ```
FAILED test_cloud_provider_receives_native_system_prompt[openai] -
ModuleNotFoundError: No module named
'gaia.llm.providers.openai_provider'
FAILED test_cloud_provider_receives_native_system_prompt[claude] -
(same)
  ```
- [x] `python util/lint.py --black --isort` — pass.
- [x] `grep -rn openai_provider CLAUDE.md .claude/agents/ tests/ src/` —
no remaining references.
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Sep 24, 2026
main is broken: `test_chat_system_prompt_owner.py` (added by amd#3864)
still imports `OpenAIProvider` directly, which amd#3899 deleted as an
intentional API break. amd#3899's own validation command never ran this
file, so the collision only showed up once both merged.

Every non-Claude cloud model now goes through `LemonadeProvider` — its
wire shape (system prompt folded into `messages[0]`) is exactly what
this test needs to exercise, so the fix swaps the mock target from a raw
OpenAI SDK client to `LemonadeProvider._backend` instead of
reintroducing the deleted class.

## Test plan
- [x] `python -m pytest tests/unit/test_chat_system_prompt_owner.py -q`
— 16 passed
- [x] `python -m pytest tests/unit/ -k "chat_sdk or system_prompt or
lemonade_provider or test_claude_provider or
test_removed_llm_providers"` — 134 passed
- [x] `git grep` confirms no other references to the removed
`OpenAIProvider`/`openai_provider` module remain

Co-authored-by: f <f@f>
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Sep 25, 2026
Replicates amd#4063 (kovtcharov/gaia fork, push access blocked) onto a
branch this session can push to.

Cloud reasoning models such as `fireworks.deepseek-v4p1-flash` count
their thinking against the agent's per-reply output cap. That cap was
fixed at 8,192 tokens, which was sized for a local 32K context. On
TheRock coding tasks, all three failed runs ended with a reply at
exactly 8,192 tokens. Lemonade cloud models now get 32,768 output
tokens, the same default Claude Code uses. Local models keep 8,192.
Callers can set their own cap with a new optional `max_output_tokens` on
the agent.

- Replies that got cut off already continue since amd#4054, but each
cut-off costs an extra round trip and drops thinking. This cuts off far
fewer replies.
- Claude keeps its current default. An explicit cap now reaches it, with
one exception: Claude's existing 8,192 minimum still raises any smaller
explicit value.

One change beyond the original: `main` removed the openai/litellm
providers (amd#3899), so `use_chatgpt` now raises a migration error at
construction. The original PR's OpenAI request-cap test exercised that
removed provider and has been dropped, along with a `use_chatgpt` term
in the cap expression that can never be True. No other content changes
beyond conflict resolution against current main.

## Test plan
- [x] `pytest tests/unit/test_agent_max_output_tokens.py
tests/unit/test_tool_call_priority.py` — 43 passed. These check the JSON
body sent to Lemonade and expect `max_completion_tokens` 32768 for a
cloud model and 8192 for a local model, plus an explicit override, a
model switch mid-session, a custom provider flagged by catalog metadata,
and the Claude request kwargs.
- [x] `pytest tests/unit/agents` — 1422 passed, 50 skipped; identical on
unmodified `main`.
- [x] `python util/lint.py --black --isort` clean.
- [ ] `gaia eval agent --category tool_selection`

Carried over from the review on amd#4063, not addressed here: the cap is
computed twice (once into `AgentConfig.max_tokens` at init, once per
call in `_max_output_tokens()`), so memory-distillation and builder
paths can disagree with the main loop for a catalog-flagged custom
provider; and the streaming call sites have no test.

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Sep 26, 2026
`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 added a commit to kovtcharov/gaia that referenced this pull request Sep 26, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents chat Chat SDK changes cli CLI changes dependencies Dependency updates devops DevOps/infrastructure changes documentation Documentation changes llm LLM backend changes performance Performance-critical changes talk Talk agent changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(llm): remove the openai and litellm providers — redundant, and they drop tool calls

2 participants