Skip to content

v0.5.9 - Gemini Images on /v1/images, config.yaml Saves That Stop Losing Settings, and Codex Models That Survive Restarts

Choose a tag to compare

@github-actions github-actions released this 11 Oct 22:19
· 384 commits to main since this release
11d8df9

v0.5.9 - Gemini Images on /v1/images, config.yaml Saves That Stop Losing Settings, and Codex Models That Survive Restarts

Pair it with codeProxy v0.6.2, which adds the Gemini image pickers and shows why a config.yaml save was rejected. Either upgrade order works; see Upgrade Notes. PUT /v0/management/config.yaml now rejects saves it used to accept and then silently lose, so scripts that write config.yaml should read the Upgrade Notes first.

Highlights

1. Antigravity's Gemini image model on /v1/images and the console

  • What was wrong: gemini-3.1-flash-image on Antigravity already returned pictures through the chat endpoints, but nothing on the images side could reach it. /v1/images/*, the console's image page and the model probe listed only gpt-image, Grok and MiniMax, and the Antigravity executor did not understand an images request.
  • What's new:
    • /v1/images/generations and /v1/images/edits serve Gemini image models while an Antigravity credential offers them. A model Antigravity publishes later needs no code change.
    • aspect_ratio and image_size map onto Gemini's image settings: the fourteen ratios upstream accepts (1:1 to 21:9) and the 512 / 1K / 2K / 4K tiers. A WIDTHxHEIGHT size maps to the nearest ratio and tier, so existing clients keep working.
    • Ratios are sent in upstream's own spelling. 21:9 used to be reduced to 7:3, which upstream rejects (#1148).
    • Reference images can be uploaded or sent as base64 data URIs. Remote URLs are not fetched, and masks are refused.
    • Responses report the real output_format (Gemini returns JPEG), the pixel size and token usage. A request that returns no image (a safety block, a text-only answer) fails as an invalid request, so the account is not cooled down.
    • The chat endpoints are unchanged.

2. config.yaml saves no longer report success while losing settings

  • What was wrong: PUT /v0/management/config.yaml answered 200 {"ok": true} in two cases where the change then existed nowhere:
    • The runtime settings a save spelled out (proxy-url, debug, request-retry, payload and others) were stored one key at a time, after the file was written. A key that failed to store was only logged. The reload then stripped it from the file and restored the old stored value.
    • The sections the database owns (routing, proxy-pool, api-keys, api-key-entries, api-key-permission-profiles) were written to the file, then dropped or overridden by the stored value. Hand-typed API keys even worked as keys of that one node until its next start.
  • The fix:
    • Runtime settings are stored first, in one transaction. If that fails, nothing changes and the save is rejected with 409 config_version_conflict or with a 500 that gives the cause.
    • A save that would change a database-owned section is rejected with 422 config_yaml_database_owned_sections before anything is stored or written. The message names each section and the page where it is edited: Channel Groups, Outbound Proxies, API Keys or Portal Account Permissions. A copy of the stored value still passes, as do the published example keys and sections the database does not hold yet.
    • Once the database holds API keys, a reload drops api-keys / api-key-entries from config.yaml, so hand-typed keys no longer act as keys of one node only.
    • Only hand-typed YAML is affected. The panel's dedicated pages use their own endpoints.

3. Codex model lists survive restarts

  • What was wrong: on 2026-10-11 a deploy restarted production, and for half an hour Codex clients got 502 unknown provider for model gpt-6.1-sol. The live model list was kept only in memory, and fetching it again failed. The fetch looked up each credential's proxy_id in the system tenant's proxy pool instead of the credential's own tenant, and the system pool still pointed at retired proxy endpoints.
  • The fix:
    • Every model list fetched from upstream is saved to provider-model-lists.json in the state directory and restored at startup, before the first registration pass. A restored list keeps routing until a newer answer replaces it.
    • Model discovery (Codex manifests, and the per-credential lists for Antigravity, xAI and Kimi) uses the credential's tenant configuration, so proxy_id resolves in that tenant's pool, as chat requests already did.

4. Antigravity: long agent sessions and malformed function calls

Contributed by @testAccountDeltas (#1143, #1139) and @RUIIIOVO (#1145). Thank you both.

  • Sessions past one million tokens: Antigravity accumulates a conversation on its side per session id. Once a long tool loop passed 1,048,576 tokens, every request in that session failed with 400 … exceeds the maximum number of tokens, and the conversation was stuck. The executor now retries on a new session id, at most twice per request, without using up a capacity retry. Sessions below the limit keep their prefix-cache hits. Each new turn starts on the original session again and switches after one quick 400.
  • MALFORMED_FUNCTION_CALL: Gemini sometimes plans a tool call, fails to emit it, and ends the turn after only thinking. Clients took that as a finished turn, so agents stopped halfway through a task. The executor now asks again, at most twice, while nothing but thinking has been sent. A streaming client still sees one response with one ending. Once text or a tool call has gone out, the answer stands.

5. Panel probes work in tenants whose default group excludes the model

  • What was wrong: the image console, the video console and the model test pick an account the same way API traffic does. A model excluded from the tenant's default channel group failed with model_not_allowed_by_channel_group, and accounts marked exclude-from-default could not be probed at all.
  • The fix: these three probes may use any account of the tenant. API traffic is unchanged.

Detailed Changes

Backend CliRelay

  • feat(images): serve Antigravity Gemini image models on /v1/images and the console (#1147).
  • fix(images): send Gemini aspect ratios in the spelling upstream accepts (#1148).
  • fix(management): let panel probes use any credential of the tenant (#1149).
  • fix(model-discovery): keep upstream model lists across restarts and fetch them through the tenant's proxy (#1150).
  • fix(management): reject config.yaml saves whose runtime settings fail to store (#1151).
  • fix(management): reject config.yaml saves that change database-owned sections (#1152).
  • test(management): pin the reason carried by {"error": "<code>", "message": "<reason>"} bodies, which codeProxy v0.6.2 now shows (#1153).
  • fix(antigravity): rotate the session id at the per-session 1M-token limit (#1143 and #1139, by @testAccountDeltas) and ask again when Gemini ends a turn with MALFORMED_FUNCTION_CALL (#1145, by @RUIIIOVO). Landed together in #1154, which keeps the re-request on the rotated session and adds executor tests.

Upgrade Notes

  • Scripts that write config.yaml (PUT /v0/management/config.yaml):
    • A save can now fail where it used to return 200: 409 config_version_conflict, 422 config_yaml_database_owned_sections, or 500 with the cause. A failed save changes nothing, so retry it, or edit the named sections where the message says.
    • Change routing, proxy pools and API keys through their own management endpoints, not by writing them into config.yaml.
  • Either upgrade order works:
    • codeProxy v0.6.2 on an older backend shows no Gemini image pickers; everything else in it works.
    • Older panels keep working on v0.5.9. Their size picker still drives Gemini image models, but some rejected saves show only an error code such as invalid_config.
    • CliRelay pulls the latest codeProxy release on its own, roughly every three hours.
  • New state file: provider-model-lists.json in the state directory. It is written atomically, so blue-green slots on one host can share it.
  • No changes required: there are no configuration or database schema changes.
中文说明(点击展开)

v0.5.9 - /v1/images 支持 Gemini 生图、config.yaml 保存不再悄悄丢设置、Codex 模型清单重启不丢

请与 codeProxy v0.6.2 搭配:新面板增加了 Gemini 生图的比例和分辨率档位,并会显示 config.yaml 保存被拒绝的原因。前后端谁先升级都可以,详见升级提示。PUT /v0/management/config.yaml 现在会拒绝以前接受、随后却悄悄丢掉的保存,写 config.yaml 的脚本请先看升级提示。

核心更新

1. /v1/images 和控制台支持 Antigravity 的 Gemini 生图模型

  • 原来的问题:Antigravity 上的 gemini-3.1-flash-image 已经能通过对话接口返回图片,但生图这边都用不了它。/v1/images/*、控制台的生图页和模型测试只列出 gpt-image、Grok 和 MiniMax,Antigravity 执行器也不认识生图请求。
  • 新增:
    • Antigravity 账号提供 Gemini 生图模型时,/v1/images/generations 和 /v1/images/edits 就能调用它们。Antigravity 以后发布的新模型不需要改代码。
    • aspect_ratio 和 image_size 对应 Gemini 的图片参数:上游接受的 14 种比例(1:1 到 21:9)和 512 / 1K / 2K / 4K 四档。传 WIDTHxHEIGHT 尺寸时会换算成最接近的比例和档位,原有客户端照常可用。
    • 比例按上游自己的写法发送。原来 21:9 会被约分成 7:3,上游不认(#1148)。
    • 参考图可以上传,也可以用 base64 data URI。不抓取远程 URL,不支持蒙版。
    • 响应里带真实的 output_format(Gemini 返回 JPEG)、像素 size 和 token usage。没有返回图片的请求(被安全策略拦截、只返回了文字)按无效请求处理,不会让账号进入冷却。
    • 对话接口没有任何变化。

2. config.yaml 保存不再一边报成功、一边丢设置

  • 原来的问题:PUT /v0/management/config.yaml 在两种情况下返回 200 {"ok": true},改动却哪里都没留下:
    • YAML 里写出的运行时设置(proxy-url、debug、request-retry、payload 等)是在写完文件之后逐个存进数据库的。某个键存失败只记日志;随后的重载把它从文件里删掉,再套回数据库里的旧值。
    • 由数据库管理的段(routing、proxy-pool、api-keys、api-key-entries、api-key-permission-profiles)被写进文件后,又被删掉或被数据库里的值覆盖。手写进去的 API Key 甚至会在那一个节点上生效,直到它下次重启。
  • 修复:
    • 先存运行时设置,并且放在一个事务里。存失败时什么都不改,保存被拒绝,返回 409 config_version_conflict,或者附带原因的 500。
    • 会改动数据库管理段的保存,在存储和写文件之前就以 422 config_yaml_database_owned_sections 拒绝。提示里会列出每个段,以及应该去哪个页面修改:渠道分组、出站代理、API Keys 或门户账号权限。与数据库中现有值相同的内容照常通过,官方示例 Key 和数据库里还没有的段也照常通过。
    • 数据库里已有 API Key 后,重载时会从 config.yaml 中去掉 api-keys / api-key-entries,手写的 Key 不会再只在单个节点上生效。
    • 只影响手写的 YAML,面板的专用页面走各自的接口。

3. Codex 模型清单重启后不再丢失

  • 原来的问题:2026-10-11 一次部署重启了生产服务,之后半小时 Codex 客户端一直收到 502 unknown provider for model gpt-6.1-sol。实时模型清单只存在内存里,重新拉取又失败了:拉取时按系统租户的代理池去解析账号的 proxy_id,而不是账号所属租户的代理池,而系统租户的代理池仍指向已经下线的代理地址。
  • 修复:
    • 每次从上游拉到的模型清单都会存到状态目录下的 provider-model-lists.json,启动时在第一次注册前恢复。恢复的清单会一直参与路由,直到被更新的结果替换。
    • 模型发现(Codex 清单,以及 Antigravity、xAI、Kimi 的按账号清单)改用账号所属租户的配置,proxy_id 在该租户自己的代理池里解析,与对话请求保持一致。

4. Antigravity:长 Agent 会话与 MALFORMED_FUNCTION_CALL

由 @testAccountDeltas(#1143、#1139)和 @RUIIIOVO(#1145)贡献,感谢两位。

  • 会话超过一百万 token:Antigravity 会按 session id 在上游累积整段对话。长时间的工具循环一旦超过 1,048,576 token,这个会话的每个请求都会返回 400 … exceeds the maximum number of tokens,对话就卡住了。现在执行器会换一个新的 session id 重试,每个请求最多换两次,不占用容量重试的次数。没超过上限的会话照常命中前缀缓存。每一轮新的对话仍会先用原来的会话,碰到一次很快返回的 400 后再切换。
  • MALFORMED_FUNCTION_CALL:Gemini 有时计划调用工具却没有发出调用,只输出了思考就结束了这一轮。客户端会把它当作正常结束,Agent 就停在半途。现在只要还没发出思考以外的内容,执行器就会重新请求,最多两次。流式客户端看到的仍是一个响应、一次结束;一旦已经发出文字或工具调用,就保留这次回答。

5. 默认分组排除了某个模型时,面板测试照常可用

  • 原来的问题:生图控制台、视频控制台和模型测试选账号的方式与 API 请求相同。被租户 default 渠道分组排除的模型会报 model_not_allowed_by_channel_group,标了 exclude-from-default 的账号则完全测不了。
  • 修复:这三处面板测试可以使用租户里的任意账号,API 请求不受影响。

详细改动

后端 CliRelay

  • feat(images):/v1/images 和控制台支持 Antigravity 的 Gemini 生图模型(#1147)。
  • fix(images):Gemini 比例按上游接受的写法发送(#1148)。
  • fix(management):面板测试可以使用租户里的任意账号(#1149)。
  • fix(model-discovery):上游模型清单重启后不丢失,并通过账号所属租户的代理拉取(#1150)。
  • fix(management):运行时设置存储失败时拒绝 config.yaml 保存(#1151)。
  • fix(management):拒绝改动数据库管理段的 config.yaml 保存(#1152)。
  • test(management):用测试固定 {"error": "<代码>", "message": "<原因>"} 错误体里的原因,codeProxy v0.6.2 会显示这个原因(#1153)。
  • fix(antigravity):会话达到 1M token 上限时轮换 session id(#1143、#1139,作者 @testAccountDeltas),Gemini 以 MALFORMED_FUNCTION_CALL 结束时重新请求(#1145,作者 @RUIIIOVO)。两者在 #1154 中一起合入,#1154 还让重新请求保持在轮换后的会话上,并补充了执行器测试。

升级提示

  • 写 config.yaml 的脚本(PUT /v0/management/config.yaml):
    • 以前返回 200 的保存现在可能失败:409 config_version_conflict、422 config_yaml_database_owned_sections,或附带原因的 500。失败的保存不会改动任何内容,可以重试,或按提示去对应的地方修改。
    • 路由、代理池和 API Key 请通过各自的管理接口修改,不要写进 config.yaml。
  • 前后端谁先升级都可以:
    • codeProxy v0.6.2 跑在旧后端上时不显示 Gemini 生图的比例和档位,其余功能都可以用。
    • 旧面板在 v0.5.9 上照常可用。它的尺寸选择仍能驱动 Gemini 生图模型,只是部分被拒绝的保存只显示 invalid_config 这样的错误代码。
    • CliRelay 大约每三小时会自动拉取 codeProxy 的最新版本。
  • 新的状态文件:状态目录下的 provider-model-lists.json。它以原子方式写入,同一台机器上的蓝绿两个实例可以共用。
  • 无需改动:配置和数据库结构都没有变化。

Multi-arch binaries and the Docker image are published to GitHub Releases and GHCR. Released together with codeProxy v0.6.2.