feat: add api_mode=responses for generic OpenAI Responses API (#33600) - #33889
feat: add api_mode=responses for generic OpenAI Responses API (#33600)#33889ousiaresearch wants to merge 1 commit into
Conversation
…Research#33600) Adds a generic 'responses' api_mode for custom providers that expose a /v1/responses endpoint instead of /v1/chat/completions. Includes _normalize_responses_to_chat() to convert Responses API output to chat.completions shape.
Design notes — first-class api_mode vs alias normalizationThis PR adds Why first-class vs alias (#33604, #33765): Competing PRs alias ```python This is a problem because it conflates two distinct protocols:
By normalizing to Our approach:
|
teknium1
left a comment
There was a problem hiding this comment.
Thanks for isolating generic Responses API support from the Codex-specific path. The capability remains absent on current main, but this patch needs a broader salvage.
Problems
- Current
AIAgentonly admits the modes listed inagent/agent_init.py:452; an explicitresponsesmode falls through tochat_completionsatagent/agent_init.py:483, so the added dispatch branch would not run after salvage. - The new
responses.create()call needs Responses-format kwargs. Currentagent/chat_completion_helpers.py:818-882producesinputand converted tools only forcodex_responses; the default path from line 884 constructs Chat Completionsmessageskwargs. - The patch has no tests for custom resolution, payload conversion, text, or function-call continuation.
Suggested changes
- Wire
responsesthrough mode admission, transport/payload conversion, centralized dispatch, and the relevant retry/fallback paths; add end-to-end-style unit coverage around a custom provider. - Update the documented API-mode enumerations, including
website/docs/developer-guide/model-provider-plugin.md:94.
Automated hermes-sweeper review.
| @@ -230,6 +329,18 @@ def _call(): | |||
| ) | |||
| elif agent.api_mode == "anthropic_messages": | |||
| result["response"] = agent._anthropic_messages_create(api_kwargs) | |||
There was a problem hiding this comment.
responses.create() requires Responses-format input and tool definitions, but this patch leaves build_api_kwargs() on the Chat Completions messages path for api_mode="responses". Wire this mode through the existing Responses transport/payload conversion before dispatching here.
What does this PR do?
Adds
api_mode='responses'for custom providers using the OpenAI Responses API (/v1/responses). Generic (non-Codex) dispatch.Fixes #33600
Type of Change
Changes Made
hermes_cli/runtime_provider.py: Added"responses"to_VALID_API_MODESagent/chat_completion_helpers.py: Added_normalize_responses_to_chat()+responsesapi_mode branch in_call()How to Test
api_mode: responsesin config.yamlhermes modelto select custom providerChecklist