fix: make reasoning effort options model-aware#3309
Open
zwj110610 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Makes reasoning_effort model-aware to prevent sending unsupported values (e.g., "minimal") to providers like DeepSeek. Adds an optional reasoning_efforts allowlist on model config that flows through the gateway/client APIs and is enforced both in the backend factory and in the frontend UI.
Changes:
- Add optional
reasoning_effortsfield toModelConfig, surface via gateway/api/modelsand embedded client, and filter unsupported values in the model factory. - Centralize a new
ReasoningEfforttype plusgetModelReasoningEfforts/getDefaultReasoningEffort/normalizeReasoningEfforthelpers, and refactorInputBoxto render and normalize per-model allowed values (addsmax/xhighi18n labels). - Update docs/config example and add backend + frontend regression tests.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| backend/packages/harness/deerflow/config/model_config.py | Adds optional reasoning_efforts list field. |
| backend/packages/harness/deerflow/models/factory.py | Strips runtime/config reasoning_effort values not in allowlist; excludes new field from kwargs. |
| backend/packages/harness/deerflow/client.py | Adds helper and includes reasoning_efforts in list_models/get_model. |
| backend/app/gateway/routers/models.py | Exposes reasoning_efforts in ModelResponse and example payloads. |
| backend/tests/test_model_factory.py | Adds tests for allowlist filtering and preservation. |
| backend/tests/test_client.py | Asserts reasoning_efforts propagation through client/gateway. |
| backend/docs/CONFIGURATION.md, backend/docs/API.md | Documents the new field. |
| config.example.yaml | Example commented config for reasoning_efforts. |
| frontend/src/core/threads/types.ts | New shared ReasoningEffort type including max/xhigh. |
| frontend/src/core/models/types.ts | Adds reasoning_efforts to Model. |
| frontend/src/core/models/reasoning-effort.ts | New helpers for available/default/normalized efforts. |
| frontend/src/core/models/index.ts | Re-exports the new helpers. |
| frontend/src/core/settings/local.ts | Uses shared ReasoningEffort type. |
| frontend/src/components/workspace/input-box.tsx | Renders model-aware efforts, normalizes stale values on model/mode/init/early-submit. |
| frontend/src/core/i18n/locales/{types,en-US,zh-CN}.ts | Adds max/xhigh labels and descriptions. |
| frontend/tests/unit/core/models/reasoning-effort.test.ts | Unit tests for helper behavior. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR makes
reasoning_effortoptions model-aware so DeerFlow does not send unsupported reasoning effort values to providers such as DeepSeek.Previously, the frontend could send
reasoning_effort: "minimal"for Flash or stale local settings, but some providers only accept values such aslow,medium,high,max, andxhigh. That could cause requests to fail with a provider-side 400 error.Changes
reasoning_effortsto model configuration.reasoning_effortsthrough the Gateway/api/modelsresponse and embedded Python client.reasoning_effortvalues in the backend model factory as a defensive guard.minimal, to a supported value for the current model/mode.config.example.yaml.Testing
make doctorcd backend && uv run --group dev pytest tests/test_model_factory.py -k reasoning_effortcd backend && uv run --group dev pytest tests/test_client.py -k "list_models or get_model"cd backend && uv run --group dev ruff check app/gateway/routers/models.py packages/harness/deerflow/client.py packages/harness/deerflow/config/model_config.py packages/harness/deerflow/models/factory.py tests/test_client.py tests/test_model_factory.pycd frontend && pnpm vitest run tests/unit/core/models/reasoning-effort.test.tscd frontend && pnpm check