feat: add ChatCompletionsTransport + wire all default paths - #27083
Closed
Master-Rensei wants to merge 1 commit into
Closed
feat: add ChatCompletionsTransport + wire all default paths#27083Master-Rensei wants to merge 1 commit into
Master-Rensei wants to merge 1 commit into
Conversation
Add ChatCompletionsTransport for the default api_mode used by ~16 OpenAI-compatible providers (OpenRouter, Nous, NVIDIA, Qwen, Ollama, DeepSeek, xAI, custom, etc.). Wire ALL transport methods to production paths in run_agent.py: - build_kwargs: extract 210-line else branch with 13 provider-specific conditionals (Qwen portal, NVIDIA NIM, Ollama, reasoning, developer role swap, provider preferences, max_tokens defaults) - validate_response: response.choices validation gate - extract_cache_stats: OpenRouter prompt_tokens_details extraction - convert_messages: codex field sanitization (identity otherwise) - convert_tools: identity (already in OpenAI format) - normalize_response: near-identity wrapper returning NormalizedResponse Agent gathers state (provider detection flags, temperature, preferences) and passes as explicit params to transport.build_kwargs(). run_agent.py: -197 lines in _build_api_kwargs (12,054 -> 11,948). 26 new tests (build_kwargs: 12, validate: 4, normalize: 2, cache: 3, convert: 3, registration: 2). All transport tests pass. PR 5 of the provider transport refactor.
Collaborator
|
Duplicate of #13805 (already merged). This PR reopens a previously closed fork branch, but the feature (ChatCompletionsTransport) was already landed via a salvage PR. |
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.
Summary
PR 5 of the provider transport refactor (PR 1: #12975, PR 2: #13073, PR 3: #13366, PR 4: #13430).
Third concrete transport — handles the default
chat_completionsapi_mode used by ~16 OpenAI-compatible providers. Extracts the 210-line kwargs construction block from run_agent.py with all 13 provider-specific conditionals.What ships
agent/transports/chat_completions.py— ChatCompletionsTransport (314 lines)All transport methods wired to production paths:
build_kwargs()elsebranch in_build_api_kwargswith 13 provider conditionalsvalidate_response()response.choicesvalidation gateextract_cache_stats()prompt_tokens_details.cached_tokensextractionconvert_messages()convert_tools()normalize_response()response.choices[0].message→ NormalizedResponse)Provider-specific conditionals now in the transport:
Impact
_build_api_kwargs(12,054 → 11,948)_get_chat_completions_transport()lazy singleton addedTest plan