feat(codex): show reasoning effort in usage logs - #1324
Conversation
Record reasoning.effort for Codex requests, preserve provider override audit data, and support the official max effort tier. Display reasoning effort beside the billing model in both usage-log tables, with requested-to-effective values when a provider overrides the request.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough本 PR 为 Codex reasoning effort 增加类型、校验、请求审计、覆盖合并、日志展示、provider 配置和多语言文案,并补充相关单元测试;另调整 OpenAPI 状态端点测试对缺失参数的处理。 ChangesCodex Reasoning Effort 功能实现
OpenAPI 测试健壮性调整
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces support for tracking, auditing, and displaying Codex reasoning.effort (thinking effort) across the logs dashboard, including support for a new 'max' effort level override. It updates localization files, schemas, types, and the proxy message service to record and visualize both the client-requested and provider-overridden effort levels. The review feedback highlights two important improvements: ensuring reasoningEffort is added to DEFAULT_VISIBLE_COLUMNS to maintain consistency with ALWAYS_VISIBLE_COLUMNS, and using optional chaining on setting.changes in the utility functions to prevent potential runtime errors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0cdea2e4d9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Code Review Summary
This PR cleanly adds Codex reasoning.effort audit/display and the official max tier. The new extraction logic is defensive and well-covered by tests, i18n keys are consistent across all five locales, and the renamed ThinkingEffortBadge leaves no dangling references. No issues met the reporting threshold (confidence >= 80).
PR Size: XL
- Lines changed: 933 (872 additions, 61 deletions)
- Files changed: 36
This crosses the XL threshold on file count. Note that ~10 files are i18n translations and ~12 are tests, so the effective logic surface is closer to size M.
Suggested split (XL)
The PR bundles two largely independent changes that could land separately if desired:
maxtier support —src/types/provider.ts,src/lib/validation/schemas.ts,src/lib/provider-patch-contract.ts,options-section.tsx, badge styles, and the*/sections.jsonoption strings.- Codex reasoning-effort audit + display —
message-service.ts,src/lib/utils/codex-reasoning-effort.ts,codex-reasoning-effort-display.tsx, both log tables,SummaryTab.tsx,column-visibility.ts,special-settings.ts, and the*/dashboard.jsonstrings.
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 |
No issues above the reporting threshold. Notable items checked and cleared:
extractCodexReasoningEffortInfooverride-resolution traced through all branches (direct display, requested->effective override, forced override with no client value, historical override-only records, non-codex filtering).usage-logs-table.tsxcolumn count (13) matchescolSpan={13}; virtualized table header/body flex columns match.ALWAYS_VISIBLE_COLUMNSaddition follows the existingas constpattern (separate from the toggleableLogsTableColumnunion) — no type regression.- Provider-override audit contract (
providerType: "codex", path"reasoning.effort"insrc/lib/codex/provider-overrides.ts) matches exactly what the new extractor reads. message-service.tsrecords the client value before provider overrides are applied, so "requested" correctly reflects the original request.
Review Coverage
- Logic and correctness - Clean
- Security (OWASP Top 10) - Clean
- Error handling - Clean
- Type safety - Clean
- Documentation accuracy - Clean
- Test coverage - Strong
- Code clarity - Good
Automated review by Claude AI
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/app/[locale]/dashboard/logs/_components/error-details-dialog/components/SummaryTab.tsx (1)
338-374: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win为装饰性箭头图标补充
aria-hidden第 362 行的
ArrowRight是纯视觉指示(表示"请求值 → 生效值"),但缺少aria-hidden="true",与同一 PR 中codex-reasoning-effort-display.tsx里同类箭头图标(<ArrowRight ... aria-hidden="true" />)的写法不一致,会导致屏幕阅读器读出多余内容。♿️ 建议修复
- {effortDisplay.requestedEffort && ( - <ArrowRight className="h-3 w-3 text-muted-foreground" /> - )} + {effortDisplay.requestedEffort && ( + <ArrowRight className="h-3 w-3 text-muted-foreground" aria-hidden="true" /> + )}
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/app/`[locale]/dashboard/logs/_components/usage-logs-table.tsx:
- Around line 302-304: The reasoning-effort cell in usage-logs-table can
overflow into the adjacent Tokens column because the TableCell is
width-constrained while CodexReasoningEffortDisplay renders nowrap content.
Update the TableCell around CodexReasoningEffortDisplay to prevent visual
overflow, either by adding overflow handling (such as clipping/truncation) or by
widening the cell. Keep the fix localized to the usage-logs-table component and
verify the specialSettings-driven display still renders correctly in override
cases.
In `@src/app/`[locale]/dashboard/logs/_components/virtualized-logs-table.tsx:
- Around line 1006-1010: The new Codex Reasoning Effort body cell in
virtualized-logs-table.tsx is missing the same overflow handling used by the
header, so its contents can spill into the adjacent Tokens column. Update the
body cell wrapper around CodexReasoningEffortDisplay to apply the same
truncation/overflow control pattern as the corresponding header div (for
example, matching the existing truncate/overflow-hidden behavior in the table
cell layout) so the badge-and-arrow content stays clipped within its flex width.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b2fa757f-875b-4234-85c9-ab4858d4c7ee
📒 Files selected for processing (36)
messages/en/dashboard.jsonmessages/en/settings/providers/form/sections.jsonmessages/ja/dashboard.jsonmessages/ja/settings/providers/form/sections.jsonmessages/ru/dashboard.jsonmessages/ru/settings/providers/form/sections.jsonmessages/zh-CN/dashboard.jsonmessages/zh-CN/settings/providers/form/sections.jsonmessages/zh-TW/dashboard.jsonmessages/zh-TW/settings/providers/form/sections.jsonsrc/app/[locale]/dashboard/logs/_components/codex-reasoning-effort-display.test.tsxsrc/app/[locale]/dashboard/logs/_components/codex-reasoning-effort-display.tsxsrc/app/[locale]/dashboard/logs/_components/error-details-dialog.test.tsxsrc/app/[locale]/dashboard/logs/_components/error-details-dialog/components/SummaryTab.tsxsrc/app/[locale]/dashboard/logs/_components/usage-logs-table.test.tsxsrc/app/[locale]/dashboard/logs/_components/usage-logs-table.tsxsrc/app/[locale]/dashboard/logs/_components/virtualized-logs-table.test.tsxsrc/app/[locale]/dashboard/logs/_components/virtualized-logs-table.tsxsrc/app/[locale]/settings/providers/_components/forms/provider-form/sections/options-section.tsxsrc/app/v1/_lib/proxy/message-service.test.tssrc/app/v1/_lib/proxy/message-service.tssrc/components/customs/thinking-effort-badge.test.tssrc/components/customs/thinking-effort-badge.tsxsrc/lib/column-visibility.test.tssrc/lib/column-visibility.tssrc/lib/provider-patch-contract.tssrc/lib/utils/codex-reasoning-effort.tssrc/lib/utils/special-settings.tssrc/lib/validation/schemas.test.tssrc/lib/validation/schemas.tssrc/types/provider.tssrc/types/special-settings.tstests/unit/actions/providers-patch-contract.test.tstests/unit/lib/utils/codex-reasoning-effort.test.tstests/unit/proxy/codex-provider-overrides.test.tstests/unit/settings/providers/options-section.test.tsx
Summary
reasoning.effortin usage-log audit datamaxeffort tier to provider types, validation, batch patches, forms, and all five localesultrainvalid because it is a Codex product mode, not a Responses APIreasoning.effortvalueMotivation
The current OpenAI Responses API supports a new
maxreasoning-effort tier. Codex usage records previously did not persist or surfacereasoning.effort, which made it difficult to verify the value actually forwarded after provider-level overrides.Official references:
Related Work
reasoning/text/parallel_tool_callsoverrides. That PR introduced thecodex_reasoning_effort_preferencefield and theprovider_parameter_overrideaudit. This PR records the client's requestedreasoning.effortintospecial_settingsbefore the usage record is created, renders the effective forwarded value from that sameprovider_parameter_overrideaudit, and adds the officialmaxtier to the preference field feat: Codex 供应商级覆写 reasoning/text/parallel_tool_calls (#404) #536 created.xhightier for Anthropic adaptive thinking. This PR follows the same type (src/types/provider.ts) / Zod validation (src/lib/validation/schemas.ts) / batch-patch contract (src/lib/provider-patch-contract.ts) pattern to addmaxfor Codex reasoning effort, and generalizes the shared badge (AnthropicEffortBadge->ThinkingEffortBadge) so Anthropic and Codex levels render with consistent styling.special-settingsaudit type union (src/types/special-settings.ts,src/lib/utils/special-settings.ts) that this PR also adds thecodex_reasoning_effortaudit type to.Behavior
reasoning.effortpersist the original request value inspecial_settings.requested -> effectivewhen the provider changes the value.Changes
Core Changes
src/app/v1/_lib/proxy/message-service.ts— extractreasoning.effortand write acodex_reasoning_effortaudit entry intospecial_settingsbefore the usage record is created (Codex providers only; deduped; skips when absent).src/lib/utils/codex-reasoning-effort.ts(new) — request-body extraction, special-settings extraction, andextractCodexReasoningEffortInfowhich merges the requested value with theprovider_parameter_overrideeffective value (including backward compatibility with override-only historical records).src/types/special-settings.ts,src/lib/utils/special-settings.ts— newcodex_reasoning_effortaudit type + dedup key.src/components/customs/thinking-effort-badge.tsx— renamed fromanthropic-effort-badge.tsx;AnthropicEffortBadge->ThinkingEffortBadge, addsnone/minimalstyles so Anthropic and Codex levels share one renderer.Usage-log UI
usage-logs-table.tsx,virtualized-logs-table.tsx— new always-visible "Reasoning Effort" column immediately after the billing model; empty-statecolSpanbumped to 13; virtualizedmin-w800px -> 900px.src/app/[locale]/dashboard/logs/_components/codex-reasoning-effort-display.tsx(new) — renders requested value, andrequested -> effectivewith an arrow + "overridden by provider" note when a provider override changed it.src/lib/column-visibility.ts— addreasoningEfforttoALWAYS_VISIBLE_COLUMNS.error-details-dialog/components/SummaryTab.tsx— unifiedeffortDisplay(Codex reasoning effort preferred, else Anthropic effort) usingThinkingEffortBadge.maxeffort tiersrc/types/provider.ts,src/lib/validation/schemas.ts,src/lib/provider-patch-contract.ts— addmaxtoCodexReasoningEffortPreference;ultrastays invalid (Codex product mode, not a Responses API value).options-section.tsx— reorder options and includemax.settings/providers/form/sections.json—maxoption + generalized help text (model-dependent levels).Breaking Changes
None. No database migration (the new audit lives in the existing
special_settingsJSON column). The badge component rename is repo-internal and all call sites were updated in this PR.Validation
bun run buildbun run lintbun run lint:fixbun run typecheckbun run i18n:audit-messages-no-emoji:failja=9,zh-TW=60Full local suite result: 6751 passed, 4 unrelated pre-existing/local-environment failures:
tr: Illegal byte sequencein the Kubernetes shell-helper fallback testNone of those failing files are changed by this PR.
i18n audit summary
The new and modified strings are translated for
zh-CN,zh-TW,en,ja, andru. No emoji or new placeholder candidates were introduced.Testing
Automated Tests
codex-reasoning-effort.test.ts,message-service.test.ts,thinking-effort-badge.test.ts,schemas.test.ts,column-visibility.test.ts, plus table/dialog component tests andcodex-provider-overrides.test.ts/providers-patch-contract.test.tscases formax.Manual Testing
max; confirmmaxappears and is persisted.reasoning.effort; confirm the new column shows the requested value, andrequested -> effectivewhen a provider override changes it.-placeholder renders.Checklist
origin/devdevDescription enhanced by Claude AI
Greptile Summary
This PR adds end-to-end visibility of Codex
reasoning.effortin usage logs: the proxy now captures the client's requested value intospecial_settingsbefore the usage record is created, and a new always-visible table column shows "requested → effective" when a provider-level override changes the value. It also adds the officialmaxeffort tier and generalizes the existingAnthropicEffortBadgeinto a sharedThinkingEffortBadge.message-service.ts,codex-reasoning-effort.ts): a newcodex_reasoning_effortspecial-setting is written for Codex providers before the record is flushed, giving the display layer a stable "requested" anchor alongside the existingprovider_parameter_override"effective" anchor.usage-logs-table.tsx,virtualized-logs-table.tsx,codex-reasoning-effort-display.tsx): a new "Reasoning Effort" column renders the badge, arrow, and override note; backward-compatible with historical records that only carry provider-override audit data.maxtier + badge generalization (provider.ts,schemas.ts,thinking-effort-badge.tsx, all 5 locales):maxis added to the Codex preference enum and the shared badge now covers all levels fromnonethroughmax, withultracorrectly kept out of scope.Confidence Score: 5/5
Safe to merge — all changed paths are additive; no existing data is modified and the new audit type writes to the existing JSON column.
The core extraction logic correctly handles all edge cases (null efforts, backward-compat historical records, multi-provider retries) and is covered by focused unit tests. The table column, badge generalisation, and
maxtier additions are self-contained and do not alter any existing behavior. The typecheck and full local test suite both pass.No files require special attention.
Important Files Changed
normalizeCodexReasoningEffort.createMessageRequest, mirroring the existing Anthropic effort pattern. The!hasCodexReasoningEffortAuditguard correctly makes the write idempotent across retries.requestedEffortcorrectly handle the backward-compat historical-record path; tooltip shows 'Overridden by provider' only whenisOverriddenis true.anthropic-effort-badge.tsx; addsnone/minimalstyles andmaxstyle; unknown levels fall back to a neutral default style. Visual ordering none < minimal < low < medium < high < xhigh < max is reflected in color progression.effortDisplaycorrectly prefers Codex reasoning effort over Anthropic effort; null-safe rendering ofeffectiveEffort(which is `stringCodexReasoningEffortSpecialSettingtype to the discriminated union; dedup key inspecial-settings.tsis consistent with other audit types.maxtoCodexReasoningEffortPreference;ultrais correctly excluded per the PR rationale.maxto the Zod enum forCODEX_REASONING_EFFORT_PREFERENCE; consistent with the type definition update.colSpancorrectly updated to 13 to match the new column count.min-wupdated from 800px to 900px to accommodate the new column width.Sequence Diagram
sequenceDiagram participant Client participant ProxyMessageService participant Session participant DB participant UI Client->>ProxyMessageService: Codex request (reasoning.effort: "high") ProxyMessageService->>Session: extractCodexReasoningEffortFromRequestBody() Session-->>ProxyMessageService: "high" ProxyMessageService->>Session: "addSpecialSetting({type: codex_reasoning_effort, effort: high})" ProxyMessageService->>DB: "createMessageRequest(special_settings=[codex_reasoning_effort])" note over Session,DB: Provider override runs after record creation Session->>DB: "update special_settings += provider_parameter_override(before:high, after:max)" UI->>DB: fetch usage log row DB-->>UI: specialSettings with codex_reasoning_effort + provider_parameter_override UI->>UI: extractCodexReasoningEffortInfo(specialSettings) note over UI: requestedEffort=high, effectiveEffort=max, isOverridden=true UI->>UI: render high → max with Overridden by providerReviews (5): Last reviewed commit: "chore: format Codex reasoning tests" | Re-trigger Greptile