feat(openai): 对齐 GPT-5.6 模型族与 Codex 请求协议#669
Closed
MMEXA wants to merge 22 commits into
Closed
Conversation
MMEXA
force-pushed
the
codex/openai-gpt-5-6-compat-20260710
branch
from
July 10, 2026 22:39
afe35bc to
a498c0a
Compare
MMEXA
force-pushed
the
codex/openai-gpt-5-6-compat-20260710
branch
from
July 10, 2026 23:41
a498c0a to
dfa121d
Compare
MMEXA
force-pushed
the
codex/openai-gpt-5-6-compat-20260710
branch
from
July 11, 2026 10:13
624b349 to
59d37ae
Compare
MMEXA
force-pushed
the
codex/openai-gpt-5-6-compat-20260710
branch
from
July 12, 2026 15:04
dcd917b to
fc2dfb8
Compare
MMEXA
force-pushed
the
codex/openai-gpt-5-6-compat-20260710
branch
from
July 12, 2026 20:54
04030e0 to
fc2dfb8
Compare
MMEXA
force-pushed
the
codex/openai-gpt-5-6-compat-20260710
branch
from
July 13, 2026 14:03
79dd8a6 to
2fc604e
Compare
Closed
fawney19
added a commit
that referenced
this pull request
Jul 15, 2026
fawney19
added a commit
that referenced
this pull request
Jul 16, 2026
feat(codex): complete PR #669 protocol follow-up
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.
目标与范围
对齐 GPT-5.6 Sol、Terra、Luna 模型族以及 Codex
Responses、Responses Compact、Search的请求协议、模型能力、服务层级、计费事实和管理配置。实现遵循 Aether 的格式注册、请求规划、候选调度、Usage 归一化和结构化计价链路,各入口共享同一组协议能力与校验规则。GPT-5.6 模型与推理能力
gpt-5.6-sol、gpt-5.6-terra、gpt-5.6-luna的 Codex 模型卡,覆盖上下文窗口、可见性、优先级、最低客户端版本、默认推理强度、可用推理档位、Responses Lite、服务层级、工具能力和提示缓存能力。none、low、medium、high、xhigh、max;模型卡按各自声明的 effort 集合执行精确校验,GPT-5.6 Codex 模型的可用档位从low起。reasoning.mode支持standard|pro,effort 缺省值为medium;reasoning.context支持auto|current_turn|all_turns。ultra是客户端推理预设,提供商请求统一映射为max;其余自定义强度保持精确字符串语义。reasoning.summary的传输值限定为auto|concise|detailed;配置值none表达字段缺省,并同步省略stream_options.reasoning_summary_delivery。supports_reasoning_summary_parameter控制 summary 投影;能力值为false时,effort、context、reasoning 包络和加密 reasoning 内容仍按各自能力处理。/models元数据进入统一能力解析器,采用区分大小写的精确匹配和最长前缀匹配。远程字段覆盖对应内置字段,缺失字段复用内置能力,未知模型使用保守能力集合。Codex Responses 请求
client_version=0.144.1;Codex 提供商边界使用user-agent: codex_cli_rs/0.144.1与originator: codex_cli_rs。tool_choice缺省时写入auto,显式值保持调用方语义;store=false、加密 reasoning include、服务层级过滤、开发者指令、工具投影、图片 detail 清理和内部请求头均由统一 Codex 请求契约生成。reasoning.context=all_turns,保留 function、namespace、custom 工具以及客户端 tool search 语义。prompt_cache_key只采用显式配置或线程标识;input item id 透明保留客户端提供的值。Claude 工具错误到 Responses 的协议映射
ToolResult.is_error保留为格式无关的内部语义;OpenAI Responses 的function_call_output只写入协议字段type、call_id、output。output表达:非空内容编码为[tool error]\n<detail>,空内容编码为[tool error]。字符串、对象和多段 Claude 内容遵循同一规则。function_call_output.output,图片和文件继续使用既有的额外 user content 投影,错误标识不会改变媒体可表示性与顺序。is_error=false的输出保持现有语义。Responses Compact
Compact 采用独立的精确字段投影,传输体仅包含:
modelinputinstructionstoolsparallel_tool_callsreasoningservice_tierprompt_cache_keytextstore、client_metadata、include、stream、stream_options、tool_choice不进入 Compact 传输体。body rules 无权向终态请求引入投影集合之外的字段。Compact 使用同步 unary 响应、Codex OAuth 通道和x-codex-turn-state,请求侧不启用 zstd 与 SSE headers。Codex Search
OpenAiSearch作为正式FormatId注册,公开入口为/v1/alpha/search,Codex 上游路径为/backend-api/codex/alpha/search。id、model、reasoning、input、commands、settings、max_output_tokens;结构化子对象使用明确 allowlist,input支持字符串与 Responses item 数组。4xx与429为终态响应;5xx与传输错误进入候选故障转移,语义与 Codex Search 客户端保持一致。null无限制范围按全部现存端点计算,停用端点仍能展示密钥关联;Codex OAuth 等继承型密钥只继承启用端点。Responses → Search单向覆盖和[]拒绝全部语义在两类统计中保持一致。超时配置与执行链路
300s,用户可配置上限为1200s。30s,可配置上限为300s。1200s同步执行默认值。900s、1200s会沿执行计划、Gateway 内嵌 relay、独立 tunnel 与 owner relay 元数据原值传递,执行层不进行300s或600s静默截断。400,不会转为无界请求或替换成其他超时值。该边界允许 Flex 任务采用官方示例中的
timeout=900,同时保持普通请求和流式请求的默认行为。Gateway 自动并发编译边界
max_in_flight_requests仍具有配置优先级。automatic_gateway_request_concurrency_for_parallelism只为确定性单元测试提供无文件描述符输入的便捷入口,使用#[cfg(test)]限定到测试构建。生产二进制继续调用容量与文件描述符共同参与的运行时函数。Usage 生命周期一致性
failed、cancelled、completed终态保持单调,不受晚到的pending或streaming覆盖。failed|cancelled / void只接受completed / pending作为权威恢复事实;该规则允许最终成功结果纠正失败记录,同时拒绝 active 占位、response-start 和非待结算完成事件重开终态。服务层级、提示缓存与计费
fast指令映射为 OpenAIpriority请求事实;processing tier 支持标准、priority、flex 以及配置中声明的扩展层级。272000token 使用短上下文价格,272001token 起使用长上下文价格。Priority 仅配置官方支持的短上下文区间,超出区间返回无计价规则。5 / 0.5 / 6.25 / 302.5 / 0.25 / 3.125 / 1510 / 1 / 12.5 / 602.5 / 0.25 / 3.125 / 151.25 / 0.125 / 1.5625 / 7.55 / 0.5 / 6.25 / 301 / 0.1 / 1.25 / 60.5 / 0.05 / 0.625 / 32 / 0.2 / 2.5 / 1210 / 1 / 12.5 / 455 / 0.5 / 6.25 / 22.55 / 0.5 / 6.25 / 22.52.5 / 0.25 / 3.125 / 11.252 / 0.2 / 2.5 / 91 / 0.1 / 1.25 / 4.5aether-billing的统一计价能力解析。ExecutionPlan形成后、上游网络请求前,并依据请求可达的价格目录与上下文区间计算可证明的费用上界。prompt_cache_options支持mode=implicit|explicit和ttl=30m。最终出站body.model是能力解析的第一事实源;有效 TTL 进入受控 Usage metadata,授权估算和终态结算使用同一事实。结构化价格导入与管理界面
TieredPricingConfig;tier.size按起始边界转换为 Aether 的包含式up_to。size=0从首个上下文阶梯开始;重复边界、负数、非安全整数和非有限价格按失败关闭处理。实验模式缺少完整适用范围时不会被推导为 processing-tier 目录。ultra -> max映射。架构决策
协议是一等类型。 Search 进入格式注册、路由、权限、候选调度和传输适配器,避免在 URL 或模型名分支中维护隐式特例。
能力与格式规则各有单一入口。 模型映射后的实际模型、远程模型卡和内置模型卡统一形成能力对象,reasoning、服务层级、缓存和工具校验共同消费该对象。Gateway 的纯格式分类、权限覆盖和列表交集统一通过
ai_servingpure facade 暴露。传输投影按协议封闭。 Responses、Compact、Search 各自定义终态字段集合;共享规范化发生在投影前,body rules 不能突破协议边界。
兼容权限与端点身份分离。 单向 companion permission 只表达授权覆盖关系,路由选择和上游端点仍保持精确身份,防止格式兼容演变为协议替换。
超时默认值与配置上限分离。 默认行为属于协议运行语义,上限属于管理配置约束;执行层只传递经过校验的显式值。
计费使用响应事实。 请求 service tier 表达意图,响应 service tier 决定结算;价格目录用结构化上下文区间表达官方边界,缺少适用规则时显式失败。
前后端共享可解释规则。 前端以相同格式权限、默认路径和 pricing tier 结构组织配置,后端仍是终态校验和执行事实的权威边界。
生命周期以因果事实收敛。 后台写入可以并行执行,非终态事件不能反向覆盖终态;完成事件保留纠正 void failure 的能力,状态正确性不依赖运行时调度先后。
工具错误由目标协议的合法载荷表达。 Canonical 层保存来源协议语义,Responses 边界使用
output字符串传递成功或失败信息,不向 wire item 添加目标协议未定义的字段。请求、Compact 和响应构造共享同一编码真源。对齐依据
验证
cargo fmt --all -- --checkgit diff --check origin/maincargo clippy -p aether-gateway --lib --bins --examples -- -D warningscargo clippy -p aether-data --all-targets -- -D warningscargo clippy --workspace --exclude aether-gateway --exclude aether-data --all-targets -- -D warningsaether-ai-formats单元测试:699 项通过,覆盖 Claude 错误工具结果的字符串、空内容、对象、多段文本与图片,以及普通 Responses、Responses Compact 和响应构造aether-data单元测试:483 项通过provider-transport单元测试:357 项通过scheduler-core单元测试:86 项通过900s超时传递RequestMetaenvelope 并校验 trace、header 与完整原始字节ai_serving依赖边界架构守卫通过Codex 重置请求体
idempotency_key表达确认操作的稳定身份;前端使用crypto.randomUUID()生成该值并随请求传入。codex_reset_credit_consume纳入管理写路由的统一 body 缓冲矩阵,JSON 请求体在本地管理路由执行前完成读取与规范化。redeem_request_id,请求目标为/backend-api/wham/rate-limit-reset-credits/consume。idempotency_key校验。决策依据
参考资料
验证
admin_codex_reset_credit_consume_buffers_idempotency_key_body路由契约测试通过。Codex Remote Compact 与 Responses Compaction V2
openai:responses的格式权限覆盖openai:responses:compact,使已授权 Responses 的用户、用户组、API Key 与 provider key 能够调用 Responses Compact 端点;openai:responses:compact保持更窄的独立范围,不反向授权普通 Responses。openai:responses传输,并在input中携带type: "compaction_trigger"项;端点、API format 与上游 URL 均保持为普通 Responses。provider_model_mappings.operations提供可选操作作用域。缺省映射覆盖全部操作,["compact"]仅匹配压缩;相同优先级下,匹配操作作用域的映射优先于通用映射。request_type复用同一识别函数,进行态与终态记录均可表达compact。决策依据
传输协议和请求操作分离:协议层继续使用 Aether 已有的 Responses 注册、权限和路由链路,操作层只为显式配置的模型映射与可观测性提供选择条件。模型选择由管理配置决定,不根据 URL、模型名称或客户端身份隐式改写请求。
验证
cargo fmt --all -- --check通过。cargo clippy -p aether-gateway --lib --bins --examples -- -D warnings通过。resolves_compaction_trigger_as_compact_operation_on_responses_transport、operation_scoped_mapping_overrides_generic_mapping_for_compaction、paged_preselection_prefers_operation_scoped_mapping_for_compaction、candidate_page_cache_key_isolates_auth_model_format_and_capabilities定向回归通过。ai_serving_crate_api_is_confined_to_root_seams与paged_preselection_prefers_operation_scoped_mapping_for_compaction在RUST_MIN_STACK=16777216下通过。参考资料