feat: Codex 供应商级覆写 reasoning/text/parallel_tool_calls (#404)#536
feat: Codex 供应商级覆写 reasoning/text/parallel_tool_calls (#404)#536
Conversation
Summary of ChangesHello @ding113, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求为 Codex 类型供应商引入了一项重要增强功能,允许管理员为关键 API 参数(如推理强度、推理摘要、文本详细程度和并行工具调用)定义全局覆写偏好。这提供了对 Codex 模型行为更细粒度的控制,确保无论客户端设置如何,通过特定供应商路由的所有请求都能获得一致的响应或特定的性能特征。这些更改涵盖了数据库架构更新、管理面板的 UI 集成以及在请求处理过程中应用这些覆写的核心逻辑。 Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 Walkthrough走查本 PR 为 Codex 类型的供应商添加了推理等级、推理总结、文本冗余度和并行工具调用的偏好设置功能。在多个层级引入了新的配置选项、数据库字段、类型定义和 UI 组件,允许按供应商覆盖 Codex API 的相关参数。 变更
估计代码审查工作量🎯 3 (中等) | ⏱️ ~20 分钟 Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro Cache: Disabled due to Reviews > Disable Cache setting 📥 CommitsReviewing files that changed from the base of the PR and between 3f33b353a38edb507034ff94bee9975db53b2d70 and 1dfe79c. 📒 Files selected for processing (22)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (12)
🧰 Additional context used📓 Path-based instructions (15)**/*.{ts,tsx,js,jsx,json}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
messages/**/*.json📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{tsx,json}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/**/*.ts📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/**/*provider*.ts📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/lib/**/*.ts📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/actions/**/*.ts📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/{repository,actions}/**/*.ts📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/**/*.{tsx,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/drizzle/**/*.ts📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.test.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.test.ts📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/repository/**/*.ts📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (6)📚 Learning: 2026-01-03T09:08:20.573ZApplied to files:
📚 Learning: 2026-01-03T09:08:20.573ZApplied to files:
📚 Learning: 2026-01-03T09:08:49.019ZApplied to files:
📚 Learning: 2026-01-03T09:08:49.019ZApplied to files:
📚 Learning: 2026-01-03T09:08:49.019ZApplied to files:
📚 Learning: 2026-01-03T09:08:49.019ZApplied to files:
🧬 Code graph analysis (5)src/lib/codex/provider-overrides.ts (1)
src/actions/providers.ts (1)
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx (5)
tests/unit/proxy/codex-provider-overrides.test.ts (1)
src/repository/provider.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (25)
Comment |
🧪 测试结果
总体结果: ✅ 所有测试通过 |
There was a problem hiding this comment.
Code Review
本次 PR 实现了 Codex 类型供应商的供应商级参数覆写功能,新增了 reasoning.effort, reasoning.summary, text.verbosity 和 parallel_tool_calls 四个可选项。整体实现非常完整,涵盖了数据库迁移、后端逻辑、前端 UI 和多语言支持。
主要变更点包括:
- 数据库:在
providers表中新增了对应的偏好设定字段。 - 后端:在请求转发阶段加入了覆写逻辑,并确保了在请求清洗后执行,逻辑清晰。
- 前端:在供应商编辑页面为 Codex 类型供应商增加了相应的配置项,并提供了 Tooltip 说明,用户体验良好。
- 测试:新增了覆盖覆写逻辑的单元测试,并补充了对
parallel_tool_calls透传的测试,保证了代码质量。
代码整体质量很高,逻辑清晰,考虑周全。我只发现一处可以改进的地方,即在前端表单组件中存在一些重复代码,已在具体评论中提出了重构建议,以提高代码的可维护性。
做得很好!
| <div className="space-y-2"> | ||
| <FieldLabelWithTooltip | ||
| label={t("sections.routing.codexOverrides.reasoningSummary.label")} | ||
| tooltip={t("sections.routing.codexOverrides.reasoningSummary.help")} | ||
| /> | ||
| <Select | ||
| value={codexReasoningSummaryPreference} | ||
| onValueChange={(val) => | ||
| setCodexReasoningSummaryPreference( | ||
| val as CodexReasoningSummaryPreference | ||
| ) | ||
| } | ||
| disabled={isPending} | ||
| > | ||
| <SelectTrigger className="w-full"> | ||
| <SelectValue placeholder="inherit" /> | ||
| </SelectTrigger> | ||
| <SelectContent> | ||
| <SelectItem value="inherit"> | ||
| {t( | ||
| "sections.routing.codexOverrides.reasoningSummary.options.inherit" | ||
| )} | ||
| </SelectItem> | ||
| <SelectItem value="auto"> | ||
| {t("sections.routing.codexOverrides.reasoningSummary.options.auto")} | ||
| </SelectItem> | ||
| <SelectItem value="detailed"> | ||
| {t( | ||
| "sections.routing.codexOverrides.reasoningSummary.options.detailed" | ||
| )} | ||
| </SelectItem> | ||
| </SelectContent> | ||
| </Select> | ||
| </div> | ||
|
|
||
| <div className="space-y-2"> | ||
| <FieldLabelWithTooltip | ||
| label={t("sections.routing.codexOverrides.textVerbosity.label")} | ||
| tooltip={t("sections.routing.codexOverrides.textVerbosity.help")} | ||
| /> | ||
| <Select | ||
| value={codexTextVerbosityPreference} | ||
| onValueChange={(val) => | ||
| setCodexTextVerbosityPreference(val as CodexTextVerbosityPreference) | ||
| } | ||
| disabled={isPending} | ||
| > | ||
| <SelectTrigger className="w-full"> | ||
| <SelectValue placeholder="inherit" /> | ||
| </SelectTrigger> | ||
| <SelectContent> | ||
| <SelectItem value="inherit"> | ||
| {t("sections.routing.codexOverrides.textVerbosity.options.inherit")} | ||
| </SelectItem> | ||
| <SelectItem value="low"> | ||
| {t("sections.routing.codexOverrides.textVerbosity.options.low")} | ||
| </SelectItem> | ||
| <SelectItem value="medium"> | ||
| {t("sections.routing.codexOverrides.textVerbosity.options.medium")} | ||
| </SelectItem> | ||
| <SelectItem value="high"> | ||
| {t("sections.routing.codexOverrides.textVerbosity.options.high")} | ||
| </SelectItem> | ||
| </SelectContent> | ||
| </Select> | ||
| </div> | ||
|
|
||
| <div className="space-y-2"> | ||
| <FieldLabelWithTooltip | ||
| label={t("sections.routing.codexOverrides.parallelToolCalls.label")} | ||
| tooltip={t("sections.routing.codexOverrides.parallelToolCalls.help")} | ||
| /> | ||
| <Select | ||
| value={codexParallelToolCallsPreference} | ||
| onValueChange={(val) => | ||
| setCodexParallelToolCallsPreference( | ||
| val as CodexParallelToolCallsPreference | ||
| ) | ||
| } | ||
| disabled={isPending} | ||
| > | ||
| <SelectTrigger className="w-full"> | ||
| <SelectValue placeholder="inherit" /> | ||
| </SelectTrigger> | ||
| <SelectContent> | ||
| <SelectItem value="inherit"> | ||
| {t( | ||
| "sections.routing.codexOverrides.parallelToolCalls.options.inherit" | ||
| )} | ||
| </SelectItem> | ||
| <SelectItem value="true"> | ||
| {t("sections.routing.codexOverrides.parallelToolCalls.options.true")} | ||
| </SelectItem> | ||
| <SelectItem value="false"> | ||
| {t("sections.routing.codexOverrides.parallelToolCalls.options.false")} | ||
| </SelectItem> | ||
| </SelectContent> | ||
| </Select> | ||
| </div> | ||
| </div> |
There was a problem hiding this comment.
你好,感谢你的贡献!
我注意到在 provider-form.tsx 文件中,用于 Codex 参数覆写的四个下拉选择框(Select 组件)存在较多重复代码。从 1061 行到 1202 行,每个选择框的结构(div, FieldLabelWithTooltip, Select)都非常相似。
为了提高代码的可读性和可维护性,我建议将这部分逻辑提取为一个可复用的组件,例如 CodexOverrideSelect。这个新组件可以接收 label, tooltip, value, onValueChange, options 和 disabled 等属性。
下面是一个简单的实现示例:
// 定义一个可复用的选择框组件
function CodexOverrideSelect({
label,
tooltip,
value,
onValueChange,
options,
disabled,
}: {
label: string;
tooltip: string;
value: string;
onValueChange: (value: string) => void;
options: { value: string; label: string }[];
disabled: boolean;
}) {
return (
<div className="space-y-2">
<FieldLabelWithTooltip label={label} tooltip={tooltip} />
<Select value={value} onValueChange={onValueChange} disabled={disabled}>
<SelectTrigger className="w-full">
<SelectValue placeholder="inherit" />
</SelectTrigger>
<SelectContent>
{options.map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.label}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
);
}
// 在你的表单中使用它
const reasoningEffortOptions = [
{ value: "inherit", label: t("sections.routing.codexOverrides.reasoningEffort.options.inherit") },
{ value: "minimal", label: t("sections.routing.codexOverrides.reasoningEffort.options.minimal") },
// ... 其他选项
];
<CodexOverrideSelect
label={t("sections.routing.codexOverrides.reasoningEffort.label")}
tooltip={t("sections.routing.codexOverrides.reasoningEffort.help")}
value={codexReasoningEffortPreference}
onValueChange={(val) => setCodexReasoningEffortPreference(val as CodexReasoningEffortPreference)}
options={reasoningEffortOptions}
disabled={isPending}
/>这样做可以显著减少重复代码,并使表单的结构更加清晰。
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/app/v1/_lib/converters/openai-to-codex/request.ts (1)
17-18: 同步更新注释以匹配parallel_tool_calls新语义
- 代码现在逻辑是:
parallel_tool_calls默认true,但如果请求体里显式提供布尔值,则尊重客户端设置,这非常合理,也与 Codex 覆写机制兼容。- 顶部注释仍写着「强制设置:... parallel_tool_calls=true」,与实际行为不符,容易误导后续维护。
建议把行 17 的说明改成类似:
- * - 强制设置:stream=true, store=false, parallel_tool_calls=true + * - 强制设置:stream=true, store=false;parallel_tool_calls 默认 true,可被客户端显式关闭以保持实现与文档一致。
Also applies to: 129-132
🧹 Nitpick comments (6)
messages/ja/settings.json (1)
1157-1199: 日语翻译结构完整,建议验证术语一致性新增的
codexOverrides配置项结构完整,包含了 4 个覆写选项组。以下是几点建议:
术语一致性:请确保以下术语在所有日语翻译文件中保持一致:
- "オーバーライド" (override)
- "クライアントに従う" (inherit/follow client)
- "強制" (force)
选项值格式:注意 line 1168 使用了
none(GPT-5.1 のみ),而 line 1167 使用了xhigh(GPT-5.1-Codex-Max のみ)。建议确认这种括号内的模型限制说明在所有相关选项中格式一致。建议添加验证:由于这是面向用户的配置界面,建议与日语母语者确认以下术语的准确性:
- "推論強度" (reasoning effort)
- "推論サマリー" (reasoning summary)
- "出力の詳細度" (text verbosity)
- "並列ツール呼び出し" (parallel tool calls)
基于 learnings,请确保该翻译与其他 4 个 locale (en, ja, ru, zh-CN, zh-TW) 中的对应配置保持结构一致性。
tests/unit/proxy/codex-request-sanitizer.test.ts (1)
25-37: 测试覆盖不完整,建议补充正向用例当前测试仅验证了
parallel_tool_calls=false的场景,建议补充以下测试用例以确保完整覆盖:
显式设置为
true的场景:验证当客户端显式设置parallel_tool_calls=true时,该值也被保留而不是被重新赋值。未定义场景的回归测试:验证当
parallel_tool_calls未设置时,默认值仍为true(确保向后兼容)。🔎 建议的补充测试用例
+ it("当客户端显式设置 parallel_tool_calls=true 时应保留", async () => { + const input: Record<string, unknown> = { + instructions: "abc", + parallel_tool_calls: true, + }; + + const output = await sanitizeCodexRequest(input, "gpt-5-codex", "auto", 1, { + isOfficialClient: false, + }); + + expect(output.parallel_tool_calls).toBe(true); + }); + + it("当客户端未设置 parallel_tool_calls 时应默认为 true", async () => { + const input: Record<string, unknown> = { + instructions: "abc", + }; + + const output = await sanitizeCodexRequest(input, "gpt-5-codex", "auto", 1, { + isOfficialClient: false, + }); + + expect(output.parallel_tool_calls).toBe(true); + });tests/unit/proxy/openai-to-codex-request.test.ts (1)
41-49: 测试覆盖与前一文件存在相同问题此测试用例仅验证了
parallel_tool_calls=false的透传场景,建议补充以下用例:
- 显式
true场景:验证parallel_tool_calls=true也被正确透传- 默认值场景:验证未设置时默认为
true- 非布尔值场景:验证传入其他类型(如字符串、数字)时的容错处理
根据相关代码片段,转换器逻辑为:
output.parallel_tool_calls = (typeof req.parallel_tool_calls === "boolean") ? req.parallel_tool_calls : true建议添加测试用例验证这个完整的条件分支逻辑。
🔎 建议的补充测试用例
+ it("当输入显式设置 parallel_tool_calls=true 时,应透传到 Codex 请求", () => { + const input: Record<string, unknown> = { + messages: [{ role: "user", content: "你好" }], + parallel_tool_calls: true, + }; + + const output = transformOpenAIRequestToCodex("gpt-5-codex", input, true) as any; + expect(output.parallel_tool_calls).toBe(true); + }); + + it("当输入未设置 parallel_tool_calls 时,应默认为 true", () => { + const input: Record<string, unknown> = { + messages: [{ role: "user", content: "你好" }], + }; + + const output = transformOpenAIRequestToCodex("gpt-5-codex", input, true) as any; + expect(output.parallel_tool_calls).toBe(true); + });drizzle/0045_add_codex_provider_overrides.sql (1)
1-4: 数据库迁移结构合理,建议添加约束验证新增的 4 个字段设计合理,采用 nullable 列来表示"继承客户端设置"的语义。以下是几点建议:
考虑添加 CHECK 约束:虽然应用层会进行验证,但数据库层的约束可以提供额外的数据完整性保障:
ALTER TABLE "providers" ADD CONSTRAINT "codex_reasoning_effort_check" CHECK (codex_reasoning_effort_preference IN ('minimal', 'low', 'medium', 'high', 'xhigh', 'none') OR codex_reasoning_effort_preference IS NULL);VARCHAR 长度验证:
varchar(20)足够存储所有选项值(最长的是 "detailed")varchar(10)足够存储 "true"/"false"/"high" 等值- ✓ 长度设置合理
缺少回滚脚本:建议在同一目录下创建对应的
down迁移脚本,以便在需要时回滚:ALTER TABLE "providers" DROP COLUMN "codex_parallel_tool_calls_preference"; ALTER TABLE "providers" DROP COLUMN "codex_text_verbosity_preference"; ALTER TABLE "providers" DROP COLUMN "codex_reasoning_summary_preference"; ALTER TABLE "providers" DROP COLUMN "codex_reasoning_effort_preference";根据 coding guidelines,请确认此迁移脚本已在包含 'test' 关键字的测试数据库中验证通过。
src/drizzle/schema.ts (1)
244-250: Codex 覆写字段定义合理,可考虑后续加强约束
- 四个字段均为可空
varchar,与注释中「null / 'inherit' 表示跟随客户端」的语义一致;UI 配置的可选值长度也都在length限制内,设计没问题。- 为保持灵活性用
varchar是可以接受的,但从数据一致性角度,未来可以考虑:
- 用 PostgreSQL
enum或check约束约束取值(如'inherit' | 'minimal' | ...),避免非法字符串混入。- 在 TypeScript 层对应这些字段定义成窄化 union 类型,减少魔法字符串。
这些都属于后续增强项,不影响当前 PR 的正确性。
tests/unit/proxy/codex-provider-overrides.test.ts (1)
1-124: 可选:改进测试中的类型安全性测试代码中多处使用
as any来绕过类型检查(第 19、42、66、84、102、120 行)。虽然这在测试代码中是可接受的做法,但可以考虑定义一个测试辅助类型来提高类型安全性。🔎 可选的重构方案
在测试文件顶部定义测试辅助类型:
+import type { CodexProviderOverrideConfig } from "@/lib/codex/provider-overrides"; + +type TestProviderConfig = Partial<CodexProviderOverrideConfig> & { + providerType: string; +}; + describe("Codex 供应商级参数覆写", () => { it("当 providerType 不是 codex 时,应直接返回原对象且不做任何处理", () => { - const provider = { + const provider: TestProviderConfig = { providerType: "claude", codexReasoningEffortPreference: "high", codexParallelToolCallsPreference: "false", }; // ... - const output = applyCodexProviderOverrides(provider as any, input); + const output = applyCodexProviderOverrides(provider as CodexProviderOverrideConfig, input);这样可以保留类型提示,同时避免完全绕过类型检查。
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to Reviews > Disable Cache setting
📥 Commits
Reviewing files that changed from the base of the PR and between d302935 and ef2c82c83c92b72a5565e8b132ea31d0f42cc82d.
📒 Files selected for processing (20)
drizzle/0045_add_codex_provider_overrides.sqlmessages/en/settings.jsonmessages/ja/settings.jsonmessages/ru/settings.jsonmessages/zh-CN/settings.jsonmessages/zh-TW/settings.jsonsrc/actions/providers.tssrc/app/[locale]/settings/providers/_components/forms/provider-form.tsxsrc/app/v1/_lib/codex/utils/request-sanitizer.tssrc/app/v1/_lib/converters/openai-to-codex/request.tssrc/app/v1/_lib/proxy/forwarder.tssrc/drizzle/schema.tssrc/lib/codex/provider-overrides.tssrc/lib/validation/schemas.tssrc/repository/_shared/transformers.tssrc/repository/provider.tssrc/types/provider.tstests/unit/proxy/codex-provider-overrides.test.tstests/unit/proxy/codex-request-sanitizer.test.tstests/unit/proxy/openai-to-codex-request.test.ts
🧰 Additional context used
📓 Path-based instructions (20)
**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (CLAUDE.md)
Use 2-space indentation in all code files
Files:
src/app/v1/_lib/codex/utils/request-sanitizer.tssrc/app/v1/_lib/converters/openai-to-codex/request.tssrc/app/v1/_lib/proxy/forwarder.tstests/unit/proxy/openai-to-codex-request.test.tsmessages/zh-CN/settings.jsonsrc/lib/codex/provider-overrides.tsmessages/zh-TW/settings.jsontests/unit/proxy/codex-provider-overrides.test.tssrc/repository/provider.tsmessages/en/settings.jsonsrc/lib/validation/schemas.tssrc/actions/providers.tssrc/types/provider.tssrc/app/[locale]/settings/providers/_components/forms/provider-form.tsxmessages/ru/settings.jsontests/unit/proxy/codex-request-sanitizer.test.tssrc/repository/_shared/transformers.tssrc/drizzle/schema.tsmessages/ja/settings.json
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx,js,jsx}: Use double quotes for strings instead of single quotes
Use trailing commas in multi-line structures
Enforce maximum line length of 100 characters
Use path alias@/*to reference files from./src/*directory
**/*.{ts,tsx,js,jsx}: Use Biome for linting and formatting with 2-space indent, double quotes, trailing commas, and 100 character max line length
Use path alias@/*to reference files in./src/*directory
Files:
src/app/v1/_lib/codex/utils/request-sanitizer.tssrc/app/v1/_lib/converters/openai-to-codex/request.tssrc/app/v1/_lib/proxy/forwarder.tstests/unit/proxy/openai-to-codex-request.test.tssrc/lib/codex/provider-overrides.tstests/unit/proxy/codex-provider-overrides.test.tssrc/repository/provider.tssrc/lib/validation/schemas.tssrc/actions/providers.tssrc/types/provider.tssrc/app/[locale]/settings/providers/_components/forms/provider-form.tsxtests/unit/proxy/codex-request-sanitizer.test.tssrc/repository/_shared/transformers.tssrc/drizzle/schema.ts
src/app/v1/_lib/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Guard pipeline must execute in order: ProxyAuthenticator, SensitiveWordGuard, VersionGuard, ProxySessionGuard, ProxyRateLimitGuard, ProxyProviderResolver
Files:
src/app/v1/_lib/codex/utils/request-sanitizer.tssrc/app/v1/_lib/converters/openai-to-codex/request.tssrc/app/v1/_lib/proxy/forwarder.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript strict mode for type safety
Use readonly or const assertions for immutable data structures
Files:
src/app/v1/_lib/codex/utils/request-sanitizer.tssrc/app/v1/_lib/converters/openai-to-codex/request.tssrc/app/v1/_lib/proxy/forwarder.tstests/unit/proxy/openai-to-codex-request.test.tssrc/lib/codex/provider-overrides.tstests/unit/proxy/codex-provider-overrides.test.tssrc/repository/provider.tssrc/lib/validation/schemas.tssrc/actions/providers.tssrc/types/provider.tssrc/app/[locale]/settings/providers/_components/forms/provider-form.tsxtests/unit/proxy/codex-request-sanitizer.test.tssrc/repository/_shared/transformers.tssrc/drizzle/schema.ts
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.ts: Hash API keys using SHA-256 before storing in database, never store plaintext keys
Mask API keys and sensitive data in application logs
Validate required environment variables at startup with clear error messages
Files:
src/app/v1/_lib/codex/utils/request-sanitizer.tssrc/app/v1/_lib/converters/openai-to-codex/request.tssrc/app/v1/_lib/proxy/forwarder.tssrc/lib/codex/provider-overrides.tssrc/repository/provider.tssrc/lib/validation/schemas.tssrc/actions/providers.tssrc/types/provider.tssrc/repository/_shared/transformers.tssrc/drizzle/schema.ts
src/app/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Implement Content-Security-Policy headers for XSS prevention
Files:
src/app/v1/_lib/codex/utils/request-sanitizer.tssrc/app/v1/_lib/converters/openai-to-codex/request.tssrc/app/v1/_lib/proxy/forwarder.ts
src/app/v1/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use Hono router for ultrafast, lightweight routing in proxy endpoints
Files:
src/app/v1/_lib/codex/utils/request-sanitizer.tssrc/app/v1/_lib/converters/openai-to-codex/request.tssrc/app/v1/_lib/proxy/forwarder.ts
src/app/v1/_lib/converters/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Use Registry pattern in format converters to map conversion pairs between Claude, OpenAI, Codex, and Gemini APIs
Files:
src/app/v1/_lib/converters/openai-to-codex/request.ts
src/app/v1/_lib/proxy/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/app/v1/_lib/proxy/**/*.ts: Implement guard pipeline pattern for cross-cutting concerns in request processing (auth, rate limiting, session)
Use undici library for HTTP requests instead of node-fetch for better performance
Files:
src/app/v1/_lib/proxy/forwarder.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Vitest for unit testing with Node environment, coverage thresholds: 50% lines/functions, 40% branches
Files:
tests/unit/proxy/openai-to-codex-request.test.tstests/unit/proxy/codex-provider-overrides.test.tstests/unit/proxy/codex-request-sanitizer.test.ts
**/*.test.ts
📄 CodeRabbit inference engine (AGENTS.md)
Ensure test database names contain 'test' keyword for safety validation
Files:
tests/unit/proxy/openai-to-codex-request.test.tstests/unit/proxy/codex-provider-overrides.test.tstests/unit/proxy/codex-request-sanitizer.test.ts
messages/**/*.json
📄 CodeRabbit inference engine (CLAUDE.md)
Support 5 locales via next-intl: en, ja, ru, zh-CN, zh-TW with messages in
messages/{locale}/*.jsonStore message translations in
messages/{locale}/*.jsonfiles
Files:
messages/zh-CN/settings.jsonmessages/zh-TW/settings.jsonmessages/en/settings.jsonmessages/ru/settings.jsonmessages/ja/settings.json
**/*.{tsx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Use next-intl for internationalization with 5 locales: en, ja, ru, zh-CN, zh-TW
Files:
messages/zh-CN/settings.jsonmessages/zh-TW/settings.jsonmessages/en/settings.jsonsrc/app/[locale]/settings/providers/_components/forms/provider-form.tsxmessages/ru/settings.jsonmessages/ja/settings.json
src/**/*provider*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Set provider circuit breaker failure threshold, open duration, and half-open success threshold in configuration
Files:
src/lib/codex/provider-overrides.tssrc/repository/provider.tssrc/actions/providers.tssrc/types/provider.ts
src/lib/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use connection pooling for database and Redis connections
Files:
src/lib/codex/provider-overrides.tssrc/lib/validation/schemas.ts
src/repository/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Use Repository pattern in
src/repository/to wrap Drizzle queries
Files:
src/repository/provider.tssrc/repository/_shared/transformers.ts
src/{repository,actions}/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Avoid N+1 queries by using eager loading and batch queries for statistics
Files:
src/repository/provider.tssrc/actions/providers.tssrc/repository/_shared/transformers.ts
src/actions/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/actions/**/*.ts: Validate all user inputs with Zod schemas before processing
Use Server Actions innext-safe-actionwith OpenAPI generation for admin API endpoints
Use Next.js API Routes and Server Actions for admin operations and REST endpoints
Files:
src/actions/providers.ts
src/**/*.{tsx,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.{tsx,jsx}: Uselucide-reactfor icons, no custom SVGs
Use React's automatic escaping to prevent XSS vulnerabilities
Files:
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx
src/drizzle/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Use Drizzle ORM with PostgreSQL for database operations
src/drizzle/**/*.ts: Use Drizzle ORM with parameterized queries to prevent SQL injection
Use soft delete pattern withdeletedAtcolumn instead of hard deletes
Use JSON columns in PostgreSQL for flexible data structures (modelRedirects, providerChain, etc.)
Implement proper indexing strategy for common queries and foreign keys
Files:
src/drizzle/schema.ts
🧠 Learnings (13)
📚 Learning: 2026-01-03T09:08:20.573Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T09:08:20.573Z
Learning: Applies to src/app/v1/_lib/proxy-handler.ts : Structure request flow in proxy handler through: ProxySession.fromContext() -> detectFormat() -> GuardPipelineBuilder.run() -> ProxyForwarder.send() -> ProxyResponseHandler.dispatch()
Applied to files:
src/app/v1/_lib/proxy/forwarder.ts
📚 Learning: 2026-01-03T09:08:49.019Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-03T09:08:49.019Z
Learning: Applies to src/app/v1/_lib/proxy/**/*.ts : Implement guard pipeline pattern for cross-cutting concerns in request processing (auth, rate limiting, session)
Applied to files:
src/app/v1/_lib/proxy/forwarder.ts
📚 Learning: 2026-01-03T09:08:49.019Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-03T09:08:49.019Z
Learning: Applies to src/app/v1/_lib/proxy/**/*.ts : Use undici library for HTTP requests instead of node-fetch for better performance
Applied to files:
src/app/v1/_lib/proxy/forwarder.ts
📚 Learning: 2026-01-03T09:08:49.019Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-03T09:08:49.019Z
Learning: Applies to src/app/v1/_lib/proxy/*handler*.ts : Stream responses with proper backpressure handling and chunked transfer encoding
Applied to files:
src/app/v1/_lib/proxy/forwarder.ts
📚 Learning: 2026-01-03T09:08:20.573Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T09:08:20.573Z
Learning: Applies to src/app/v1/_lib/**/*.ts : Guard pipeline must execute in order: ProxyAuthenticator, SensitiveWordGuard, VersionGuard, ProxySessionGuard, ProxyRateLimitGuard, ProxyProviderResolver
Applied to files:
src/app/v1/_lib/proxy/forwarder.ts
📚 Learning: 2026-01-03T09:08:49.019Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-03T09:08:49.019Z
Learning: Applies to src/app/v1/**/*.ts : Use Hono router for ultrafast, lightweight routing in proxy endpoints
Applied to files:
src/app/v1/_lib/proxy/forwarder.ts
📚 Learning: 2026-01-03T09:08:49.019Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-03T09:08:49.019Z
Learning: Applies to src/**/*provider*.ts : Set provider circuit breaker failure threshold, open duration, and half-open success threshold in configuration
Applied to files:
src/app/v1/_lib/proxy/forwarder.tssrc/app/[locale]/settings/providers/_components/forms/provider-form.tsx
📚 Learning: 2026-01-03T09:08:20.573Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T09:08:20.573Z
Learning: Applies to src/lib/circuit-breaker.ts : Circuit Breaker must implement state machine: CLOSED -> OPEN -> HALF_OPEN -> CLOSED with per-provider isolation and Redis persistence
Applied to files:
src/app/v1/_lib/proxy/forwarder.ts
📚 Learning: 2026-01-03T09:08:49.019Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-03T09:08:49.019Z
Learning: Applies to src/lib/circuit-breaker/**/*.ts : Implement circuit breaker state machine with CLOSED -> OPEN -> HALF_OPEN -> CLOSED transitions
Applied to files:
src/app/v1/_lib/proxy/forwarder.ts
📚 Learning: 2026-01-03T09:08:20.573Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T09:08:20.573Z
Learning: Applies to src/components/**/*.{ts,tsx} : Use `lucide-react` for icons instead of custom SVGs
Applied to files:
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx
📚 Learning: 2026-01-03T09:08:49.019Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-03T09:08:49.019Z
Learning: Applies to src/**/*.{tsx,jsx} : Use `lucide-react` for icons, no custom SVGs
Applied to files:
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx
📚 Learning: 2026-01-03T09:08:49.019Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-03T09:08:49.019Z
Learning: Applies to src/components/**/*.{tsx,jsx} : Use shadcn/ui component library for high-quality, accessible UI components
Applied to files:
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx
📚 Learning: 2026-01-03T09:08:20.573Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T09:08:20.573Z
Learning: Applies to messages/**/*.json : Support 5 locales via next-intl: en, ja, ru, zh-CN, zh-TW with messages in `messages/{locale}/*.json`
Applied to files:
messages/ja/settings.json
🧬 Code graph analysis (8)
src/app/v1/_lib/proxy/forwarder.ts (1)
src/lib/codex/provider-overrides.ts (1)
applyCodexProviderOverrides(43-90)
tests/unit/proxy/openai-to-codex-request.test.ts (1)
src/app/v1/_lib/converters/openai-to-codex/request.ts (1)
transformOpenAIRequestToCodex(117-314)
src/lib/codex/provider-overrides.ts (1)
src/types/provider.ts (4)
CodexReasoningEffortPreference(17-24)CodexReasoningSummaryPreference(26-26)CodexTextVerbosityPreference(28-28)CodexParallelToolCallsPreference(31-31)
tests/unit/proxy/codex-provider-overrides.test.ts (1)
src/lib/codex/provider-overrides.ts (1)
applyCodexProviderOverrides(43-90)
src/repository/provider.ts (1)
src/drizzle/schema.ts (1)
providers(129-269)
src/actions/providers.ts (1)
src/types/provider.ts (4)
CodexReasoningEffortPreference(17-24)CodexReasoningSummaryPreference(26-26)CodexTextVerbosityPreference(28-28)CodexParallelToolCallsPreference(31-31)
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx (5)
src/components/ui/label.tsx (1)
Label(21-21)src/components/ui/tooltip.tsx (4)
TooltipProvider(57-57)Tooltip(57-57)TooltipTrigger(57-57)TooltipContent(57-57)scripts/sync-settings-keys.js (2)
p(102-102)t(72-72)src/types/provider.ts (4)
CodexReasoningEffortPreference(17-24)CodexReasoningSummaryPreference(26-26)CodexTextVerbosityPreference(28-28)CodexParallelToolCallsPreference(31-31)src/components/ui/select.tsx (5)
Select(162-162)SelectTrigger(170-170)SelectValue(171-171)SelectContent(163-163)SelectItem(165-165)
tests/unit/proxy/codex-request-sanitizer.test.ts (1)
src/app/v1/_lib/codex/utils/request-sanitizer.ts (1)
sanitizeCodexRequest(59-137)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: Greptile Review
- GitHub Check: pr-description
- GitHub Check: pr-review
- GitHub Check: Docker Build Test
- GitHub Check: 🌐 API Tests
- GitHub Check: check-codex-status
- GitHub Check: dev-build-deploy
🔇 Additional comments (31)
tests/unit/proxy/codex-request-sanitizer.test.ts (1)
36-36: 良好的不可变性验证在 line 36 验证输入对象未被修改是一个很好的实践,确保了函数的纯度。虽然实现中使用了扩展运算符
{...request}来避免突变,但显式测试这一点可以防止未来的回归问题。src/app/v1/_lib/codex/utils/request-sanitizer.ts (1)
123-126: 实现正确,逻辑清晰新的条件默认逻辑正确实现了以下行为:
undefined→true(向后兼容)true→true(保留显式设置)false→false(保留显式关闭)实现方式使用
typeof检查是适当的,可以正确区分undefined和显式的布尔值。这为供应商级别覆写和客户端控制提供了基础。src/app/v1/_lib/proxy/forwarder.ts (1)
12-12: Codex 供应商级覆写挂载位置与顺序合理
- 放在 Codex 分支、且紧跟清洗逻辑之后统一调用
applyCodexProviderOverrides,保证:
- 对非官方客户端:顺序为「格式转换 → Codex 清洗 → 供应商级覆写」,管理员设置优先级最高。
- 对官方 Codex CLI 客户端:即使跳过清洗也仍可在供应商层强制覆写关键参数,符合注释说明。
- 覆写函数内部再按
providerType做一次防护,且使用返回值整体替换session.request.message,不会影响非 Codex provider 的路径。当前实现从行为和解耦上都没看到明显问题,可以保持。
Also applies to: 944-1000
messages/en/settings.json (1)
1262-1304: Codex 覆写文案与后端行为、选项集合一致
- 四组 override(reasoningEffort / reasoningSummary / textVerbosity / parallelToolCalls)的标签、帮助说明和枚举值与后端 schema 中的字段、预期行为对齐,默认都强调 “inherit = follow client”,语义清晰。
- 对于仅在特定模型支持的取值(如
none、xhigh),帮助文案明确标注了限制,有利于降低误配风险。这部分配置作为英文基准文案看起来是准确且完备的。
messages/zh-CN/settings.json (1)
766-808: Codex 覆写中文文案与英文版含义基本一致
- 四个 override 小节的 label / help / options 与英文版一一对应:
reasoningEffort说明了“跟随客户端”与强制覆写的区别,并明确none/xhigh的模型限制。reasoningSummary、textVerbosity、parallelToolCalls也都准确传达了含义和影响。- 术语如「推理等级」「输出冗长度」「并行工具调用」在当前上下文中易于理解,与后端字段含义对应良好。
整体翻译质量和键名保持一致,不会引入行为歧义。
src/lib/validation/schemas.ts (2)
14-25: LGTM:Codex 偏好枚举定义正确新增的四个 Codex 偏好枚举定义合理:
- 统一使用
"inherit"作为不覆写的标识值parallel_tool_calls使用字符串"true"/"false"而非布尔值,便于在 API 和表单中传递- 选项值与类型定义(
src/types/provider.ts)保持一致符合 Zod 4 语法规范。
423-429: LGTM:Schema 集成正确Codex 偏好字段已正确集成到 Provider schemas:
CreateProviderSchema:默认值为"inherit",表示新建的 Provider 默认不覆写客户端参数UpdateProviderSchema:设为optional(),支持部分更新- 字段命名遵循现有约定(schema 层使用 snake_case)
实现符合最佳实践。
Also applies to: 594-597
src/repository/_shared/transformers.ts (1)
102-105: LGTM:Transformer 实现正确新增的 Codex 偏好字段转换逻辑正确:
- 使用空值合并运算符
??将undefined统一转换为null- 字段命名遵循 camelCase 约定
- 与其他可选偏好字段(如
cacheTtlPreference、context1mPreference)的处理方式保持一致实现符合代码库的转换模式。
src/lib/codex/provider-overrides.ts (3)
16-30: LGTM:辅助函数实现合理三个辅助函数设计良好:
isPlainObject:正确区分普通对象与数组和 nullnormalizeStringPreference:将空值和"inherit"标识符统一处理为null(表示不覆写)normalizeParallelToolCallsPreference:将字符串形式的布尔值转换为实际布尔值逻辑清晰,边界情况处理得当。
51-56: 优秀:采用写时复制优化模式
ensureCloned闭包实现了高效的写时复制模式:
- 初始时
output仅是对input的引用- 仅在首次需要修改时才进行浅拷贝
- 避免了不必要的对象克隆开销(当所有偏好都是 inherit 时)
这种模式在可选转换场景中既保证了不可变性,又提供了良好的性能。
58-87: LGTM:覆写逻辑实现正确三个覆写逻辑段落实现得当:
- parallel_tool_calls(58-64 行):直接设置布尔值
- reasoning(66-79 行):
- 正确保留现有 reasoning 对象中的其他字段
- 仅覆写
effort和summary- 当 reasoning 不存在时自动创建
- text(81-87 行):
- 保留现有 text 对象的其他字段
- 仅覆写
verbosity所有逻辑都在
!== null检查后执行,确保只在有明确覆写值时才修改请求。messages/zh-TW/settings.json (1)
1157-1199: LGTM:i18n 配置完整且准确新增的 Codex 覆写配置国际化内容质量高:
- 选项值与 schema 枚举定义完全匹配
- 帮助文本详细说明了各选项的作用和限制(如 xhigh 仅 GPT-5.1-Codex-Max 支持)
- 统一使用"不覆寫(跟隨客戶端)"表示
inherit选项- 繁体中文翻译准确、专业
与其他语言包(en、ja、ru、zh-CN)的结构保持一致。
messages/ru/settings.json (1)
1157-1199: LGTM!Codex 参数覆写的俄语翻译结构完整,遵循了现有的国际化模式。四个配置项(reasoning effort、reasoning summary、text verbosity、parallel tool calls)都提供了标签、帮助文本和选项翻译。
src/repository/provider.ts (5)
54-57: LGTM!Codex 偏好字段的初始化逻辑正确,使用了
?? null默认值模式,与现有的context1mPreference字段保持一致。
102-105: LGTM!
returning子句正确包含了四个新的 Codex 偏好字段,确保创建操作后能返回完整的提供者数据。
161-164: LGTM!所有查询方法(
findProviderList、findAllProviders、findProviderById)都正确添加了四个 Codex 偏好字段的选择,保持了数据获取的完整性。Also applies to: 231-234, 295-298
392-401: LGTM!
updateProvider中的条件更新逻辑正确:
- 使用
!== undefined检查确保只更新显式提供的字段?? null模式正确处理 null 值- 与其他偏好字段的更新模式保持一致
这种模式支持部分更新,不会影响未包含在更新载荷中的字段。
449-452: LGTM!
updateProvider的returning子句正确包含了新字段,确保更新操作返回完整的提供者数据。src/app/[locale]/settings/providers/_components/forms/provider-form.tsx (4)
2-2: LGTM!导入语句正确:
- 使用
lucide-react提供Info图标(符合编码指南)- 从
@/components/ui/tooltip导入 Tooltip 组件(shadcn/ui)- 新增的 Codex 偏好类型导入完整且必要
Also applies to: 34-34, 38-46
173-189: LGTM!Codex 偏好状态初始化正确:
- 默认值使用
"inherit",表示遵循客户端请求(符合设计意图)- 从
sourceProvider读取现有值,支持编辑和克隆场景- 类型注解完整,与导入的类型定义匹配
- 模式与其他偏好字段(如
context1mPreference)保持一致
397-400: LGTM!负载构造正确:
- 编辑负载接口正确定义为可选且可为 null(支持部分更新)
- 创建和编辑负载都正确赋值四个 Codex 偏好字段
- 使用 snake_case 字段名(
codex_reasoning_effort_preference等),与仓储层期望的格式匹配- 类型与状态变量的类型定义一致
Also applies to: 439-442, 503-506
1059-1203: LGTM!Codex 参数覆写 UI 区块实现正确:
结构:
- 仅在
providerType === "codex"时渲染(正确的条件显示)- 包含 4 个配置项,每个都使用 Select 组件
- 布局使用
space-y-4保持适当间距功能:
- 值绑定正确(
value={codexReasoningEffortPreference}等)- 状态更新处理器正确转换类型并调用 setState
- 表单提交期间正确禁用(
disabled={isPending})数据完整性:
- 所有选项值与类型定义匹配:
reasoningEffort: 7 个选项 ✓reasoningSummary: 3 个选项 ✓textVerbosity: 4 个选项 ✓parallelToolCalls: 3 个选项 ✓- 翻译键遵循统一的命名模式
唯一问题:
FieldLabelWithTooltip的TooltipProvider性能问题已在上面单独标记。src/actions/providers.ts (4)
44-51: LGTM!新增的 Codex 偏好类型导入符合预期,类型定义清晰。
227-230: LGTM!getProviders() 正确返回了 4 个新增的 Codex 偏好字段,命名规范一致。
369-372: LGTM!addProvider() 函数签名正确添加了 4 个可选的 Codex 偏好参数,命名和类型定义符合规范。
534-537: 验证确认:UpdateProviderSchema已包含新增 Codex 偏好字段的验证。editProvider() 新增的 4 个可选 Codex 偏好参数已在
UpdateProviderSchema(src/lib/validation/schemas.ts, 第 594-597 行)中正确验证:
codex_reasoning_effort_preference: CODEX_REASONING_EFFORT_PREFERENCE.optional()codex_reasoning_summary_preference: CODEX_REASONING_SUMMARY_PREFERENCE.optional()codex_text_verbosity_preference: CODEX_TEXT_VERBOSITY_PREFERENCE.optional()codex_parallel_tool_calls_preference: CODEX_PARALLEL_TOOL_CALLS_PREFERENCE.optional()所有字段使用 Zod 枚举常量定义,.optional() 修饰符确保了 PATCH 风格更新的语义正确性。验证逻辑完整,符合编码规范。
src/types/provider.ts (5)
119-124: LGTM!Provider 接口正确添加了 4 个 Codex 偏好字段,注释清晰说明了这些字段仅对 Codex 类型供应商有效。
192-195: LGTM!ProviderDisplay 接口正确添加了 4 个 Codex 偏好字段,与 Provider 接口保持一致。
263-266: LGTM!CreateProviderData 接口正确添加了 4 个可选的 Codex 偏好字段,使用 snake_case 命名符合数据库字段规范。
332-335: LGTM!UpdateProviderData 接口正确添加了 4 个可选的 Codex 偏好字段,使用 snake_case 命名符合数据库字段规范。
14-31: 类型定义正确且布尔值转换逻辑完整。已验证
src/lib/codex/provider-overrides.ts中的normalizeParallelToolCallsPreference()函数(第 25-30 行)正确将字符串"true"/"false"转换为布尔值true/false,符合 Codex API 要求。"inherit" 和 null 值正确处理为不覆写(返回 null)。转换逻辑在第 58-64 行应用,并通过完整的测试用例验证。所有代码遵循指导原则:2 空格缩进、双引号、不超过 100 字符行长、TypeScript 严格模式启用。
There was a problem hiding this comment.
Code Review Summary
No significant issues identified in this PR.
PR Size: L
- Lines changed: 830
- Files changed: 20
- Split suggestions: Consider splitting into (1) DB migration + schema/types/validation, (2) Settings UI + i18n strings, (3) Proxy pipeline changes + unit tests.
Review Coverage
- Logic and correctness - Clean
- Security (OWASP Top 10) - Clean
- Error handling - Clean
- Type safety - Clean
- Documentation accuracy - Clean
- Test coverage - Adequate
- Code clarity - Good
Automated review by Codex AI
There was a problem hiding this comment.
- Identified PR
#536(feat: Codex 供应商级覆写 reasoning/text/parallel_tool_calls (#404)), sizeL(830 lines changed across 20 files) and applied labelsize/L. - Completed a diff-only review across the requested perspectives and posted the summary via
gh pr review --commentonhttps://github.com/ding113/claude-code-hub/pull/536. - No inline comments were posted because I did not find any diff-scope issues that cleared the reporting threshold.
There was a problem hiding this comment.
Code Review Summary
This PR implements a well-designed feature adding provider-level parameter overrides for Codex-type providers. The implementation is complete and consistent across all layers (database, repository, actions, UI, i18n).
PR Size: L
- Lines changed: 830 (825 additions + 5 deletions)
- Files changed: 20
Issues Found
| Category | Critical | High | Medium | Low |
|---|---|---|---|---|
| Logic/Bugs | 0 | 0 | 0 | 0 |
| Security | 0 | 0 | 0 | 0 |
| Error Handling | 0 | 0 | 0 | 0 |
| Types | 0 | 0 | 0 | 0 |
| Comments/Docs | 0 | 0 | 0 | 0 |
| Tests | 0 | 0 | 0 | 0 |
| Simplification | 0 | 0 | 0 | 0 |
Review Coverage
- Logic and correctness - Clean. The
applyCodexProviderOverridesfunction correctly handles all edge cases including null/inherit values, missing objects, and preserves existing properties when merging. - Security (OWASP Top 10) - Clean. No user input is directly used in queries or commands; values are constrained by TypeScript types and Zod enums.
- Error handling - Clean. The override function is designed to be idempotent and safe, returning the original request unmodified when not applicable.
- Type safety - Clean. New type definitions properly constrain the allowed values, and the implementation correctly uses type guards.
- Documentation accuracy - Clean. Comments accurately describe the behavior.
- Test coverage - Adequate. Unit tests cover non-codex providers, inherit/null cases, all override scenarios, and object auto-creation.
- Code clarity - Good. The lazy cloning pattern with
ensureCloned()is efficient and the code is well-structured.
Implementation Highlights
-
Lazy Cloning Pattern (
src/lib/codex/provider-overrides.ts:55-58): TheensureCloned()pattern efficiently avoids cloning the request object when no overrides are needed. -
Proper Type Handling: The
normalizeParallelToolCallsPreferencecorrectly converts string"true"/"false"to boolean values. -
Object Preservation: When overriding
reasoningortext, existing fields are preserved using spread operators. -
Complete Data Flow: All layers are properly updated:
- Database schema with proper column lengths
- Repository with create/update/select support
- Transformers for data conversion
- Actions with type-safe parameters
- UI form with conditional rendering for Codex providers only
- i18n for all 5 locales
Automated review by Claude AI
There was a problem hiding this comment.
Code Review Summary
This PR implements a well-designed feature adding provider-level parameter overrides for Codex-type providers. The implementation is complete and consistent across all layers (database, repository, actions, UI, i18n).
PR Size: L
- Lines changed: 830 (825 additions + 5 deletions)
- Files changed: 20
Issues Found
| Category | Critical | High | Medium | Low |
|---|---|---|---|---|
| Logic/Bugs | 0 | 0 | 0 | 0 |
| Security | 0 | 0 | 0 | 0 |
| Error Handling | 0 | 0 | 0 | 0 |
| Types | 0 | 0 | 0 | 0 |
| Comments/Docs | 0 | 0 | 0 | 0 |
| Tests | 0 | 0 | 0 | 0 |
| Simplification | 0 | 0 | 0 | 0 |
Review Coverage
- Logic and correctness - Clean. The
applyCodexProviderOverridesfunction correctly handles all edge cases including null/inherit values, missing objects, and preserves existing properties when merging. - Security (OWASP Top 10) - Clean. No user input is directly used in queries or commands; values are constrained by TypeScript types and Zod enums.
- Error handling - Clean. The override function is designed to be idempotent and safe, returning the original request unmodified when not applicable.
- Type safety - Clean. New type definitions properly constrain the allowed values, and the implementation correctly uses type guards.
- Documentation accuracy - Clean. Comments accurately describe the behavior.
- Test coverage - Adequate. Unit tests cover non-codex providers, inherit/null cases, all override scenarios, and object auto-creation.
- Code clarity - Good. The lazy cloning pattern with
ensureCloned()is efficient and the code is well-structured.
Implementation Highlights
-
Lazy Cloning Pattern (
src/lib/codex/provider-overrides.ts:55-58): TheensureCloned()pattern efficiently avoids cloning the request object when no overrides are needed. -
Proper Type Handling: The
normalizeParallelToolCallsPreferencecorrectly converts string "true"/"false" to boolean values. -
Object Preservation: When overriding
reasoningortext, existing fields are preserved using spread operators. -
Complete Data Flow: All layers are properly updated:
- Database schema with proper column lengths
- Repository with create/update/select support
- Transformers for data conversion
- Actions with type-safe parameters
- UI form with conditional rendering for Codex providers only
- i18n for all 5 locales
Automated review by Claude AI
🧪 测试结果
总体结果: ✅ 所有测试通过 |
1 similar comment
🧪 测试结果
总体结果: ✅ 所有测试通过 |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx (1)
542-578: 表单重置逻辑遗漏了 Codex 偏好字段。在成功创建供应商后,表单重置逻辑(Lines 542-578)正确地重置了
context1mPreference(Line 577),但遗漏了四个 Codex 偏好字段的重置。这会导致用户在创建下一个供应商时看到上一次设置的 Codex 偏好值,而不是默认的"inherit"值。建议在 Line 577 之后添加以下重置调用:
setContext1mPreference("inherit"); setCodexReasoningEffortPreference("inherit"); setCodexReasoningSummaryPreference("inherit"); setCodexTextVerbosityPreference("inherit"); setCodexParallelToolCallsPreference("inherit");🔎 建议的修复
setWebsiteUrl(""); setContext1mPreference("inherit"); + setCodexReasoningEffortPreference("inherit"); + setCodexReasoningSummaryPreference("inherit"); + setCodexTextVerbosityPreference("inherit"); + setCodexParallelToolCallsPreference("inherit"); } onSuccess?.();
♻️ Duplicate comments (3)
src/actions/providers.ts (1)
456-461: LGTM:偏好字段的默认值保持一致。所有 Codex 偏好字段(包括
context_1m_preference)现在都正确地默认为"inherit",保持了一致性。这修复了先前审查中提到的context_1m_preference默认值不一致的问题。src/app/[locale]/settings/providers/_components/forms/provider-form.tsx (2)
63-91: LGTM:Tooltip 性能问题已修复。
FieldLabelWithTooltip组件现在正确地仅使用Tooltip、TooltipTrigger和TooltipContent,而不在内部创建TooltipProvider。TooltipProvider已在 Line 588 处提升到表单级别,所有 tooltip 共享一个 provider 实例,这修复了先前审查中提到的性能问题。基于 learnings:使用
lucide-react的Info图标符合规范。
1057-1201: 建议重构:提取重复的 Codex 覆写选择器代码。Lines 1061-1201 中的四个 Codex 参数覆写选择器(ReasoningEffort、ReasoningSummary、TextVerbosity、ParallelToolCalls)包含高度重复的代码结构。建议提取为可复用的
CodexOverrideSelect组件,接收label、tooltip、value、onValueChange、options、disabled等属性,以提高代码可维护性和可读性。
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to Reviews > Disable Cache setting
📥 Commits
Reviewing files that changed from the base of the PR and between f43b8b0414faf7c2aba4b6d9256d54c9eb935d9a and 3f33b353a38edb507034ff94bee9975db53b2d70.
📒 Files selected for processing (2)
src/actions/providers.tssrc/app/[locale]/settings/providers/_components/forms/provider-form.tsx
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{ts,tsx,js,jsx,json}
📄 CodeRabbit inference engine (CLAUDE.md)
Use 2-space indentation in all code files
Files:
src/actions/providers.tssrc/app/[locale]/settings/providers/_components/forms/provider-form.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx,js,jsx}: Use double quotes for strings instead of single quotes
Use trailing commas in multi-line structures
Enforce maximum line length of 100 characters
Use path alias@/*to reference files from./src/*directory
**/*.{ts,tsx,js,jsx}: Use Biome for linting and formatting with 2-space indent, double quotes, trailing commas, and 100 character max line length
Use path alias@/*to reference files in./src/*directory
Files:
src/actions/providers.tssrc/app/[locale]/settings/providers/_components/forms/provider-form.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript strict mode for type safety
Use readonly or const assertions for immutable data structures
Files:
src/actions/providers.tssrc/app/[locale]/settings/providers/_components/forms/provider-form.tsx
src/actions/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/actions/**/*.ts: Validate all user inputs with Zod schemas before processing
Use Server Actions innext-safe-actionwith OpenAPI generation for admin API endpoints
Use Next.js API Routes and Server Actions for admin operations and REST endpoints
Files:
src/actions/providers.ts
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.ts: Hash API keys using SHA-256 before storing in database, never store plaintext keys
Mask API keys and sensitive data in application logs
Validate required environment variables at startup with clear error messages
Files:
src/actions/providers.ts
src/**/*provider*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Set provider circuit breaker failure threshold, open duration, and half-open success threshold in configuration
Files:
src/actions/providers.ts
src/{repository,actions}/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Avoid N+1 queries by using eager loading and batch queries for statistics
Files:
src/actions/providers.ts
src/**/*.{tsx,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.{tsx,jsx}: Uselucide-reactfor icons, no custom SVGs
Use React's automatic escaping to prevent XSS vulnerabilities
Files:
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx
**/*.{tsx,json}
📄 CodeRabbit inference engine (AGENTS.md)
Use next-intl for internationalization with 5 locales: en, ja, ru, zh-CN, zh-TW
Files:
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx
🧠 Learnings (4)
📚 Learning: 2026-01-03T09:08:20.573Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T09:08:20.573Z
Learning: Applies to src/components/**/*.{ts,tsx} : Use `lucide-react` for icons instead of custom SVGs
Applied to files:
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx
📚 Learning: 2026-01-03T09:08:49.019Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-03T09:08:49.019Z
Learning: Applies to src/**/*.{tsx,jsx} : Use `lucide-react` for icons, no custom SVGs
Applied to files:
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx
📚 Learning: 2026-01-03T09:08:49.019Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-03T09:08:49.019Z
Learning: Applies to src/components/**/*.{tsx,jsx} : Use shadcn/ui component library for high-quality, accessible UI components
Applied to files:
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx
📚 Learning: 2026-01-03T09:08:49.019Z
Learnt from: CR
Repo: ding113/claude-code-hub PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-03T09:08:49.019Z
Learning: Applies to src/**/*provider*.ts : Set provider circuit breaker failure threshold, open duration, and half-open success threshold in configuration
Applied to files:
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx
🧬 Code graph analysis (2)
src/actions/providers.ts (1)
src/types/provider.ts (4)
CodexReasoningEffortPreference(17-24)CodexReasoningSummaryPreference(26-26)CodexTextVerbosityPreference(28-28)CodexParallelToolCallsPreference(31-31)
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx (1)
src/types/provider.ts (4)
CodexReasoningEffortPreference(17-24)CodexReasoningSummaryPreference(26-26)CodexTextVerbosityPreference(28-28)CodexParallelToolCallsPreference(31-31)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: 🌐 API Tests
- GitHub Check: Docker Build Test
- GitHub Check: dev-build-deploy
🔇 Additional comments (3)
src/actions/providers.ts (1)
44-51: LGTM:Codex 偏好类型导入正确。四个新增的 Codex 偏好类型导入符合代码规范,与
src/types/provider.ts中的类型定义一致。src/app/[locale]/settings/providers/_components/forms/provider-form.tsx (2)
172-187: LGTM:Codex 偏好状态初始化正确。四个 Codex 偏好状态变量正确地从
sourceProvider继承值或默认为"inherit",与后端的默认行为保持一致。类型注解也准确匹配导入的类型定义。
395-398: LGTM:提交载荷正确包含 Codex 偏好字段。创建和编辑供应商的提交载荷都正确地包含了四个 Codex 偏好字段,类型定义与后端 API 期望一致,状态值直接传递无需转换。
Also applies to: 437-440, 501-504
3f33b35 to
1dfe79c
Compare
🧪 测试结果
总体结果: ✅ 所有测试通过 |
|
Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance. |
Summary
Implements provider-level parameter overrides for Codex-type providers, allowing administrators to force-override or inherit client-specified values for reasoning effort, reasoning summary, text verbosity, and parallel tool calls.
实现 Codex 类型供应商的供应商级参数覆写功能,管理员可以强制覆写或跟随客户端指定的推理强度、推理摘要、输出冗长度和并行工具调用设置。
Problem
Codex providers (OpenAI Responses API) support various configuration parameters like
reasoning.effort,reasoning.summary,text.verbosity, andparallel_tool_calls. Previously, there was no way for administrators to enforce specific values at the provider level, requiring reliance on client-specified values.Related Issues:
Solution
Added provider-level override settings that:
Changes
Core Changes
src/lib/codex/provider-overrides.ts(+90): New override logic module withapplyCodexProviderOverrides()functionsrc/app/v1/_lib/proxy/forwarder.ts(+8): Integrate override application in forwarding phasesrc/drizzle/schema.ts(+8): Add 4 new columns to providers tableDatabase Migration
drizzle/0045_plain_titania.sql(generated viabun run db:generate): Adds columns:codex_reasoning_effort_preference(varchar(20))codex_reasoning_summary_preference(varchar(20))codex_text_verbosity_preference(varchar(10))codex_parallel_tool_calls_preference(varchar(10))Admin UI
src/app/[locale]/settings/providers/_components/forms/provider-form.tsx(+219):FieldLabelWithTooltiphelper component (shared TooltipProvider scope)Supporting Changes
src/types/provider.ts(+37): Type definitions for override preferencessrc/lib/validation/schemas.ts(+25): Zod validation schemassrc/actions/providers.ts(+26): Server action updates for CRUD operationssrc/repository/provider.ts(+34): Repository layer updatessrc/repository/_shared/transformers.ts(+4): Data transformerssrc/app/v1/_lib/codex/utils/request-sanitizer.ts(+4/-1): Preserveparallel_tool_callsin sanitizationsrc/app/v1/_lib/converters/openai-to-codex/request.ts(+3/-1): Pass throughparallel_tool_callsin conversioni18n
Testing
Automated Tests
tests/unit/proxy/codex-provider-overrides.test.ts(+124): New test suite for override logictests/unit/proxy/codex-request-sanitizer.test.ts(+14): Additional tests for parallel_tool_calls preservationtests/unit/proxy/openai-to-codex-request.test.ts(+10): Tests for parallel_tool_calls pass-through in conversionManual Testing
Migration
Run database migration to add the new columns:
Or apply manually:
Checklist
Description enhanced by Claude AI