feat(effort): Add model-level reasoning effort routing - #1780
Conversation
Introduce per-model reasoning control metadata on catalog entries and model descriptors so /effort support can be expanded without provider-wide inference. Resolve /effort through explicit model metadata first, preserve legacy allowlist behavior, and treat supportsReasoning-only entries as capability metadata that does not mutate requests. Guard OpenAI shim effort serialization with the model-level wire support check and add focused tests for capability-only, explicit metadata, opt-out, and toggle-mode cases. Document the reasoning metadata contract and provider follow-up workflow.
Centralize OpenAI shim reasoning request planning so DeepSeek-compatible and Z.AI-compatible controls flow through the effort resolver instead of provider-specific shim helpers. Add compatibility metadata handling for DeepSeek and Z.AI routes while keeping supportsReasoning-only catalog entries non-controllable until exact wire formats are verified. Respect route removeBodyFields after compatibility serialization and make provider override support checks use the resolved override route/base URL instead of ambient provider metadata. Document temporary compatibility rules and add regression coverage for Atlas DeepSeek, Z.AI levels, Groq stripping, providerOverride OpenAI effort, providerOverride Groq stripping, and non-generic metadata opt-out. Verified: bun test --feature=UNATTENDED_RETRY src/utils/effort.codex.test.ts; bun test --feature=UNATTENDED_RETRY src/services/api/client.test.ts; bun test --feature=UNATTENDED_RETRY src/services/api/openaiShim.test.ts; node .\\node_modules\\typescript\\bin\\tsc --noEmit; bun run build; git diff --check.
Send reasoning effort on OpenAI-compatible Responses requests using the nested reasoning object expected by the endpoint instead of flat reasoning_effort/reasoning_summary fields. Keep chat_completions behavior unchanged so OpenAI-compatible chat endpoints still receive top-level reasoning_effort. Add a regression test covering the Responses request body shape and verifying the flat fields are omitted. Validation: bun test --feature=UNATTENDED_RETRY src/services/api/openaiShim.test.ts; node .\\node_modules\\typescript\\bin\\tsc --noEmit; git diff --check.
Make the new reasoning-effort guide discoverable from the integrations overview and reading order. Update model, gateway, and vendor onboarding docs to explain that supportsReasoning is descriptive only and does not enable /effort request mutation without verified per-model reasoning metadata. Clarify that gateway and vendor catalogs must annotate reasoning controls per exact route/model rather than provider-wide. Validation: git diff --check.
Add an optional reasoning control context so effort tests can inject provider, catalog, model descriptor, and shim metadata without mocking process-global integration/provider modules. Update effort.codex tests to use the injected context and restore only the remaining local mocks, preventing mock leakage into later full-suite provider tests. Validation: bun run check; bun run test:provider; bun run test:provider-recommendation; bun run typecheck:type-tests; bun run integrations:check; python -m pytest -q python/tests; bun run security:pr-scan -- --base upstream/main --head HEAD.
📝 WalkthroughWalkthroughAdds reasoning metadata docs and descriptor fields, makes effort resolution context-aware across catalog and compatibility routes, and updates OpenAI shim/client request shaping plus tests to serialize or omit reasoning fields by model and route support. ChangesReasoning controls
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 6 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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 `@docs/integrations/reasoning-effort.md`:
- Around line 11-24: Update the reasoning metadata example so
`ReasoningControlMetadata.levels` is shown as a subset array rather than a fixed
ordered tuple; use the `reasoning` block in the documentation to reflect that
`levels` can contain any valid `ReasoningEffortLevel[]` subset, not necessarily
all five values. Keep the example aligned with the current
`ReasoningControlMetadata`/`ReasoningEffortLevel` behavior so contributors
understand they may provide partial lists like `['high', 'xhigh']`.
- Around line 29-38: The “unknown models do not receive new reasoning request
fields” wording is too broad and conflicts with the compatibility behavior in
the effort resolver. Update the docs to reflect that src/utils/effort.ts still
applies heuristic compatibility shaping for certain uncatalogued routes/models
(for example DeepSeek- and Z.AI-compatible paths) even without explicit
reasoning metadata, while truly unknown models remain unchanged. Keep the
wording narrowly scoped to the resolver behavior and mention the preserved
compat path so readers do not assume all uncatalogued models are untouched.
In `@src/integrations/runtimeMetadata.ts`:
- Around line 241-247: The route selection in runtimeMetadata should not fall
back to the ambient activeRouteId when preferBaseUrlRoute is true and
resolveRouteIdFromBaseUrl returns nothing. Update the routeId logic so a
base-URL-preferred override either uses the resolved base URL route or stays
isolated from ambient provider settings, and verify the behavior around
resolveRouteIdFromBaseUrl, preferBaseUrlRoute, and activeRouteId so descriptor
values like endpointPath, removeBodyFields, and auth headers do not leak in.
In `@src/utils/effort.ts`:
- Around line 123-130: The metadata path in metadataWireFormatSupportsEffort()
is too strict and blocks /effort for compat catalogs by making
resolveMetadataReasoningControl() return non-controllable before
resolveModelReasoningControl() can reach the legacy/compat fallback. Update the
effort resolution flow so metadata with deepseek_compatible or zai_compatible is
treated as effort-capable, or otherwise keep those wire formats out of the
metadata contract until supported; make sure the behavior in
resolveMetadataReasoningControl() and resolveModelReasoningControl() matches the
intended precedence for compat-capable entries.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: ab307ef5-f287-4f4c-91b4-5db4eaf92642
📒 Files selected for processing (13)
docs/integrations/how-to/add-gateway.mddocs/integrations/how-to/add-model.mddocs/integrations/how-to/add-vendor.mddocs/integrations/overview.mddocs/integrations/reasoning-effort.mdsrc/integrations/descriptors.tssrc/integrations/runtimeMetadata.tssrc/services/api/client.test.tssrc/services/api/client.tssrc/services/api/openaiShim.test.tssrc/services/api/openaiShim.tssrc/utils/effort.codex.test.tssrc/utils/effort.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (16)
**/*.{ts,tsx,js,jsx,py,json,md}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Follow the existing code style in the touched files
Files:
docs/integrations/reasoning-effort.mddocs/integrations/how-to/add-vendor.mddocs/integrations/how-to/add-gateway.mdsrc/integrations/runtimeMetadata.tsdocs/integrations/how-to/add-model.mdsrc/services/api/client.test.tsdocs/integrations/overview.mdsrc/integrations/descriptors.tssrc/services/api/openaiShim.test.tssrc/services/api/client.tssrc/services/api/openaiShim.tssrc/utils/effort.codex.test.tssrc/utils/effort.ts
docs/**/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Update docs when setup, commands, or user-facing behavior changes
Files:
docs/integrations/reasoning-effort.mddocs/integrations/how-to/add-vendor.mddocs/integrations/how-to/add-gateway.mddocs/integrations/how-to/add-model.mddocs/integrations/overview.md
**
⚙️ CodeRabbit configuration file
**: # AGENTS.md - AI Agent Coding GuideThis guide is for AI coding agents working in the OpenClaude repository. Read it before changing code, and also follow CONTRIBUTING.md for contributor policy, PR expectations, review follow-up, and project scope.
Project Snapshot
OpenClaude is a coding-agent CLI for cloud and local model providers. It supports OpenAI-compatible APIs, Anthropic, Gemini, DeepSeek, Ollama, MCP, local backends, slash commands, tools, agents, and a React/Ink terminal UI.
The installed CLI runs on Node.js
>=22.0.0. Bun is used for source builds, scripts, dependency management, and tests.Work Style
- Keep changes focused on one problem.
- Prefer existing patterns in the file or nearby module.
- Avoid unrelated formatting, renames, dependency changes, or broad rewrites.
- Add or update tests when behavior changes.
- Update docs when setup, commands, provider behavior, or user-facing behavior changes.
- For new features, larger refactors, dependencies, or runtime changes, follow the issue-first guidance in CONTRIBUTING.md.
Stack And Conventions
- TypeScript with strict mode and ESM imports.
- React + Ink for terminal UI.
- Bun lockfile and Bun scripts for development workflows.
- Node runtime for the built CLI.
- Python exists for legacy/local-provider helper code. Do not add new Python code or expand Python-based features unless a maintainer explicitly approves that direction.
Common libraries and patterns:
chalkfor terminal color.commanderfor CLI argument parsing.execafor child processes.- Existing service, provider, settings, permission, and UI patterns over new abstractions.
Repository Map
src/commands/- slash and CLI command implementations.src/components/- React/Ink UI components.src/services/- API, MCP, OAuth, wiki, voice, and other service integrations.src/tools/- tool implementations.src/utils/- shared utilities.- `src/integration...
Files:
docs/integrations/reasoning-effort.mddocs/integrations/how-to/add-vendor.mddocs/integrations/how-to/add-gateway.mdsrc/integrations/runtimeMetadata.tsdocs/integrations/how-to/add-model.mdsrc/services/api/client.test.tsdocs/integrations/overview.mdsrc/integrations/descriptors.tssrc/services/api/openaiShim.test.tssrc/services/api/client.tssrc/services/api/openaiShim.tssrc/utils/effort.codex.test.tssrc/utils/effort.ts
**/*
⚙️ CodeRabbit configuration file
**/*: Apply the OpenClaude maintainer review rubric from AGENTS.md. Review the current diff, not stale discussion context. Separate real blockers from suggestions. Do not request changes for vague style churn. Treat approval as merge-ready from CodeRabbit's side, pending required human review and GitHub Checks. If checks are failing or unavailable, say so clearly instead of implying the PR is fully ready.
Files:
docs/integrations/reasoning-effort.mddocs/integrations/how-to/add-vendor.mddocs/integrations/how-to/add-gateway.mdsrc/integrations/runtimeMetadata.tsdocs/integrations/how-to/add-model.mdsrc/services/api/client.test.tsdocs/integrations/overview.mdsrc/integrations/descriptors.tssrc/services/api/openaiShim.test.tssrc/services/api/client.tssrc/services/api/openaiShim.tssrc/utils/effort.codex.test.tssrc/utils/effort.ts
{README.md,CONTRIBUTING.md,docs/**,.github/pull_request_template.md}
⚙️ CodeRabbit configuration file
{README.md,CONTRIBUTING.md,docs/**,.github/pull_request_template.md}: Review docs for accuracy against current code behavior. Flag security or provider claims that overpromise, stale install commands, missing setup caveats, and instructions that could push users toward unsafe credential handling. Keep purely wording-level suggestions non-blocking.
Files:
docs/integrations/reasoning-effort.mddocs/integrations/how-to/add-vendor.mddocs/integrations/how-to/add-gateway.mddocs/integrations/how-to/add-model.mddocs/integrations/overview.md
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript with strict mode and ESM imports
Files:
src/integrations/runtimeMetadata.tssrc/services/api/client.test.tssrc/integrations/descriptors.tssrc/services/api/openaiShim.test.tssrc/services/api/client.tssrc/services/api/openaiShim.tssrc/utils/effort.codex.test.tssrc/utils/effort.ts
{src/integrations/**/*.ts,src/services/**/*.ts}
📄 CodeRabbit inference engine (AGENTS.md)
Test the exact provider/model path you changed when possible for provider modifications
Files:
src/integrations/runtimeMetadata.tssrc/services/api/client.test.tssrc/integrations/descriptors.tssrc/services/api/openaiShim.test.tssrc/services/api/client.tssrc/services/api/openaiShim.ts
src/integrations/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Check existing provider implementations before adding a new pattern
Files:
src/integrations/runtimeMetadata.tssrc/integrations/descriptors.ts
**/*.{ts,tsx,js,jsx,py}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Keep comments useful and concise
Files:
src/integrations/runtimeMetadata.tssrc/services/api/client.test.tssrc/integrations/descriptors.tssrc/services/api/openaiShim.test.tssrc/services/api/client.tssrc/services/api/openaiShim.tssrc/utils/effort.codex.test.tssrc/utils/effort.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Follow TypeScript strict mode and type safety practices by running typecheck before submitting
Files:
src/integrations/runtimeMetadata.tssrc/services/api/client.test.tssrc/integrations/descriptors.tssrc/services/api/openaiShim.test.tssrc/services/api/client.tssrc/services/api/openaiShim.tssrc/utils/effort.codex.test.tssrc/utils/effort.ts
{src/services/api/**,src/integrations/**,src/utils/model/**,src/utils/provider*.ts,src/commands/provider/**}
⚙️ CodeRabbit configuration file
{src/services/api/**,src/integrations/**,src/utils/model/**,src/utils/provider*.ts,src/commands/provider/**}: Review provider routing, model selection, env precedence, auth/token handling, OpenAI-compatible shims, retries, proxy behavior, and outbound HTTP behavior with high scrutiny. Block on silent default changes, hidden fallback expansion, credential reuse mistakes, hardcoded provider assumptions, or new network reach that is not intentional and documented.
Files:
src/integrations/runtimeMetadata.tssrc/services/api/client.test.tssrc/integrations/descriptors.tssrc/services/api/openaiShim.test.tssrc/services/api/client.tssrc/services/api/openaiShim.ts
{src/commands/**/*.ts,src/services/**/*.ts,src/entrypoints/**/*.ts}
📄 CodeRabbit inference engine (AGENTS.md)
Use
chalkfor terminal color in CLI code
Files:
src/services/api/client.test.tssrc/services/api/openaiShim.test.tssrc/services/api/client.tssrc/services/api/openaiShim.ts
{src/services/**/*.ts,src/utils/**/*.ts}
📄 CodeRabbit inference engine (AGENTS.md)
Use
execafor child processes
Files:
src/services/api/client.test.tssrc/services/api/openaiShim.test.tssrc/services/api/client.tssrc/services/api/openaiShim.tssrc/utils/effort.codex.test.tssrc/utils/effort.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Add or update tests when the change affects behavior
Files:
src/services/api/client.test.tssrc/services/api/openaiShim.test.tssrc/utils/effort.codex.test.ts
**/*.test.{ts,tsx,js}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Test the exact provider/model path you changed when possible
Files:
src/services/api/client.test.tssrc/services/api/openaiShim.test.tssrc/utils/effort.codex.test.ts
{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}
⚙️ CodeRabbit configuration file
{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}: Review tests for meaningful coverage of the changed behavior, isolation of global/env/config state, async cleanup, fake timers, provider profile leaks, and Windows-compatible assumptions. Block when risky runtime changes lack focused regression coverage or tests assert implementation details while missing the user-visible behavior.
Files:
src/services/api/client.test.tssrc/services/api/openaiShim.test.tssrc/utils/effort.codex.test.ts
🪛 LanguageTool
docs/integrations/overview.md
[style] ~47-~47: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ssary.mdfor the shared vocabulary. 3. Readdocs/integrations/reasoning-effort.md`...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
🔇 Additional comments (4)
src/services/api/openaiShim.ts (1)
41-41: LGTM!Also applies to: 2437-2457, 2510-2535, 2617-2621
src/services/api/openaiShim.test.ts (1)
360-400: LGTM!Also applies to: 6160-6193
src/services/api/client.ts (1)
15-16: LGTM!Also applies to: 49-49, 335-359
src/services/api/client.test.ts (1)
1335-1443: LGTM!
Load integration registry before catalog reasoning lookup, isolate provider override route resolution from ambient routes, and carry explicit compat reasoning metadata into the OpenAI shim request planner. Clarify reasoning metadata documentation and add focused regression coverage for compat metadata and provider override route preference.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/utils/effort.ts`:
- Around line 593-605: The metadata gate in effort resolution is missing the
`high` level, so `reasoningEffort` is dropped for `zai_compatible` entries that
only advertise `levels: ['high']`. Update the
`metadataZaiSupportsReasoningEffort` check in `src/utils/effort.ts` to include
`high`, keeping the existing `options.reasoningControl?.levels.includes(...)`
pattern aligned with the other supported levels. Add a focused regression test
around the effort normalization path (the
`reasoningEffort`/`normalizeZaiReasoningEffort` branch) to verify that a
high-only metadata entry preserves `/effort high`.
🪄 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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 83233507-75af-4d7e-82d2-a1865e269306
📒 Files selected for processing (6)
docs/integrations/reasoning-effort.mdsrc/integrations/runtimeMetadata.test.tssrc/integrations/runtimeMetadata.tssrc/services/api/openaiShim.tssrc/utils/effort.codex.test.tssrc/utils/effort.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: smoke-and-tests
- GitHub Check: typecheck
🧰 Additional context used
📓 Path-based instructions (16)
**/*.{ts,tsx,js,jsx,py,json,md}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Follow the existing code style in the touched files
Files:
docs/integrations/reasoning-effort.mdsrc/integrations/runtimeMetadata.test.tssrc/utils/effort.codex.test.tssrc/integrations/runtimeMetadata.tssrc/services/api/openaiShim.tssrc/utils/effort.ts
docs/**/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Update docs when setup, commands, or user-facing behavior changes
Files:
docs/integrations/reasoning-effort.md
**
⚙️ CodeRabbit configuration file
**: # AGENTS.md - AI Agent Coding GuideThis guide is for AI coding agents working in the OpenClaude repository. Read it before changing code, and also follow CONTRIBUTING.md for contributor policy, PR expectations, review follow-up, and project scope.
Project Snapshot
OpenClaude is a coding-agent CLI for cloud and local model providers. It supports OpenAI-compatible APIs, Anthropic, Gemini, DeepSeek, Ollama, MCP, local backends, slash commands, tools, agents, and a React/Ink terminal UI.
The installed CLI runs on Node.js
>=22.0.0. Bun is used for source builds, scripts, dependency management, and tests.Work Style
- Keep changes focused on one problem.
- Prefer existing patterns in the file or nearby module.
- Avoid unrelated formatting, renames, dependency changes, or broad rewrites.
- Add or update tests when behavior changes.
- Update docs when setup, commands, provider behavior, or user-facing behavior changes.
- For new features, larger refactors, dependencies, or runtime changes, follow the issue-first guidance in CONTRIBUTING.md.
Stack And Conventions
- TypeScript with strict mode and ESM imports.
- React + Ink for terminal UI.
- Bun lockfile and Bun scripts for development workflows.
- Node runtime for the built CLI.
- Python exists for legacy/local-provider helper code. Do not add new Python code or expand Python-based features unless a maintainer explicitly approves that direction.
Common libraries and patterns:
chalkfor terminal color.commanderfor CLI argument parsing.execafor child processes.- Existing service, provider, settings, permission, and UI patterns over new abstractions.
Repository Map
src/commands/- slash and CLI command implementations.src/components/- React/Ink UI components.src/services/- API, MCP, OAuth, wiki, voice, and other service integrations.src/tools/- tool implementations.src/utils/- shared utilities.- `src/integration...
Files:
docs/integrations/reasoning-effort.mdsrc/integrations/runtimeMetadata.test.tssrc/utils/effort.codex.test.tssrc/integrations/runtimeMetadata.tssrc/services/api/openaiShim.tssrc/utils/effort.ts
**/*
⚙️ CodeRabbit configuration file
**/*: Apply the OpenClaude maintainer review rubric from AGENTS.md. Review the current diff, not stale discussion context. Separate real blockers from suggestions. Do not request changes for vague style churn. Treat approval as merge-ready from CodeRabbit's side, pending required human review and GitHub Checks. If checks are failing or unavailable, say so clearly instead of implying the PR is fully ready.
Files:
docs/integrations/reasoning-effort.mdsrc/integrations/runtimeMetadata.test.tssrc/utils/effort.codex.test.tssrc/integrations/runtimeMetadata.tssrc/services/api/openaiShim.tssrc/utils/effort.ts
{README.md,CONTRIBUTING.md,docs/**,.github/pull_request_template.md}
⚙️ CodeRabbit configuration file
{README.md,CONTRIBUTING.md,docs/**,.github/pull_request_template.md}: Review docs for accuracy against current code behavior. Flag security or provider claims that overpromise, stale install commands, missing setup caveats, and instructions that could push users toward unsafe credential handling. Keep purely wording-level suggestions non-blocking.
Files:
docs/integrations/reasoning-effort.md
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript with strict mode and ESM imports
Files:
src/integrations/runtimeMetadata.test.tssrc/utils/effort.codex.test.tssrc/integrations/runtimeMetadata.tssrc/services/api/openaiShim.tssrc/utils/effort.ts
{src/integrations/**/*.ts,src/services/**/*.ts}
📄 CodeRabbit inference engine (AGENTS.md)
Test the exact provider/model path you changed when possible for provider modifications
Files:
src/integrations/runtimeMetadata.test.tssrc/integrations/runtimeMetadata.tssrc/services/api/openaiShim.ts
src/integrations/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Check existing provider implementations before adding a new pattern
Files:
src/integrations/runtimeMetadata.test.tssrc/integrations/runtimeMetadata.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Add or update tests when the change affects behavior
Files:
src/integrations/runtimeMetadata.test.tssrc/utils/effort.codex.test.ts
**/*.test.{ts,tsx,js}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Test the exact provider/model path you changed when possible
Files:
src/integrations/runtimeMetadata.test.tssrc/utils/effort.codex.test.ts
**/*.{ts,tsx,js,jsx,py}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Keep comments useful and concise
Files:
src/integrations/runtimeMetadata.test.tssrc/utils/effort.codex.test.tssrc/integrations/runtimeMetadata.tssrc/services/api/openaiShim.tssrc/utils/effort.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Follow TypeScript strict mode and type safety practices by running typecheck before submitting
Files:
src/integrations/runtimeMetadata.test.tssrc/utils/effort.codex.test.tssrc/integrations/runtimeMetadata.tssrc/services/api/openaiShim.tssrc/utils/effort.ts
{src/services/api/**,src/integrations/**,src/utils/model/**,src/utils/provider*.ts,src/commands/provider/**}
⚙️ CodeRabbit configuration file
{src/services/api/**,src/integrations/**,src/utils/model/**,src/utils/provider*.ts,src/commands/provider/**}: Review provider routing, model selection, env precedence, auth/token handling, OpenAI-compatible shims, retries, proxy behavior, and outbound HTTP behavior with high scrutiny. Block on silent default changes, hidden fallback expansion, credential reuse mistakes, hardcoded provider assumptions, or new network reach that is not intentional and documented.
Files:
src/integrations/runtimeMetadata.test.tssrc/integrations/runtimeMetadata.tssrc/services/api/openaiShim.ts
{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}
⚙️ CodeRabbit configuration file
{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}: Review tests for meaningful coverage of the changed behavior, isolation of global/env/config state, async cleanup, fake timers, provider profile leaks, and Windows-compatible assumptions. Block when risky runtime changes lack focused regression coverage or tests assert implementation details while missing the user-visible behavior.
Files:
src/integrations/runtimeMetadata.test.tssrc/utils/effort.codex.test.ts
{src/services/**/*.ts,src/utils/**/*.ts}
📄 CodeRabbit inference engine (AGENTS.md)
Use
execafor child processes
Files:
src/utils/effort.codex.test.tssrc/services/api/openaiShim.tssrc/utils/effort.ts
{src/commands/**/*.ts,src/services/**/*.ts,src/entrypoints/**/*.ts}
📄 CodeRabbit inference engine (AGENTS.md)
Use
chalkfor terminal color in CLI code
Files:
src/services/api/openaiShim.ts
Include high in the Z.AI-compatible metadata gate so high-only reasoning metadata emits reasoning_effort instead of silently dropping the user-selected effort. Add regression coverage for a high-only zai_compatible catalog entry flowing through the OpenAI shim request planner.
Allow unrecognized providerOverride OpenAI-compatible routes to fall back to legacy effort support instead of dropping user-selected effort. Constrain compat metadata levels to wire-faithful high/xhigh values and clarify reserved reasoning wire formats in docs and descriptors.
Resolve providerOverride effort against the override model and route context before converting it for the OpenAI shim, so stale persisted effort values respect per-model metadata levels. Add regression coverage for high-only providerOverride metadata and explicit max filtering in compat metadata levels.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/services/api/client.ts (1)
336-378: 🩺 Stability & Availability | 🟡 MinorAdd
CLAUDE_CODE_USE_OPENAIcoverage forreasoning_effort
src/services/api/client.tsnow gates shimreasoning_effortonmodelSupportsWireEffort(model)and clamps viaresolveAppliedEffort. Add asrc/services/api/client.test.tscase for the env-route path, ideally with an unsupported OpenAI-compatible model, to lock in the new omission behavior.🤖 Prompt for 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. In `@src/services/api/client.ts` around lines 336 - 378, `client.ts` now suppresses shim `reasoning_effort` when the model does not support wire effort, but this path is not covered for the `CLAUDE_CODE_USE_OPENAI` env-route flow. Add a `client.test.ts` case that exercises `resolveOpenAIShimRuntimeContext`/`resolveAppliedEffort` through an OpenAI-compatible provider override with an unsupported model, and assert that `shimReasoningEffort` is omitted instead of being sent.
🤖 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.
Outside diff comments:
In `@src/services/api/client.ts`:
- Around line 336-378: `client.ts` now suppresses shim `reasoning_effort` when
the model does not support wire effort, but this path is not covered for the
`CLAUDE_CODE_USE_OPENAI` env-route flow. Add a `client.test.ts` case that
exercises `resolveOpenAIShimRuntimeContext`/`resolveAppliedEffort` through an
OpenAI-compatible provider override with an unsupported model, and assert that
`shimReasoningEffort` is omitted instead of being sent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 9adebdde-4e93-49dd-b2ad-33585806cab0
📒 Files selected for processing (3)
src/services/api/client.test.tssrc/services/api/client.tssrc/utils/effort.codex.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: smoke-and-tests
- GitHub Check: typecheck
🧰 Additional context used
📓 Path-based instructions (13)
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript with strict mode and ESM imports
Files:
src/services/api/client.tssrc/utils/effort.codex.test.tssrc/services/api/client.test.ts
{src/commands/**/*.ts,src/services/**/*.ts,src/entrypoints/**/*.ts}
📄 CodeRabbit inference engine (AGENTS.md)
Use
chalkfor terminal color in CLI code
Files:
src/services/api/client.tssrc/services/api/client.test.ts
{src/services/**/*.ts,src/utils/**/*.ts}
📄 CodeRabbit inference engine (AGENTS.md)
Use
execafor child processes
Files:
src/services/api/client.tssrc/utils/effort.codex.test.tssrc/services/api/client.test.ts
{src/integrations/**/*.ts,src/services/**/*.ts}
📄 CodeRabbit inference engine (AGENTS.md)
Test the exact provider/model path you changed when possible for provider modifications
Files:
src/services/api/client.tssrc/services/api/client.test.ts
**/*.{ts,tsx,js,jsx,py,json,md}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Follow the existing code style in the touched files
Files:
src/services/api/client.tssrc/utils/effort.codex.test.tssrc/services/api/client.test.ts
**/*.{ts,tsx,js,jsx,py}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Keep comments useful and concise
Files:
src/services/api/client.tssrc/utils/effort.codex.test.tssrc/services/api/client.test.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Follow TypeScript strict mode and type safety practices by running typecheck before submitting
Files:
src/services/api/client.tssrc/utils/effort.codex.test.tssrc/services/api/client.test.ts
**
⚙️ CodeRabbit configuration file
**: # AGENTS.md - AI Agent Coding GuideThis guide is for AI coding agents working in the OpenClaude repository. Read it before changing code, and also follow CONTRIBUTING.md for contributor policy, PR expectations, review follow-up, and project scope.
Project Snapshot
OpenClaude is a coding-agent CLI for cloud and local model providers. It supports OpenAI-compatible APIs, Anthropic, Gemini, DeepSeek, Ollama, MCP, local backends, slash commands, tools, agents, and a React/Ink terminal UI.
The installed CLI runs on Node.js
>=22.0.0. Bun is used for source builds, scripts, dependency management, and tests.Work Style
- Keep changes focused on one problem.
- Prefer existing patterns in the file or nearby module.
- Avoid unrelated formatting, renames, dependency changes, or broad rewrites.
- Add or update tests when behavior changes.
- Update docs when setup, commands, provider behavior, or user-facing behavior changes.
- For new features, larger refactors, dependencies, or runtime changes, follow the issue-first guidance in CONTRIBUTING.md.
Stack And Conventions
- TypeScript with strict mode and ESM imports.
- React + Ink for terminal UI.
- Bun lockfile and Bun scripts for development workflows.
- Node runtime for the built CLI.
- Python exists for legacy/local-provider helper code. Do not add new Python code or expand Python-based features unless a maintainer explicitly approves that direction.
Common libraries and patterns:
chalkfor terminal color.commanderfor CLI argument parsing.execafor child processes.- Existing service, provider, settings, permission, and UI patterns over new abstractions.
Repository Map
src/commands/- slash and CLI command implementations.src/components/- React/Ink UI components.src/services/- API, MCP, OAuth, wiki, voice, and other service integrations.src/tools/- tool implementations.src/utils/- shared utilities.- `src/integration...
Files:
src/services/api/client.tssrc/utils/effort.codex.test.tssrc/services/api/client.test.ts
**/*
⚙️ CodeRabbit configuration file
**/*: Apply the OpenClaude maintainer review rubric from AGENTS.md. Review the current diff, not stale discussion context. Separate real blockers from suggestions. Do not request changes for vague style churn. Treat approval as merge-ready from CodeRabbit's side, pending required human review and GitHub Checks. If checks are failing or unavailable, say so clearly instead of implying the PR is fully ready.
Files:
src/services/api/client.tssrc/utils/effort.codex.test.tssrc/services/api/client.test.ts
{src/services/api/**,src/integrations/**,src/utils/model/**,src/utils/provider*.ts,src/commands/provider/**}
⚙️ CodeRabbit configuration file
{src/services/api/**,src/integrations/**,src/utils/model/**,src/utils/provider*.ts,src/commands/provider/**}: Review provider routing, model selection, env precedence, auth/token handling, OpenAI-compatible shims, retries, proxy behavior, and outbound HTTP behavior with high scrutiny. Block on silent default changes, hidden fallback expansion, credential reuse mistakes, hardcoded provider assumptions, or new network reach that is not intentional and documented.
Files:
src/services/api/client.tssrc/services/api/client.test.ts
**/*.test.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Add or update tests when the change affects behavior
Files:
src/utils/effort.codex.test.tssrc/services/api/client.test.ts
**/*.test.{ts,tsx,js}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Test the exact provider/model path you changed when possible
Files:
src/utils/effort.codex.test.tssrc/services/api/client.test.ts
{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}
⚙️ CodeRabbit configuration file
{src/**/*.test.ts,src/**/*.test.tsx,tests/**,scripts/**/*.test.ts,vscode-extension/**/*.test.js}: Review tests for meaningful coverage of the changed behavior, isolation of global/env/config state, async cleanup, fake timers, provider profile leaks, and Windows-compatible assumptions. Block when risky runtime changes lack focused regression coverage or tests assert implementation details while missing the user-visible behavior.
Files:
src/utils/effort.codex.test.tssrc/services/api/client.test.ts
🔇 Additional comments (2)
src/utils/effort.codex.test.ts (1)
676-746: LGTM!src/services/api/client.test.ts (1)
1446-1527: 📐 Maintainability & Code QualityNo issue here:
globalThis.fetchis restored in the sharedafterEach, so the stub stays isolated across tests.> Likely an incorrect or invalid review comment.
|
@kevincodex1 LGTM |
Rebased onto current main so the diff contains only these changes — Twigpine#1780's model-level effort routing now comes from main rather than being duplicated. - ultrathink: a `\bultrathink\b` keyword in a prompt injects a high-effort reminder, gated behind the isUltrathinkEnabled() rollout flag. - ultracode: a new session-only EffortLevel that maps to xhigh (or high) on the wire and grants a standing multi-agent orchestration permission. First-party only, suppressed under a per-agent providerOverride, and gated to xhigh-capable models. Honors CLAUDE_CODE_EFFORT_LEVEL precedence across the API path, the permission attachment, and the display surfaces; rejected from every agent-definition input (markdown/skill/plugin frontmatter, SDK, and JSON). Closes Twigpine#1551 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rebased onto current main so the diff contains only these changes — Twigpine#1780's model-level effort routing now comes from main rather than being duplicated. - ultrathink: a `\bultrathink\b` keyword in a prompt injects a high-effort reminder, gated behind the isUltrathinkEnabled() rollout flag. - ultracode: a new session-only EffortLevel that maps to xhigh (or high) on the wire and grants a standing multi-agent orchestration permission. First-party only, suppressed under a per-agent providerOverride, and gated to xhigh-capable models. Honors CLAUDE_CODE_EFFORT_LEVEL precedence across the API path, the permission attachment, and the display surfaces; rejected from every agent-definition input (markdown/skill/plugin frontmatter, SDK, and JSON). Closes Twigpine#1551 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ffort protocol GLM-5.2 (zai's reasoning-capable flagship) accepts a wire vocabulary of `high` / `max` for the chat-completions `reasoning_effort` field; older GLM versions reject the field outright. The openai provider's brand-id alias `zhiniao-glm-5.1` resolves to the same underlying GLM-5.2 model, so it must use the same wire contract. Add three helpers to src/utils/effort.ts: - `supportsZaiReasoningEffort(model)` — whitelist check; true for `glm-5.2`, `zai-org/glm-5.2`, and `zhiniao-glm-5.1` (strips the `?reasoning=<level>` query suffix before matching). - `modelLooksZaiCompatible(model)` — broader family check; any `glm-*` / `zai-org/glm-*` string. - `normalizeZaiReasoningEffort(effort)` — collapse OpenCC's full effort vocabulary to zai's two-value wire: `low` / `medium` / `high` → `high`; `xhigh` / `max` / `ultracode` → `max`. Wire the helpers into the chat-completions body emission in src/services/api/openaiShim/openaiClient.ts: when the resolved model is zai-effort-capable, route `request.reasoning.effort` through `normalizeZaiReasoningEffort` before writing the body; otherwise pass through unchanged. Add co-located tests in src/utils/effort.zai.test.ts covering the whitelist (positive + negative cases including query-suffix handling), the family-prefix matcher, and the effort normalizer's full vocabulary. Ports the GLM-5.2 portion of upstream cb689cc (Twigpine#1780) while intentionally dropping the wider reasoning-effort-routing system (DeepSeek compat, Responses API shape, runtime metadata registry, descriptor registry, Client.ts wholesale rewrite) — those pieces require fork-policy rework for removed providers and are deferred to a follow-up fsync session.
) (#1630) * feat: add ultrathink keyword detection and ultracode effort level Rebased onto current main so the diff contains only these changes — #1780's model-level effort routing now comes from main rather than being duplicated. - ultrathink: a `\bultrathink\b` keyword in a prompt injects a high-effort reminder, gated behind the isUltrathinkEnabled() rollout flag. - ultracode: a new session-only EffortLevel that maps to xhigh (or high) on the wire and grants a standing multi-agent orchestration permission. First-party only, suppressed under a per-agent providerOverride, and gated to xhigh-capable models. Honors CLAUDE_CODE_EFFORT_LEVEL precedence across the API path, the permission attachment, and the display surfaces; rejected from every agent-definition input (markdown/skill/plugin frontmatter, SDK, and JSON). Closes #1551 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(effort): clamp ultracode display availability * fix(effort): report effective effort overrides * test(model): avoid catalog-dependent effort label * fix(model): resolve current effort against session model * fix(spinner): resolve effort suffix against session model --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: jatmn <the@jat.mn>
…igpine#1551) (Twigpine#1630) * feat: add ultrathink keyword detection and ultracode effort level Rebased onto current main so the diff contains only these changes — Twigpine#1780's model-level effort routing now comes from main rather than being duplicated. - ultrathink: a `\bultrathink\b` keyword in a prompt injects a high-effort reminder, gated behind the isUltrathinkEnabled() rollout flag. - ultracode: a new session-only EffortLevel that maps to xhigh (or high) on the wire and grants a standing multi-agent orchestration permission. First-party only, suppressed under a per-agent providerOverride, and gated to xhigh-capable models. Honors CLAUDE_CODE_EFFORT_LEVEL precedence across the API path, the permission attachment, and the display surfaces; rejected from every agent-definition input (markdown/skill/plugin frontmatter, SDK, and JSON). Closes Twigpine#1551 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(effort): clamp ultracode display availability * fix(effort): report effective effort overrides * test(model): avoid catalog-dependent effort label * fix(model): resolve current effort against session model * fix(spinner): resolve effort suffix against session model --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: jatmn <the@jat.mn>
Summary
/effortcan be enabled per model instead of being gated only by provider-wide assumptions.src/utils/effort.ts, including backward-compatible compatibility handling for existing DeepSeek and Z.AI OpenAI-shim behavior./responsesrequests send nestedreasoning: { effort, summary: 'auto' }while Chat Completions keepsreasoning_effort.Fixes #1778.
Closes #1638.
Impact
/effortremains backward compatible for existing supported models, and the resolver can now support gateway/provider models once their per-model reasoning metadata is added in follow-up PRs.Related issues and PR coordination
reasoning.effortbehavior plus regression coverage while preserving Chat Completionsreasoning_effort.Testing
bun installbun run buildbun run smokebun run checkbun run typecheckbun run typecheck:type-testsbun run test:providerbun run test:provider-recommendationbun run integrations:checkpython -m pytest -q python/testsbun run security:pr-scan -- --base upstream/main --head HEADbun test --feature=UNATTENDED_RETRY src/utils/effort.codex.test.tsbun test --feature=UNATTENDED_RETRY src/services/api/client.test.tsbun test --feature=UNATTENDED_RETRY src/services/api/openaiShim.test.tsbun test src/utils/effort.codex.test.tsReview Risk Note
f4aef70and2fb5ba6, with focused regression coverage for route preference isolation, compat metadata planning, and high-only Z.AI metadata effort serialization.Notes
/responsesreasoning payloads, DeepSeek-compatible shim planning, Z.AI/GLM shim planning, and descriptor-backed gateway routing behavior in tests.reasoningmetadata only where the upstream API behavior is verified.Summary by CodeRabbit
New Features
/effortmetadata across mixed catalogs, vendors, and gateways.Bug Fixes
/responsespayload structure) and omit incompatible legacy fields.Tests