Skip to content

fix(tests): stop importing OpenAIProvider after its removal - #4185

Merged
kovtcharov-amd merged 2 commits into
mainfrom
fix-test-chat-system-prompt-owner
Sep 24, 2026
Merged

kovtcharov-amd merged 2 commits into
mainfrom
fix-test-chat-system-prompt-owner

Conversation

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

main is broken: test_chat_system_prompt_owner.py (added by #3864) still imports OpenAIProvider directly, which #3899 deleted as an intentional API break. #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

  • python -m pytest tests/unit/test_chat_system_prompt_owner.py -q — 16 passed
  • 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
  • git grep confirms no other references to the removed OpenAIProvider/openai_provider module remain

#3899 deleted the direct OpenAI/LiteLLM adapters as an intentional API
break, but its own validation never ran this file, so main has been
broken since both merged: this test still imports OpenAIProvider
directly. Every non-Claude cloud model now goes through
LemonadeProvider, whose wire shape (system prompt folded into
messages[0]) is what the test actually needs to exercise, so swap the
mock target instead of the raw OpenAI SDK client.
@github-actions github-actions Bot added the tests Test changes label Sep 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This unbreaks main: a test added by #3864 still imported a provider class #3899 deleted, so the file failed at collection. Swapping the mock target onto the Lemonade path is the right call — reintroducing the deleted class to satisfy a test would have undone an intentional API break.

Two things worth a look before merge, neither blocking:

  • The test is named for the cloud path but is configured so the provider takes the local branch. The assertion it makes holds either way, so nothing is broken — but the name now promises coverage the setup doesn't give.
  • The non-Claude half of this test now largely repeats what the fixture-based tests at the top of the same file already prove, and it does so with a hand-built provider object rather than a real one. Consider whether that half still earns its place.

Real-world evidence

N/A — tests-only change, no user-visible surface; no evidence-bundle.md was produced for this PR. The PR's own test plan reports the file passing (16 passed) plus a 134-test neighbouring sweep, which is the right proof for a collection-error fix. I could not re-run it myself (no pytest in the review environment), so my verdict rests on static review of the mock against LemonadeProvider.chat — which checks out: the attributes the test stubs are exactly the ones that path touches, and the __new__-constructed object has no unset attribute that chat() reads before writing.

🔍 Technical details

Issues

🟢 Test name says "cloud", setup selects the local branch (tests/unit/test_chat_system_prompt_owner.py:127)

cloud_model_provider.return_value = None sends LemonadeProvider.chat down the local branch (lemonade.py:503), where it injects frequency_penalty / repeat_penalty. Since the system-prompt fold happens earlier (lemonade.py:491), the assertion passes either way — but a reader takes test_cloud_provider_receives_native_system_prompt at face value. Returning a provider name exercises the path the name claims.

🟢 Inline comment carries PR-body history (tests/unit/test_chat_system_prompt_owner.py:122-125)

CLAUDE.md → "Code Comments — Short or Skip": one short line, and don't reference the current fix or issue numbers inline — that context belongs in the commit body (where this PR already puts it well). Both nits fold into one edit:

        # Non-Claude models fold the system prompt into messages[0].
        provider._backend = Mock()
        provider._backend.cloud_model_provider.return_value = "openai"
        create = provider._backend.chat_completions
        create.return_value = {"choices": [{"message": {"content": "answer"}}]}

🟢 The lemonade parametrization is now near-duplicate coverage (tests/unit/test_chat_system_prompt_owner.py:105)

test_system_prompt_occurs_once_and_updates_without_old_copy (line 43) already asserts messages[0] == {"role": "system", …}, the single-occurrence count, and the update-replaces-old-copy behaviour — through the sdk fixture, which patches LemonadeClient and builds a real LemonadeProvider. The branch added here re-asserts the same three things against a __new__-constructed provider with hand-set private attributes. The Claude half still earns its place (it's the only test of the native system= parameter); the Lemonade half may be worth dropping in favour of the fixture path, which is both more realistic and less coupled to provider internals. Your call — keeping symmetric parametrization is a defensible reason to leave it.

🟢 Vestigial attributes on the Lemonade branch (tests/unit/test_chat_system_prompt_owner.py:116-117)

provider._client and provider._tool_name_map are only read by ClaudeProvider; LemonadeProvider ignores both. Moving them inside the if provider_name == "claude" branch makes the setup say what each provider actually needs. Cosmetic — skip if you take the previous suggestion.

Strengths

  • Fixed the collision at the right layer. The tempting move was to restore OpenAIProvider to make a red test green; routing through LemonadeProvider instead keeps fix(llm): retire providers that discard tool calls #3899's deletion intact and tests the wire shape users actually hit.
  • The test plan goes beyond the one broken file — the 134-test sweep across chat_sdk, lemonade_provider, and test_removed_llm_providers, plus the git grep for lingering references, is the check that catches a second instance of the same import.
  • Mock fidelity is right: {"choices": [{"message": {"content": …}}]} matches what LemonadeClient.chat_completions actually returns, so the stub proves the call is valid, not just that it was made.

# Conflicts:
#	tests/unit/test_chat_system_prompt_owner.py
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

#4183 landed in the meantime and fixed the same breakage a different way — it dropped the non-Claude case entirely rather than restoring it. Rebased this PR onto main and kept the fuller fix here, since it restores the test coverage #4183's version dropped (the OpenAI-compatible wire shape every non-Claude cloud model now goes through via LemonadeProvider).

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 24, 2026
Merged via the queue into main with commit c234e50 Sep 24, 2026
33 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the fix-test-chat-system-prompt-owner branch September 24, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant