auto-sync(copilot): merge upstream/main (conflicts with feat/copilot)#7
Merged
Merged
Conversation
Anthropic's List Models response (GET /v1/models) defines each model object with id, display_name, max_input_tokens, max_tokens, created_at and type. The Claude case of convertModelToMap emitted an incomplete object: it dropped max_input_tokens and max_tokens entirely and omitted display_name whenever it was unset, so the Anthropic-compatible listing did not match the schema it emulates. Emit max_input_tokens from ContextLength and max_tokens from MaxCompletionTokens (the same registry metadata the Gemini case already surfaces as inputTokenLimit/outputTokenLimit), with fallbacks, and always emit display_name, falling back to the model ID.
Anthropic's List Models schema types created_at as an RFC 3339 datetime string, but the Claude case of convertModelToMap emitted model.Created as a Unix-timestamp integer. Format it with time.RFC3339 so the listing matches the documented schema.
/v1/models is shared by the OpenAI and Anthropic surfaces and was dispatched to the Claude format only for claude-cli User-Agents, so generic Anthropic API clients received the OpenAI format. Distinguish Anthropic requests by the Anthropic-Version header (sent by every Anthropic client, never by OpenAI/Codex clients) in addition to the existing claude-cli check, in both unifiedModelsHandler and handleHomeModels. Additive and non-breaking for existing clients.
- Deleted `geminicli` provider and related `Apply` logic. - Removed all translator packages specific to Gemini CLI (Claude, Codex integrations). - Purged associated test files for Gemini CLI translation. - Removed `GeminiAuthenticator` and all associated authentication logic (OAuth flows, token handling, refresh logic). - Deleted internal/executor Gemini OAuth support, including bearer token handling and runtime API logic. - Purged all tests, configs, and command-line flags specific to Gemini OAuth flows. - Updated documentation and aliases to reflect Gemini removal. - Renamed `parseRetryDelay` to `ParseRetryDelay` and `deleteJSONField` to `DeleteJSONField`. - Updated references in `antigravity_executor` and tests to use the new `helps` package. - Adjusted import paths and test cases to ensure compatibility with the new location. - Updated README files to reflect changes in the retry logic references. - Updated `.github/ISSUE_TEMPLATE/bug_report.md` to remove deprecated Gemini CLI mention.
Add executor-scoped replay cache aligned with Codex HOME replay: Scope, observe SSE/non-stream responses, store normalized thought_signature and function_call_part items, apply on the next streamGenerateContent request, and invalidate on invalid signature responses. Gemini/flash/agent models use HOME replay; native per-part signature replay is not wired on upstream/dev. Wire non-stream and stream paths in antigravity_executor and purge expired entries from signature_cache. Includes unit tests and HOME-provider-replay documentation.
…onResponse When HOME replay restores a cached function_call_part and the request already contains the matching functionResponse, insert a synthetic role=model content with functionCall (and thoughtSignature) immediately before that response content instead of writing into the same index. Add regression tests for user/model functionResponse shapes.
Trim call_id once for matching-function-response checks; use args.Value() in synthetic model functionCall insertion; guard functionResponse lookup when call_id is empty.
- Derive replay session from generateStableSessionID when sessionId is absent - Merge cached thoughtSignature into existing functionCall by call id - Allow filter to pass function_call_part when only signature replay is needed - Include native functionCall id in replay dedupe keys - Add unit tests for signature merge, stable scope, and parallel tool ids
Add executor httptest for upstream 400 clearing HOME reasoning replay items, and a whitespace call_id matcher regression test for replay filtering.
…e conversions - Updated `ConvertOpenAIResponsesRequestToOpenAIChatCompletions` to retain `tool_choice` with raw byte handling. - Added `TestConvertOpenAIResponsesRequestToOpenAIChatCompletions_PreservesStructuredToolChoice` to ensure function and type fields are preserved in transformations. Closes: router-for-me#3384
…onversion - Updated handling in `ConvertOpenAIResponsesRequestToOpenAIChatCompletions` to retain `input_image` detail fields such as `image_url` and `detail`. - Added `TestConvertOpenAIResponsesRequestToOpenAIChatCompletions_PreservesInputImageDetail` to verify preservation of image details during transformation. Closes: router-for-me#3385
# Conflicts: # internal/api/handlers/management/auth_files.go # internal/thinking/provider/geminicli/apply.go
…ssages in OpenAI response conversion - Enhanced `ConvertOpenAIResponsesRequestToOpenAIChatCompletions` to include `reasoning_content` in assistant and tool call messages. - Introduced `collectOpenAIResponsesReasoningContent` for aggregating reasoning summaries. - Added tests to validate reasoning attachment in various scenarios, including empty reasoning, tool calls, and reasoning followed by user messages. Closes: router-for-me#3397
…versions - Updated `ConvertOpenAIRequestToGemini` and `ConvertOpenAIRequestToCodex` to handle `input_audio`, retaining `data` and `format` fields. - Added helper `openAIInputAudioMimeType` for determining MIME types from audio formats. - Introduced unit tests to validate correct preservation of `input_audio` data and format. Closes: router-for-me#3447
…e is available - Updated `ConvertCodexResponseToClaude` to delay emitting `function_call` start events until the `name` field is resolved. - Introduced `pendingCodexFunctionCall` for buffering incomplete function calls. - Added tests to ensure proper behavior for deferred starts, including argument buffering and finalization. Closes: router-for-me#3471
…N schema processing - Updated JSON schema handling to remove `$comment` and `enumDescriptions` fields during schema transformations. - Adjusted test cases to validate the removal of these fields both at root and nested levels. - Expanded unsupported schema keywords to include `$comment` and `enumDescriptions` for Gemini compatibility. Closes: router-for-me#3512
…port - Replaced direct `strings.ToLower` usage with `util.OpenAICompatibleProviderKey` for generating provider keys. - Updated auth and executor workflows to use namespaced keys for OpenAI-compatible providers. - Adjusted tests to validate namespaced key handling, including new test cases for provider registration and execution logic. - Added `OpenAICompatibleProviderKey` helper in `util` for consistent key transformations. Closes: router-for-me#3600
…ence - Added `normalizeCodexParallelToolCallsForTools` to conditionally remove `parallel_tool_calls` when `tools` are missing or empty. - Integrated normalization into Codex executor workflows for improved request handling. - Introduced unit tests to validate behavior across different tool scenarios. Closes: router-for-me#3903
…to Gemini requests - Implemented `applyOpenAIResponsesTextFormatToGemini` to handle `json_object` and `json_schema` formats. - Updated generation config to set appropriate `responseMimeType` and optional `responseJsonSchema`. - Introduced unit tests to validate correct handling of `text.format` conversion scenarios. Closes: router-for-me#3721
- Introduced `xaiRequiresIsolatedConversation` to enforce session ID generation for `grok-composer` models. - Updated request preparation logic to handle isolated conversations by setting `prompt_cache_key` and `x-grok-conv-id`. - Added unit tests with coverage for session isolation, stateless models, and explicit `prompt_cache_key` scenarios. Closes: router-for-me#3750
… with large inputs - Introduced `BenchmarkConvertSystemRoleToDeveloperLargeInput` to evaluate performance on various input sizes and configurations. - Improved `convertSystemRoleToDeveloper` logic to optimize JSON rebuilding and reduce unnecessary operations. - Created helper `makeLargeResponsesInputForBenchmark` to generate test data for performance scenarios. Closes: router-for-me#3751
- Introduced `SetOAuthModelAliasesAttribute` and `OAuthModelAliasesFromAttributes` for managing per-auth model aliases. - Enhanced OAuth model resolution logic to prioritize per-auth aliases over global aliases. - Updated metadata handling to extract and sanitize per-account model aliases. - Added tests to validate alias precedence, empty attributes, and conflict scenarios. Closes: router-for-me#3764
- Introduced `RebuildMidSystemMessage` field in config to move system messages into the top-level Claude system field. - Updated executor to handle mid-system message rebuilding when enabled via config or auth attributes. - Added unit tests to verify rebuilding behavior and default behavior when disabled. - Updated configuration example and API handlers to support the new field. Closes: router-for-me#3792
…l handling - Replaced internal model-specific constants with exported defaults (`DefaultClaudeMaxInputTokens`, `DefaultClaudeMaxOutputTokens`). - Refactored Claude model formatting to centralize schema application in `formatHomeClaudeModel`, with fields like `type`, `display_name`, and token limits. - Added new unit tests for fallback behavior, metadata fields, and token handling in Claude and Gemini models. - Removed deprecated test coverage for Amp provider model routes. Closes: router-for-me#3833
… request handling - Applied `CleanJSONSchemaForGemini` to ensure compatibility by removing unsupported fields and cleaning schema requirements. - Added test cases to validate schema transformation, ensuring only necessary `required` fields are retained. - Enhanced both request and response flows to consistently clean and sanitize tool parameter schemas. Closes: router-for-me#3863
…set functionality - Introduced a new `/reset-quota` API endpoint in the management handler to clear quota and cooldown state for auth records. - Implemented `ResetQuota` method in the auth manager to handle runtime and registry state resets for affected models. - Added tests to validate quota reset behavior, including proper state updates and registry consistency. - Refactored utility functions to support deduplication and registered models handling in quota resets. Closes: router-for-me#3866
…Gemini requests - Updated `ConvertGeminiRequestToOpenAI` to consume `tool_call_id`s in FIFO order, ensuring consistent mapping between calls and responses. - Added fallback logic for unmatched or extra function responses to generate unique `tool_call_id`s with a `call_` prefix. - Introduced comprehensive unit tests to validate order enforcement, distinct ID assignment, and fallback behavior. Closes: router-for-me#3874
…request and response translations - Updated `ConvertGeminiRequestToClaude`, `ConvertGeminiRequestToCodex`, and their respective response counterparts to include logic for retaining and using tool/call IDs when present from gateway-provided inputs. - Enhanced pairing logic between function calls and responses to handle custom and auto-generated IDs consistently. - Introduced tests validating ID preservation and proper behavior in both streaming and non-streaming flows. Closes: router-for-me#3878
- Added a new "max" level to model `thinking.levels` for enhanced customization. - Removed deprecated Gemini 3 Pro (High/Low) models and associated fields from the registry. - Simplified `thinking` attribute structure for `grok-build-0.1` and `grok-composer-2.5-fast` models. Closes: router-for-me#3901
- Updated `ConvertOpenAIRequestToGemini` to process `video_url` message types, extracting and embedding video metadata (MIME type and base64 data) into Gemini request parts. - Added corresponding unit tests to validate `video_url` handling, ensuring proper extraction and data preservation. Closes: router-for-me#3920
…eplay-fc-order-upstream-dev fix(antigravity): HOME Gemini replay and functionCall ordering before functionResponse
…ent models - Introduced a new "max" level for reasoning depth in Codex client model configuration, providing maximum problem-solving capability. - Added `service_tiers` field to model responses for better tier categorization. - Updated unit tests to validate the inclusion and default behavior of `service_tiers` and the new "max" reasoning depth.
…ority calculation logic - Added `applyCodexClientNonTemplatePriorities` to assign higher priorities to non-template Codex client models dynamically. - Implemented `maxCodexClientTemplatePriority` to set base priority for non-template models relative to template models. - Updated unit tests to validate priority calculation for custom models.
- Added logic to expand single auth JSON payloads into multiple plugin virtual auth records. - Updated related API endpoints such as `PatchAuthFileStatus` and `DeleteAuthFile` to handle plugin virtual auths with rollback mechanisms. - Introduced `NormalizePluginOAuthCallbackProvider` and other normalization functions for better handling of OAuth callbacks. - Enhanced tests to validate multi-auth parsing, rollback behavior, and API response consistency.
…lugin calls - Added `rpcPluginError` to encapsulate plugin errors with HTTP status codes. - Enhanced `decodeEnvelopeResult` to preserve and return detailed plugin errors with status codes. - Introduced `isPluginErrorEnvelope` to identify plugin error envelopes. - Updated plugin call logic in Unix and Windows loaders to differentiate plugin errors from system errors. - Added unit tests to verify error handling and status code preservation.
… configuration - Implemented `unregisterOpenAICompatExecutor` to remove OpenAI-compatible executors dynamically. - Updated `ensureExecutorsForAuth` to unregister incompatible executors while handling plugin candidates. - Adjusted runtime configuration logic to ensure proper synchronization during updates with `syncPluginModelRuntime`.
… for compatibility grouping - Extracted provider key determination into `apiKeyUsageProviderKey` for reuse and better readability. - Updated `GetAPIKeyUsage` to utilize the new function. - Added a new test case to validate compatibility grouping logic via `compat_name` attribute. Closes: router-for-me#3940 router-for-me#3941
…-for-me#3946) * fix(claude): bypass signature sanitizer for non-Claude models * test(claude): use subtests for sanitizer gate model cases
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.
Auto-sync from
upstream/main(router-for-me/CLIProxyAPI) intofeat/copilot.Reason for manual review: conflicts with
feat/copilotNew commits
tool_choicein OpenAI response conversionsinput_imagedetails in OpenAI response conversionreasoning_contentto assistant and tool messages in OpenAI response conversiongithub.com/jackc/pgx/v5from v5.7.6 to v5.9.2input_audiofields in OpenAI request conversions$commentandenumDescriptionsin JSON schema processingparallel_tool_callsbased ontoolspresencetext.formatconversion in OpenAI to Gemini requestsgrok-composermodelsconvertSystemRoleToDeveloperwith large inputsrebuild_mid_system_messageconfigurationparametersJsonSchemain OpenAI to Gemini request handlingResetQuotaendpoint and auth manager quota reset functionalityservice_tiersto Codex client modelsunregisterOpenAICompatExecutorand sync runtime configuration