Skip to content

feat(codex): show reasoning effort in usage logs - #1324

Merged
ding113 merged 6 commits into
ding113:devfrom
baitaotao521:feature/codex-reasoning-effort
Jul 22, 2026
Merged

feat(codex): show reasoning effort in usage logs#1324
ding113 merged 6 commits into
ding113:devfrom
baitaotao521:feature/codex-reasoning-effort

Conversation

@baitaotao521

@baitaotao521 baitaotao521 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • record Codex Responses API reasoning.effort in usage-log audit data
  • show an always-visible reasoning-effort column immediately after the billing model in both regular and virtualized usage-log tables
  • display requested and effective effort values when a provider override changes the request
  • add the official max effort tier to provider types, validation, batch patches, forms, and all five locales
  • keep ultra invalid because it is a Codex product mode, not a Responses API reasoning.effort value
  • generalize the existing effort badge so Anthropic and Codex levels share consistent rendering

Motivation

The current OpenAI Responses API supports a new max reasoning-effort tier. Codex usage records previously did not persist or surface reasoning.effort, which made it difficult to verify the value actually forwarded after provider-level overrides.

Official references:

Related Work

Behavior

  • Codex requests with reasoning.effort persist the original request value in special_settings.
  • Provider override audit data remains the source of the effective forwarded value.
  • Usage logs render requested -> effective when the provider changes the value.
  • Historical records containing only provider override audit data remain displayable.
  • Records without Codex reasoning-effort audit data render a neutral placeholder.

Changes

Core Changes

  • src/app/v1/_lib/proxy/message-service.ts — extract reasoning.effort and write a codex_reasoning_effort audit entry into special_settings before 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, and extractCodexReasoningEffortInfo which merges the requested value with the provider_parameter_override effective value (including backward compatibility with override-only historical records).
  • src/types/special-settings.ts, src/lib/utils/special-settings.ts — new codex_reasoning_effort audit type + dedup key.
  • src/components/customs/thinking-effort-badge.tsx — renamed from anthropic-effort-badge.tsx; AnthropicEffortBadge -> ThinkingEffortBadge, adds none/minimal styles 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-state colSpan bumped to 13; virtualized min-w 800px -> 900px.
  • src/app/[locale]/dashboard/logs/_components/codex-reasoning-effort-display.tsx (new) — renders requested value, and requested -> effective with an arrow + "overridden by provider" note when a provider override changed it.
  • src/lib/column-visibility.ts — add reasoningEffort to ALWAYS_VISIBLE_COLUMNS.
  • error-details-dialog/components/SummaryTab.tsx — unified effortDisplay (Codex reasoning effort preferred, else Anthropic effort) using ThinkingEffortBadge.

max effort tier

  • src/types/provider.ts, src/lib/validation/schemas.ts, src/lib/provider-patch-contract.ts — add max to CodexReasoningEffortPreference; ultra stays invalid (Codex product mode, not a Responses API value).
  • options-section.tsx — reorder options and include max.
  • All 5 locale settings/providers/form/sections.jsonmax option + generalized help text (model-dependent levels).

Breaking Changes

None. No database migration (the new audit lives in the existing special_settings JSON column). The badge component rename is repo-internal and all call sites were updated in this PR.

Validation

  • bun run build
  • bun run lint
  • bun run lint:fix
  • bun run typecheck
  • 354 focused unit/component tests
  • Docker image build and local runtime health checks
  • bun run i18n:audit-messages-no-emoji:fail
  • i18n settings split and module-load tests
  • placeholder audit completed; existing candidates only: ja=9, zh-TW=60
  • no placeholder allowlist changes

Full local suite result: 6751 passed, 4 unrelated pre-existing/local-environment failures:

  • macOS locale causes tr: Illegal byte sequence in the Kubernetes shell-helper fallback test
  • two user-insights date assertions differ by one day because of the local timezone
  • the blocked-sessionStorage language-switcher test does not observe its expected console error

None of those failing files are changed by this PR.

i18n audit summary

Locale Settings candidates Dashboard candidates My Usage candidates
ja 7 2 0
zh-TW 45 15 0

The new and modified strings are translated for zh-CN, zh-TW, en, ja, and ru. No emoji or new placeholder candidates were introduced.

Testing

Automated Tests

  • Unit tests added/updated — 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 and codex-provider-overrides.test.ts / providers-patch-contract.test.ts cases for max.

Manual Testing

  1. Create or edit a Codex provider and set the reasoning-effort override to max; confirm max appears and is persisted.
  2. Send a Codex request with reasoning.effort; confirm the new column shows the requested value, and requested -> effective when a provider override changes it.
  3. Open a non-Codex log and confirm the neutral - placeholder renders.

Checklist

  • branch created from the latest origin/dev
  • PR targets dev
  • Conventional Commit used
  • no database migration required
  • no unrelated source changes

Description enhanced by Claude AI

Greptile Summary

This PR adds end-to-end visibility of Codex reasoning.effort in usage logs: the proxy now captures the client's requested value into special_settings before 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 official max effort tier and generalizes the existing AnthropicEffortBadge into a shared ThinkingEffortBadge.

  • Audit capture (message-service.ts, codex-reasoning-effort.ts): a new codex_reasoning_effort special-setting is written for Codex providers before the record is flushed, giving the display layer a stable "requested" anchor alongside the existing provider_parameter_override "effective" anchor.
  • Usage-log UI (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.
  • max tier + badge generalization (provider.ts, schemas.ts, thinking-effort-badge.tsx, all 5 locales): max is added to the Codex preference enum and the shared badge now covers all levels from none through max, with ultra correctly 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 max tier 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

Filename Overview
src/lib/utils/codex-reasoning-effort.ts New utility with three well-guarded extraction functions. The multi-override accumulation logic (first before, last after) is correct for both the new-record and historical backward-compat paths. All edge cases—null efforts, non-string values, empty strings, missing audit entries—are handled via normalizeCodexReasoningEffort.
src/app/v1/_lib/proxy/message-service.ts Adds Codex reasoning-effort audit write before createMessageRequest, mirroring the existing Anthropic effort pattern. The !hasCodexReasoningEffortAudit guard correctly makes the write idempotent across retries.
src/app/[locale]/dashboard/logs/_components/codex-reasoning-effort-display.tsx Clean display component: null-guards on requestedEffort correctly handle the backward-compat historical-record path; tooltip shows 'Overridden by provider' only when isOverridden is true.
src/components/customs/thinking-effort-badge.tsx Renamed from anthropic-effort-badge.tsx; adds none/minimal styles and max style; unknown levels fall back to a neutral default style. Visual ordering none < minimal < low < medium < high < xhigh < max is reflected in color progression.
src/app/[locale]/dashboard/logs/_components/error-details-dialog/components/SummaryTab.tsx Unified effortDisplay correctly prefers Codex reasoning effort over Anthropic effort; null-safe rendering of effectiveEffort (which is `string
src/types/special-settings.ts Adds CodexReasoningEffortSpecialSetting type to the discriminated union; dedup key in special-settings.ts is consistent with other audit types.
src/types/provider.ts Adds max to CodexReasoningEffortPreference; ultra is correctly excluded per the PR rationale.
src/lib/validation/schemas.ts Adds max to the Zod enum for CODEX_REASONING_EFFORT_PREFERENCE; consistent with the type definition update.
src/app/[locale]/dashboard/logs/_components/usage-logs-table.tsx New 'Reasoning Effort' column added after 'Billing Model'; empty-state colSpan correctly updated to 13 to match the new column count.
src/app/[locale]/dashboard/logs/_components/virtualized-logs-table.tsx New Reasoning Effort column added in the virtualized table; min-w updated 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 provider
Loading

Reviews (5): Last reviewed commit: "chore: format Codex reasoning tests" | Re-trigger Greptile

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.
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

本 PR 为 Codex reasoning effort 增加类型、校验、请求审计、覆盖合并、日志展示、provider 配置和多语言文案,并补充相关单元测试;另调整 OpenAPI 状态端点测试对缺失参数的处理。

Changes

Codex Reasoning Effort 功能实现

Layer / File(s) Summary
类型、校验与配置契约
src/types/*, src/lib/validation/*, src/lib/provider-patch-contract.ts, src/app/[locale]/settings/..., messages/*/settings/..., tests/unit/...
新增 codex_reasoning_effort special setting 类型,允许 max 值,更新去重逻辑、provider 表单选项及对应测试。
Reasoning effort 提取与审计写入
src/lib/utils/codex-reasoning-effort.ts, src/app/v1/_lib/proxy/message-service.ts, tests/unit/lib/utils/*, src/app/v1/_lib/proxy/message-service.test.ts
提取并规范化请求中的 reasoning.effort,写入 Codex special setting,并合并 provider 覆写记录以计算请求值、有效值和覆盖状态。
统一 effort 展示与日志表格接入
src/components/customs/thinking-effort-badge.tsx, src/app/[locale]/dashboard/logs/_components/*, src/lib/column-visibility.ts, tests/unit/*
使用通用 badge 和展示组件呈现 reasoning effort,将其加入普通及虚拟化日志表格,并设为始终可见列。
Dashboard 多语言文案
messages/{en,ja,ru,zh-CN,zh-TW}/dashboard.json
新增 reasoning effort 列标题,并将请求详情文案改为 Codex reasoning.effort 的说明。

OpenAPI 测试健壮性调整

Layer / File(s) Summary
缺失参数测试处理
tests/api/api-openapi-spec.test.ts
状态端点测试在 parameters 未定义时使用空数组回退后提取参数名称。

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: brisbanehuang, tesgth032

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 43.75% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed 标题简洁且准确概括了核心改动:在使用日志中展示 Codex reasoning effort。
Description check ✅ Passed 描述与变更内容高度一致,涵盖了记录、展示、max 档位和共享徽标等主要改动。
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added enhancement New feature or request area:OpenAI area:UI area:i18n area:provider size/XL Extra Large PR (> 1000 lines) labels Jul 9, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/lib/column-visibility.ts
Comment thread src/lib/utils/codex-reasoning-effort.ts Outdated
Comment thread src/lib/column-visibility.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/lib/utils/codex-reasoning-effort.ts Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. max tier supportsrc/types/provider.ts, src/lib/validation/schemas.ts, src/lib/provider-patch-contract.ts, options-section.tsx, badge styles, and the */sections.json option strings.
  2. Codex reasoning-effort audit + displaymessage-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.json strings.

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:

  • extractCodexReasoningEffortInfo override-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.tsx column count (13) matches colSpan={13}; virtualized table header/body flex columns match.
  • ALWAYS_VISIBLE_COLUMNS addition follows the existing as const pattern (separate from the toggleable LogsTableColumn union) — no type regression.
  • Provider-override audit contract (providerType: "codex", path "reasoning.effort" in src/lib/codex/provider-overrides.ts) matches exactly what the new extractor reads.
  • message-service.ts records 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 595a7d9 and 0cdea2e.

📒 Files selected for processing (36)
  • messages/en/dashboard.json
  • messages/en/settings/providers/form/sections.json
  • messages/ja/dashboard.json
  • messages/ja/settings/providers/form/sections.json
  • messages/ru/dashboard.json
  • messages/ru/settings/providers/form/sections.json
  • messages/zh-CN/dashboard.json
  • messages/zh-CN/settings/providers/form/sections.json
  • messages/zh-TW/dashboard.json
  • messages/zh-TW/settings/providers/form/sections.json
  • src/app/[locale]/dashboard/logs/_components/codex-reasoning-effort-display.test.tsx
  • src/app/[locale]/dashboard/logs/_components/codex-reasoning-effort-display.tsx
  • src/app/[locale]/dashboard/logs/_components/error-details-dialog.test.tsx
  • src/app/[locale]/dashboard/logs/_components/error-details-dialog/components/SummaryTab.tsx
  • src/app/[locale]/dashboard/logs/_components/usage-logs-table.test.tsx
  • src/app/[locale]/dashboard/logs/_components/usage-logs-table.tsx
  • src/app/[locale]/dashboard/logs/_components/virtualized-logs-table.test.tsx
  • src/app/[locale]/dashboard/logs/_components/virtualized-logs-table.tsx
  • src/app/[locale]/settings/providers/_components/forms/provider-form/sections/options-section.tsx
  • src/app/v1/_lib/proxy/message-service.test.ts
  • src/app/v1/_lib/proxy/message-service.ts
  • src/components/customs/thinking-effort-badge.test.ts
  • src/components/customs/thinking-effort-badge.tsx
  • src/lib/column-visibility.test.ts
  • src/lib/column-visibility.ts
  • src/lib/provider-patch-contract.ts
  • src/lib/utils/codex-reasoning-effort.ts
  • src/lib/utils/special-settings.ts
  • src/lib/validation/schemas.test.ts
  • src/lib/validation/schemas.ts
  • src/types/provider.ts
  • src/types/special-settings.ts
  • tests/unit/actions/providers-patch-contract.test.ts
  • tests/unit/lib/utils/codex-reasoning-effort.test.ts
  • tests/unit/proxy/codex-provider-overrides.test.ts
  • tests/unit/settings/providers/options-section.test.tsx

Comment thread src/app/[locale]/dashboard/logs/_components/usage-logs-table.tsx Outdated
@ding113
ding113 merged commit 5164373 into ding113:dev Jul 22, 2026
12 of 14 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Claude Code Hub Roadmap Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:i18n area:OpenAI area:provider area:UI enhancement New feature or request size/XL Extra Large PR (> 1000 lines)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants