Skip to content

Fix #541: Add error rule for Codex reasoning effort mismatch#544

Merged
ding113 merged 1 commit intodevfrom
fix/issue-541-codex-reasoning-effort-error
Jan 5, 2026
Merged

Fix #541: Add error rule for Codex reasoning effort mismatch#544
ding113 merged 1 commit intodevfrom
fix/issue-541-codex-reasoning-effort-error

Conversation

@ding113
Copy link
Owner

@ding113 ding113 commented Jan 5, 2026

Summary

  • Adds a new default error rule to detect and handle Codex API errors when reasoning effort (思考强度) values are incompatible with the selected model
  • When triggered, returns a user-friendly Chinese message explaining the issue and suggesting fixes

Problem

Fixes #541

When using Codex type providers, if the reasoning_effort parameter (e.g., high) is not supported by the model (e.g., gpt-5.2-codex only supports medium), the API returns:

状态码: 400
错误: invalid_request_error: Unsupported value: 'high' is not supported with the 'gpt-5.2-codex' model. Supported values are: 'medium'.

Without an error rule, this cryptic error is passed directly to users.

Solution

Added a new entry to DEFAULT_ERROR_RULES in src/repository/error-rules.ts:

  • Pattern: Unsupported value.*is not supported with.*model.*Supported values (regex)
  • Category: thinking_error
  • Priority: 72 (consistent with other thinking-related errors)
  • Override Response:
    当前思考强度不支持该模型,请调整 reasoning_effort 参数或切换模型(如 'high' 仅支持部分模型)
    

Changes

  • src/repository/error-rules.ts - Added new error rule for Codex reasoning effort mismatch

Testing

  • Verified regex pattern matches the error message format
  • TypeScript typecheck passes
  • Biome lint passes
  • Unit tests pass

Created by Claude AI in response to @claude mention

🤖 Generated with Claude Code

Greptile Summary

Added default error rule to handle Codex API errors when reasoning_effort values are incompatible with the model. The rule matches the error pattern "Unsupported value.*is not supported with.*model.*Supported values" and returns a localized Chinese message guiding users to adjust the parameter or switch models. Implementation follows existing patterns with appropriate priority (72) consistent with other thinking-related errors.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change adds a single, well-defined error rule following established patterns. The regex pattern correctly matches the documented error format, priority is consistent with similar rules, and the implementation is isolated with no side effects
  • No files require special attention

Important Files Changed

Filename Overview
src/repository/error-rules.ts Added new error rule for Codex reasoning effort mismatch with proper pattern, priority, and Chinese error message

Sequence Diagram

sequenceDiagram
    participant Client
    participant API Gateway
    participant ErrorDetector
    participant ErrorRules
    participant Codex Provider

    Client->>API Gateway: Request with reasoning_effort='high'
    API Gateway->>Codex Provider: Forward request (model=gpt-5.2-codex)
    Codex Provider-->>API Gateway: 400 Error: Unsupported value 'high'
    API Gateway->>ErrorDetector: Process error response
    ErrorDetector->>ErrorRules: Match error pattern
    ErrorRules-->>ErrorDetector: Rule matched (priority 72)
    ErrorDetector->>ErrorDetector: Apply override response
    ErrorDetector-->>Client: User-friendly message in Chinese
Loading

Closes #541

This commit adds a new error rule to handle the case when a Codex API provider
returns an error due to unsupported reasoning effort (thinking intensity) values
for a specific model.

Error pattern example:
"Unsupported value: 'high' is not supported with the 'gpt-5.2-codex' model.
Supported values are: 'medium'."

The new error rule:
- Pattern: Uses regex to match the "Unsupported value" error format
- Category: thinking_error (priority: 72)
- Response: Provides a user-friendly Chinese message suggesting to adjust
  reasoning_effort parameter or switch to a different model

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Jan 5, 2026

📝 Walkthrough

概览

error-rules.ts 文件的 DEFAULT_ERROR_RULES 中添加了新的默认错误规则,用于处理 Codex 模型在 reasoning 值与模型不匹配时的 thinking_error,通过规则匹配、验证和响应覆盖来引导用户调整推理强度或切换模型。

变更

队列 / 文件 变更摘要
错误处理规则扩展
src/repository/error-rules.ts
DEFAULT_ERROR_RULES 数组中新增一条错误规则,用于匹配"Unsupported value"相关的错误消息,将其识别为 thinking_error 类型,优先级为 72,并返回中文提示信息指导用户调整 reasoning_effort 或切换模型

评估代码审查工作量

🎯 2 (简单) | ⏱️ ~8 分钟

可能相关的 PR

  • PR #519: 同样修改 src/repository/error-rules.ts 文件,在 DEFAULT_ERROR_RULES 中添加相邻优先级的 thinking_error 规则条目,用于处理不同的思考错误模式
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/issue-541-codex-reasoning-effort-error

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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!

This pull request enhances error handling for Codex API interactions by introducing a new default error rule. The rule specifically addresses scenarios where the reasoning_effort parameter does not align with the capabilities of the chosen model, preventing cryptic API error messages from reaching the user. Instead, it presents an actionable, localized message to guide the user toward a resolution.

Highlights

  • New Error Rule: A new default error rule has been added to detect and handle specific Codex API errors.
  • Reasoning Effort Mismatch: This rule targets errors where the reasoning_effort parameter is incompatible with the selected Codex model.
  • User-Friendly Messaging: When triggered, the rule provides a clear, user-friendly Chinese message to the user, suggesting adjustments to the reasoning_effort parameter or model selection.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 a new error rule to handle a specific Codex API error for incompatible reasoning_effort values. The change is well-contained and improves the user experience by providing a more informative error message. I have one suggestion to make the regular expression more specific and robust.

},
// Issue #541: Codex model reasoning effort mismatch
{
pattern: "Unsupported value.*is not supported with.*model.*Supported values",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The current regex pattern is a bit broad and could potentially match other unrelated error messages, leading to incorrect error handling. It's better to make it more specific to the exact error format to increase robustness and prevent future false positives. This can be done by explicitly matching the quotes and punctuation from the example error message.

Suggested change
pattern: "Unsupported value.*is not supported with.*model.*Supported values",
pattern: "Unsupported value: '.*' is not supported with the '.*' model\\. Supported values are: '.*'\\.",

@github-actions github-actions bot added bug Something isn't working area:Error Rule labels Jan 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

🧪 测试结果

测试类型 状态
代码质量
单元测试
集成测试
API 测试

总体结果: ✅ 所有测试通过

@ding113 ding113 merged commit 696c283 into dev Jan 5, 2026
15 of 16 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in Claude Code Hub Roadmap Jan 5, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 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 6ab0c9d and 9dace34.

📒 Files selected for processing (1)
  • src/repository/error-rules.ts
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx,js,jsx,json}

📄 CodeRabbit inference engine (CLAUDE.md)

Use 2-space indentation in all code files

Files:

  • src/repository/error-rules.ts
**/*.{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/repository/error-rules.ts
src/repository/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Use Repository pattern in src/repository/ to wrap Drizzle queries

Files:

  • src/repository/error-rules.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/repository/error-rules.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/repository/error-rules.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/error-rules.ts
🧠 Learnings (1)
📚 Learning: 2026-01-05T03:01:39.354Z
Learnt from: NieiR
Repo: ding113/claude-code-hub PR: 539
File: src/types/user.ts:158-170
Timestamp: 2026-01-05T03:01:39.354Z
Learning: In TypeScript interfaces, explicitly document and enforce distinct meanings for null and undefined. Example: for numeric limits like limitTotalUsd, use 'number | null | undefined' when null signifies explicitly unlimited (e.g., matches DB schema or special UI logic) and undefined signifies 'inherit default'. This pattern should be consistently reflected in type definitions across related fields to preserve semantic clarity between database constraints and UI behavior.

Applied to files:

  • src/repository/error-rules.ts
⏰ 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). (8)
  • GitHub Check: Greptile Review
  • GitHub Check: check-codex-status
  • GitHub Check: pr-review
  • GitHub Check: pr-description
  • GitHub Check: pr-label
  • GitHub Check: 🌐 API Tests
  • GitHub Check: Docker Build Test
  • GitHub Check: dev-build-deploy

Comment on lines +708 to +725
// Issue #541: Codex model reasoning effort mismatch
{
pattern: "Unsupported value.*is not supported with.*model.*Supported values",
category: "thinking_error",
description: "Reasoning effort (thinking intensity) not supported by the Codex model",
matchType: "regex" as const,
isDefault: true,
isEnabled: true,
priority: 72,
overrideResponse: {
type: "error",
error: {
type: "thinking_error",
message:
"当前思考强度不支持该模型,请调整 reasoning_effort 参数或切换模型(如 'high' 仅支持部分模型)",
},
},
},
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# 查看文件大小和结构
wc -l src/repository/error-rules.ts

Repository: ding113/claude-code-hub

Length of output: 100


🏁 Script executed:

# 查看 708-725 行的代码
sed -n '700,730p' src/repository/error-rules.ts | cat -n

Repository: ding113/claude-code-hub

Length of output: 1026


🏁 Script executed:

# 查看周围的错误规则以验证优先级顺序
sed -n '690,740p' src/repository/error-rules.ts | cat -n

Repository: ding113/claude-code-hub

Length of output: 1670


🏁 Script executed:

# 搜索所有 thinking_error 分类的规则及其优先级
rg -n --type ts 'thinking_error' src/repository/error-rules.ts -B5 -A10

Repository: ding113/claude-code-hub

Length of output: 2242


🏁 Script executed:

# 搜索 reasoning_effort 相关的代码
rg -n --type ts 'reasoning_effort' --max-count=20

Repository: ding113/claude-code-hub

Length of output: 2843


🏁 Script executed:

# 检查是否有其他 Codex 或思维强度相关的错误规则
rg -n --type ts 'Codex|reasoning.*effort' src/repository/error-rules.ts -B2 -A2

Repository: ding113/claude-code-hub

Length of output: 593


🏁 Script executed:

# 检查第 722 行的精确字符数
sed -n '722p' src/repository/error-rules.ts | wc -c

Repository: ding113/claude-code-hub

Length of output: 70


🏁 Script executed:

# 查看第 721-723 行的完整内容
sed -n '721,723p' src/repository/error-rules.ts

Repository: ding113/claude-code-hub

Length of output: 165


🏁 Script executed:

# 查找 ClaudeErrorResponse 接口定义
rg -n --type ts 'interface ClaudeErrorResponse|type ClaudeErrorResponse' -A10

Repository: ding113/claude-code-hub

Length of output: 701


🏁 Script executed:

# 搜索所有 thinking_error 类别的规则,看是否有其他需要同步的地方
rg -n 'thinking_error' src/repository/error-rules.ts -B1 -A1

Repository: ding113/claude-code-hub

Length of output: 892


🏁 Script executed:

# 检查周围 70-80 优先级范围内的规则
sed -n '600,730p' src/repository/error-rules.ts | grep -n 'priority'

Repository: ding113/claude-code-hub

Length of output: 215


🏁 Script executed:

# 再确认一下完整的第 722 行内容和缩进情况
sed -n '720,724p' src/repository/error-rules.ts | cat -A

Repository: ding113/claude-code-hub

Length of output: 511


🏁 Script executed:

# 检查是否有其他行也超过了 100 字符限制
awk 'NR>=708 && NR<=725 && length($0) > 100 {print NR": "length($0)" chars - "$0}' src/repository/error-rules.ts

Repository: ding113/claude-code-hub

Length of output: 156


修复行长度超限问题

新增的错误规则实现质量整体良好,但存在一个代码风格违规:

行长度超限:第 722 行有 138 个字符,超过编码规范规定的 100 字符限制。需要拆分长字符串:

建议修复方案
message:
  "当前思考强度不支持该模型,请调整 reasoning_effort 参数或" +
  "切换模型(如 'high' 仅支持部分模型)",

或使用模板字符串分行:

message:
  `当前思考强度不支持该模型,请调整 reasoning_effort 参数或切换模型` +
  `(如 'high' 仅支持部分模型)`,

其他方面正确:2 空格缩进、双引号、尾随逗号、正则模式、分类(thinking_error)、优先级位置(72,介于 71 和下一级之间)、ClaudeErrorResponse 接口格式都符合规范。

🤖 Prompt for AI Agents
In src/repository/error-rules.ts around lines 708 to 725, the message string on
line 722 exceeds the 100-character line length limit; split the long string into
multiple shorter string literals concatenated (or use a template literal broken
into concatenated parts) so no single source line exceeds 100 chars, preserve
the existing double-quote style and trailing comma, keep indentation consistent
with surrounding entries, and ensure the final overrideResponse.message content
remains identical.

@github-actions github-actions bot added the size/XS Extra Small PR (< 50 lines) label Jan 5, 2026
},
// Issue #541: Codex model reasoning effort mismatch
{
pattern: "Unsupported value.*is not supported with.*model.*Supported values",
Copy link
Contributor

Choose a reason for hiding this comment

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

[High] [LOGIC-BUG] Regex pattern is too broad and can misclassify unrelated “Unsupported value” errors

Evidence (src/repository/error-rules.ts:710):

pattern: "Unsupported value.*is not supported with.*model.*Supported values",

…and the override message is reasoning-effort specific (src/repository/error-rules.ts:721-722).

Why this is a problem: That error string format is generic (many OpenAI/Codex invalid_request_error cases use “Unsupported value … Supported values …”). With the current pattern, unrelated unsupported-value errors (e.g. other params) will be overridden with a reasoning_effort troubleshooting message, hiding the real cause and misleading users.

Suggested fix (tighten the regex to require a reasoning-effort signal from the upstream body):

{
  // ...
  pattern:
    "(\\\"param\\\"\\s*:\\s*\\\"reasoning_effort\\\"|reasoning_effort).*Unsupported value.*is not supported with.*model.*Supported values",
  category: "thinking_error",
  // ...
}

Copy link
Contributor

@github-actions github-actions bot left a comment

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 adds a new default error rule intended to translate a Codex reasoning_effort mismatch into a user-friendly message. The current regex is overly generic and can match other “Unsupported value … Supported values …” errors, potentially returning a misleading reasoning_effort message and obscuring the real failure.

PR Size: XS

  • Lines changed: 18
  • Files changed: 1

Issues Found

Category Critical High Medium Low
Logic/Bugs 0 1 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

Critical Issues (Must Fix)

None

High Priority Issues (Should Fix)

  • src/repository/error-rules.ts:710 [High] [LOGIC-BUG] Regex is too broad and may override unrelated unsupported-value errors with a reasoning_effort-specific message (confidence: 88).

Review Coverage

  • Logic and correctness
  • Security (OWASP Top 10)
  • Error handling
  • Type safety
  • Documentation accuracy
  • Test coverage
  • Code clarity

Automated review by Codex AI

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

  • Identified open PR as #544 and calculated PR Size: XS (18 lines changed, 1 file).
  • Applied label size/XS via gh pr edit.
  • Posted 1 inline review comment on src/repository/error-rules.ts:710 flagging a [High] [LOGIC-BUG]: the new regex is broad enough to override unrelated “Unsupported value … Supported values …” errors with a reasoning-effort-specific message; suggested tightening the pattern to require a reasoning_effort signal (e.g., "param": "reasoning_effort" in upstream JSON).
  • Submitted the required review summary using gh pr review --comment --body ....

Note: the GitHub API in this environment rejected line/side; I successfully created the inline comment using position + subject_type instead.

This was referenced Jan 6, 2026
@ding113 ding113 deleted the fix/issue-541-codex-reasoning-effort-error branch January 27, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Error Rule bug Something isn't working size/XS Extra Small PR (< 50 lines)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant

Comments