1727 Commits

Author SHA1 Message Date
Luis Pater
f56a19e5b8 feat: add tri-state support for disable-image-generation configuration
- Introduced `DisableImageGenerationMode` with support for `false`, `true`, and `chat` values.
- Updated payload handling to preserve `image_generation` on images endpoints when `chat` mode is enabled.
- Modified OpenAI image handlers (`ImagesGenerations`, `ImagesEdits`) to respect tri-state logic.
- Added unit tests for `DisableImageGenerationMode` behavior and endpoint-specific handling.
- Enhanced configuration diff logging to support `DisableImageGenerationMode`.
2026-04-30 12:10:27 +08:00
Luis Pater
46018417ad feat: remove tool_choice for image_generation when disabled
- Added logic to remove `tool_choice` entries of type `image_generation` from payloads when `disable-image-generation` is enabled.
- Updated `ApplyPayloadConfigWithRoot` to handle new removal logic.
- Added unit tests to verify `tool_choice` removal behavior.
2026-04-30 08:24:14 +08:00
Luis Pater
e3e60f914b feat: support disabling image generation globally
- Added `disable-image-generation` configuration flag to disable the `image_generation` tool globally.
- Updated payload handling to remove `image_generation` tools from request payload arrays when the flag is enabled.
- Modified OpenAI image handlers (`ImagesGenerations`, `ImagesEdits`) to return 404 when the feature is disabled.
- Enhanced configuration diff logging to track changes for the `disable-image-generation` flag.
- Added accompanying unit tests for the new feature in payload helpers and image handler logic.
2026-04-30 03:42:27 +08:00
Luis Pater
a1f0ed9575 Merge pull request #3071 from sususu98/fix/antigravity-credits-log
Mark Antigravity credits requests in access logs
2026-04-29 22:56:41 +08:00
Luis Pater
b3b92f334e Merge pull request #3125 from sususu98/fix/gemini-cli-usage-metadata-variants
fix: parse gemini cli usage metadata variants
2026-04-29 22:56:14 +08:00
sususu98
0d107dd566 fix: respect declared claude web search tool names 2026-04-29 19:24:53 +08:00
sususu98
1c0c426b85 fix: align claude codex translation 2026-04-29 18:47:03 +08:00
sususu98
4982512da2 fix: parse gemini cli usage metadata variants 2026-04-29 13:10:53 +08:00
Luis Pater
2ea8f77efb feat(models): add GPT-5.5 to the registry with support for advanced tasks 2026-04-29 09:49:26 +08:00
Luis Pater
f95ab4cdf1 Merge pull request #3089 from XYenon/feat/session-affinity
feat: support Codex/PI session headers for session affinity
2026-04-28 23:54:16 +08:00
sususu98
0e1235122e fix antigravity client agent headers 2026-04-28 19:04:40 +08:00
sususu98
e78d45acc9 fix antigravity user agent handling 2026-04-28 19:04:40 +08:00
xbang
a992dee4e8 fix(antigravity): use real antigravity UA when polling credits balance
The loadCodeAssist polling call hardcoded the User-Agent to
google-api-nodejs-client/9.15.1. Google Cloud Code returns the
paidTier object WITHOUT the availableCredits array for that UA,
so updateAntigravityCreditsBalance always saw "no credits", set the
hint to Available=false for every Google One AI Ultra account, and
the conductor-level credits fallback could never find a candidate.

Switching to resolveUserAgent(auth) (the same UA used for
streamGenerateContent / generateContent) makes the response include
availableCredits, so the credits hint is populated correctly and the
fallback can actually inject enabledCreditTypes:["GOOGLE_ONE_AI"]
when free tier is exhausted.
2026-04-28 16:21:15 +08:00
XYenon
3ac39dcc7d feat: support Codex/PI session headers for session affinity
Amp-Thread-ID: https://ampcode.com/threads/T-019dce25-c070-773a-ac52-11c541220b30
Co-authored-by: Amp <amp@ampcode.com>
2026-04-27 17:10:50 +08:00
sususu
c523101439 Preserve Codex reasoning signatures for Claude 2026-04-27 16:51:35 +08:00
Luis Pater
d85e13b044 fix(codex): include content field in reasoning item initialization 2026-04-27 16:41:23 +08:00
Luis Pater
01e16a8509 feat(codex): handle thinking-signature conversion for reasoning content
- Implemented `appendReasoningContent` to support processing of `thinking` signature and text as reasoning input.
- Added test cases to validate reasoning content conversion with and without text.
2026-04-27 16:31:26 +08:00
Luis Pater
04a336f7df fix(usage_helpers): skip zero-token usage in additional model records
- Added `buildAdditionalModelRecord` to filter out zero-token usage details.
- Introduced `hasNonZeroTokenUsage` helper function for token usage validation.
- Updated tests to cover scenarios for zero and non-zero token usage.
2026-04-27 10:56:22 +08:00
sususu98
6fc23568df logging: mark antigravity credits requests 2026-04-26 23:04:27 +08:00
Luis Pater
736ae61e4a Merge pull request #3051 from philipbankier/fix/gpt55-free-tier-test
fix(test): remove free tier from GPT-5.5 inclusion test
2026-04-26 22:35:59 +08:00
Luis Pater
c5bea6f6f8 Merge pull request #3020 from Matthias319/fix/codex-error-classification
fix(codex): classify context, thinking-signature, previous-response, and auth failures
2026-04-26 22:26:40 +08:00
Luis Pater
c7b28ba058 feat(executor): add support for Codex image generation tool usage tracking
- Introduced `publishCodexImageToolUsage` to report image generation tool metrics.
- Updated executor logic to handle image generation tool events and defaults.
- Added parsing logic for `image_gen` tool usage details in `helps/usage_helpers.go`.
- Updated `UsageReporter` for additional model-specific usage publishing.
- Refactored usage detail normalizations.

Closes: #3063
2026-04-26 22:19:03 +08:00
Luis Pater
38573050aa feat(config): add support for disabling OpenAI compatibility providers
- Introduced a `Disabled` flag to OpenAI compatibility configurations.
- Updated routing, auth selection, and API handling logic to respect the `Disabled` state.
- Extended relevant APIs, YAML configurations, and data structures to include the `Disabled` field.
- Adjusted all relevant loops and filters to skip disabled providers.

Closes: #3060 #3059 #2977
2026-04-26 21:49:36 +08:00
philipbankier
32ef1588e8 fix(test): remove free tier from GPT-5.5 inclusion test
GPT-5.5 was correctly removed from codex-free tier in 7b89583c
(since free accounts cannot access it), but the test was not updated
to reflect this. This caused TestCodexStaticModelsIncludeGPT55 to
fail on the free subtest.

Changes:
- Remove free tier from GPT-5.5 inclusion test
- Add new TestCodexFreeModelsExcludeGPT55 to explicitly verify
  that free tier does NOT include GPT-5.5
2026-04-25 22:11:08 -04:00
Luis Pater
ea670ef8c0 feat(models): add Codex Auto Review model entry to registry JSON
Closes: #2995
2026-04-26 03:09:06 +08:00
Luis Pater
2c626efc59 feat(security): implement IP ban for repeated management key and Redis AUTH failures
- Added IP ban logic to `AuthenticateManagementKey` and Redis protocol handlers, blocking requests after multiple failed attempts.
- Introduced unit tests to validate IP ban behavior across localhost and remote clients.
- Synchronized Redis protocol's authentication policy with management key validation.
2026-04-25 21:39:58 +08:00
Luis Pater
28d78273e4 feat(api): implement protocol multiplexer and Redis queue for usage integration
- Added `protocol_multiplexer.go`, enabling support for both HTTP and Redis protocols on a single listener.
- Introduced `redis_queue_protocol.go` to handle Redis-compatible RESP commands for queue management.
- Integrated `redisqueue` package, supporting in-memory queuing with expiration pruning.
- Updated server initialization to manage a shared listener and multiplex connections.
- Adjusted `Handler` to adopt `AuthenticateManagementKey` for modular key validation, supporting both HTTP and Redis flows.
2026-04-25 18:52:24 +08:00
Luis Pater
a7e92e2639 feat(auth): disallow free-tier Codex auth during selection process
- Introduced `disallowFreeAuthFromMetadata` and `isFreeCodexAuth` to enforce skipping free-tier credentials.
- Modified scheduler logic to honor `DisallowFreeAuthMetadataKey` during auth selection.
- Updated `ensureImageGenerationTool` to skip tool injection for free-tier Codex auth.
- Added context utility `WithDisallowFreeAuth` and integrated with image handlers.
- Augmented relevant tests to cover free-tier exclusion scenarios.
2026-04-24 23:18:56 +08:00
Matthias319
4056c2590b fix(codex): classify known upstream failures
Normalize Codex context, thinking-signature, previous-response, and auth failures to explicit error codes: context_too_large, thinking_signature_invalid, previous_response_not_found, auth_unavailable.

Refs #2596.
2026-04-24 17:13:23 +02:00
Luis Pater
f1ba6151a9 feat(codex): pass base model to enable conditional image_generation tool injection
- Modified `ensureImageGenerationTool` to accept `baseModel` for conditional logic.
- Ensured `gpt-5.3-codex-spark` models bypass image_generation tool injection.
- Updated relevant tests and executor logic to reflect changes.
2026-04-24 07:21:03 +08:00
Luis Pater
7b89583cf8 chore(models): remove GPT-5.5 model entry from registry JSON 2026-04-24 05:07:03 +08:00
Ben Vargas
736018a0b0 Add GPT-5.5 Codex model support 2026-04-23 13:43:02 -06:00
Luis Pater
7d5f6d9382 feat(models): add GPT-5.5 model entry to registry JSON 2026-04-24 02:43:12 +08:00
sususu98
12195a276e Merge pull request #2971 from sususu98/feat/antigravity-credits-fallback
feat(antigravity): conductor-level credits fallback for Claude models
2026-04-24 00:15:23 +08:00
Luis Pater
25137b1984 feat(logging): add AI API path support for image routes
- Included `/v1/images` in AI API path prefixes.
- Introduced tests to validate `/v1/images/generations` and `/v1/images/edits` as AI API paths.
2026-04-24 00:11:42 +08:00
sususu98
7ad1900041 perf(antigravity): async credits hint refresh for warm tokens 2026-04-23 23:58:10 +08:00
sususu98
920b6efffa refactor(logging): strip unrelated deferred body changes, keep credits-only logging
Remove deferred body optimization and maxErrorLog constants that were
unrelated to credits fallback. Keep only MarkCreditsUsed/CreditsUsed
helpers for flagging requests that consumed AI credits.
2026-04-23 17:41:54 +08:00
sususu98
e75daa299b fix(antigravity): respect pinned auth in credits fallback, release deferred body on success
- findAllAntigravityCreditsCandidateAuths now filters by PinnedAuthMetadataKey
  to prevent credential isolation violations during credits fallback
- Release deferredBody reference on success path to avoid holding large
  payloads in memory for the lifetime of the gin context
2026-04-23 17:38:02 +08:00
sususu98
4de5c29f86 fix(antigravity): remove credits fallback from CountTokens, fix gofmt
CountTokens upstream API does not support enabledCreditTypes, so
remove the dead credits fallback path from ExecuteCount and delete
the unused tryAntigravityCreditsExecuteCount method. Fix gofmt on
credits test file.
2026-04-23 15:17:00 +08:00
sususu98
14d46a0a5d feat(antigravity): conductor-level credits fallback for Claude models
Move credits handling from executor-level retry to conductor-level
orchestration. When all free-tier auths are exhausted (429/503), the
conductor discovers auths with available Google One AI credits and
retries with enabledCreditTypes injected via context flag.

Key changes:
- Add AntigravityCreditsHint system for tracking per-auth credits state
- Conductor tries credits fallback after all auths fail (Execute/Stream/Count)
- Executor injects enabledCreditTypes only when conductor sets context flag
- Credits fallback respects provider scope (requires antigravity in providers)
- Add context cancellation check in credits fallback to avoid wasted requests
- Remove executor-level attemptCreditsFallback and preferCredits machinery
- Restructure 429 decision logic (parse details first, keyword fallback)
- Expand shouldAbort to cover INVALID_ARGUMENT/FAILED_PRECONDITION/500+UNKNOWN
- Support human-readable retry delay parsing (e.g. "1h43m56s")
2026-04-23 13:44:20 +08:00
MoYeRanQianZhi
31934ae04c feat(codex): enable image generation for all Codex upstream requests
Codex CLI gates the built-in image_generation tool behind
AuthMode::Chatgpt (OAuth only). When clients connect via API key
auth through CPA, the tool is absent from requests, making image
generation unavailable through the reverse proxy.

Changes:

1. Inject image_generation tool (codex_executor.go):
   Add ensureImageGenerationTool() that appends
   {"type":"image_generation","output_format":"png"} to the tools
   array if not already present. Applied to all three execution
   paths: Execute, executeCompact, and ExecuteStream.

2. Route aliases for Codex CLI direct access (server.go):
   Add /backend-api/codex/responses routes that map to the same
   OpenAI Responses API handlers as /v1/responses. This allows
   Codex CLI to connect via chatgpt_base_url config while keeping
   AuthMode::Chatgpt, which enables the built-in image_generation
   tool on the client side.

3. Unit tests (codex_executor_imagegen_test.go):
   Cover no-tools, existing tools, already-present, empty array,
   and mixed built-in tool scenarios.
2026-04-23 01:24:40 +08:00
Luis Pater
e935196df4 feat(models): add hardcoded GPT-Image-2 model support in Codex
- Added `GPT-Image-2` as a built-in model to avoid dependency on remote updates for Codex.
- Updated model tier functions (`CodexFree`, `CodexTeam`, etc.) to include built-in models via `WithCodexBuiltins`.
- Introduced new handlers for image generation and edit operations under `OpenAIAPIHandler`.
- Extended tests to validate 503 response for unsupported image model requests.
2026-04-22 20:51:13 +08:00
Luis Pater
4fc2c619fb feat(models): add Kimi K2.6 model entry to registry JSON 2026-04-21 20:53:03 +08:00
Luis Pater
8ced7a548f Merge pull request #2834 from muzhi1991/fix/openai-compat-host-header
fix(util): forward custom Host header to upstream
2026-04-21 20:29:14 +08:00
Luis Pater
3444820958 Merge pull request #2939 from stringer07/fix/codex-stream-output-backfill
fix(codex): backfill streaming response output
2026-04-21 20:18:57 +08:00
Luis Pater
1716a845eb feat(api): add support for HEAD requests to /healthz endpoint
- Refactored `/healthz` handler to support `HEAD` requests alongside `GET`.
- Updated tests to include validation for `HEAD` requests with expected status and empty body.

Closes: #2929
2026-04-21 20:16:18 +08:00
stringer07
b6781d69be perf(codex): avoid repeated output patch writes 2026-04-21 16:29:54 +08:00
stringer07
bb8408cef5 fix(codex): backfill streaming response output 2026-04-21 16:03:56 +08:00
Luis Pater
e05abec01f Merge pull request #2898 from octo-patch/fix/issue-2866-remove-obsolete-1m-beta-header
fix(executor): drop obsolete context-1m-2025-08-07 beta header
2026-04-19 11:46:21 +08:00
octo-patch
f4eb16102b fix(executor): drop obsolete context-1m-2025-08-07 beta header (fixes #2866)
Anthropic has moved the 1M-context-window feature to General Availability,
so the context-1m-2025-08-07 beta flag is no longer accepted and now causes
400 Bad Request errors when forwarded upstream.

Remove the X-CPA-CLAUDE-1M detection and the corresponding injection of the
now-invalid beta header.  Also drop the unused net/textproto import that was
only needed for the header-key lookup.
2026-04-19 10:38:16 +08:00