tests: cover OpenAI provider gaps — key resolution, Qwen XML salvage, stream edges#196
Open
ayobamiseun wants to merge 1 commit into
Open
tests: cover OpenAI provider gaps — key resolution, Qwen XML salvage, stream edges#196ayobamiseun wants to merge 1 commit into
ayobamiseun wants to merge 1 commit into
Conversation
… stream edges The Anthropic and Gemini providers each have a dedicated test module, but openai_provider.py was only covered incidentally by test_providers.py (complete/stream basics, param-fix retries) and test_provider_router.py (JSON-form tool-call salvage). This adds tests/test_openai_provider.py for what neither reaches: - resolve_api_key precedence (env over SecretStore) and _ensure_client (no-key RuntimeError; api_key/base_url plumbed to the SDK client) — mirroring the existing Anthropic/Gemini tests. - The Qwen/Hermes XML tool-call template (salvage path 1b: <function=...><parameter=...>), which had no coverage at all: happy path, verbatim free-text params, JSON coercion, unknown-name filtering, schema-less acceptance, multi-block renumbering, and _coerce_param. - Salvage gating inside complete()/stream(): salvage fires only when tools were offered and no structured calls came back; structured calls always win; streamed text deltas still surface live before the final turn swaps in the recovered calls. - Stream edge cases: unparseable accumulated args surface as _raw, parallel calls ordered by index, choice-less keep-alive chunks skipped, and the xAI/OpenRouter reasoning attribute variant. Full backend suite: 909 passed, 1 skipped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
tests/test_openai_provider.py(20 tests). The Anthropic and Gemini providers each have a dedicated test module (test_anthropic_provider.py,test_gemini_provider.py), butcoworker/providers/openai_provider.pywas only covered incidentally —test_providers.pyhandles complete/stream basics and the param-fix retries,test_provider_router.pyhandles JSON-form tool-call salvage. This fills what neither reaches:resolve_api_keyenv-over-SecretStore precedence and empty-profile fallbacks;_ensure_clientraising the no-keyRuntimeError;api_key/base_urlplumbed to the SDK client (the Ollama/compat path).<function=…><parameter=…>—openai_provider.py:296-307), which had no coverage anywhere: happy path per the template in the code comment, verbatim free-text parameters (file content with newlines), unambiguous-JSON coercion, unknown-name filtering, schema-less acceptance, multi-block renumbering, plus_coerce_paramdirectly.complete()/stream(): salvage fires only when tools were offered and no structured calls came back; structuredtool_callsalways win over tool-shaped text; streamed text deltas still surface live before the final turn swaps in the recovered calls.{"_raw": …}; parallel calls come out ordered by index with empty args as{}; choice-less keep-alive/usage chunks from compat servers are skipped; and thereasoningattribute variant (xAI/OpenRouter — distinct fromreasoning_content) on bothstream()andcomplete().Tests-only change; no production code touched. Fakes follow the established SDK-free
SimpleNamespacepattern fromtest_providers.py.Verification
No screenshots — no UI change.