Skip to content

fix: make reasoning effort options model-aware#3309

Open
zwj110610 wants to merge 1 commit into
bytedance:mainfrom
zwj110610:fix-reasoning-effort-options
Open

fix: make reasoning effort options model-aware#3309
zwj110610 wants to merge 1 commit into
bytedance:mainfrom
zwj110610:fix-reasoning-effort-options

Conversation

@zwj110610
Copy link
Copy Markdown
Contributor

Summary

This PR makes reasoning_effort options 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 as low, medium, high, max, and xhigh. That could cause requests to fail with a provider-side 400 error.

Changes

  • Add optional reasoning_efforts to model configuration.
  • Expose reasoning_efforts through the Gateway /api/models response and embedded Python client.
  • Filter unsupported reasoning_effort values in the backend model factory as a defensive guard.
  • Update the frontend to render only the reasoning effort values supported by the selected model.
  • Normalize stale local reasoning effort values, such as minimal, to a supported value for the current model/mode.
  • Document the new config/API field and update config.example.yaml.
  • Add backend and frontend regression tests.

Testing

  • make doctor
  • cd backend && uv run --group dev pytest tests/test_model_factory.py -k reasoning_effort
  • cd 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.py
  • cd frontend && pnpm vitest run tests/unit/core/models/reasoning-effort.test.ts
  • cd frontend && pnpm check
  • pre-commit hooks passed during commit

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_efforts field to ModelConfig, surface via gateway /api/models and embedded client, and filter unsupported values in the model factory.
  • Centralize a new ReasoningEffort type plus getModelReasoningEfforts/getDefaultReasoningEffort/normalizeReasoningEffort helpers, and refactor InputBox to render and normalize per-model allowed values (adds max/xhigh i18n 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants