Skip to content

feat(task): task-local thinking effort state, per-request override, and adaptive effort envelope (DTE series 2/5) #1329

Description

@easonLiangWorldedtech

What

Introduce a task-local runtimeThinkingEffort override for reasoning effort, resolved per API request (next-request semantics), passed through metadata.reasoningEffort, and emitted as the adaptive-model effort envelope (output_config.effort) where applicable. This is the state + plumbing PR.

Part of the Dynamic Thinking Effort series (5 PRs). Master design issue: easonLiangWorldedtech#28.

PR protocol (all series PRs): draft PR until CI is fully green -> switch to ready -> CodeRabbit bot review addressed in full -> 100% test coverage on patch lines. Each PR <= 1000 diff lines, based on latest upstream main (stacked on preceding series PRs where noted; rebased to pure main once dependencies merge).

Stacking: PR 2/5 — standalone, based on main.

Design

Resolution order (strongest first):

  1. task.runtimeThinkingEffort (task-local; written by the model tool in PR 3 and the user control in PR 4)
  2. settings reasoningEffort
  3. model default
  • Task-local state is discarded at task end and never written to Settings.
  • setRuntimeThinkingEffort(effort, source) is the single write path (source: model tool / user).
  • ApiHandlerCreateMessageMetadata.reasoningEffort? — per-request override channel, same pattern as the abort signal (metadata read at request build time) and the existing Bedrock metadata.thinking precedent.
  • Adaptive Anthropic class (supportsReasoningBinary models): when the effective effort resolves, the request carries output_config: { effort } clamped to [low, medium, high, xhigh, max] (soft-guidance envelope). The Bedrock handler already sends a hardcoded xhigh envelope — left unchanged (documented follow-up).

Acceptance criteria

  • An override takes effect on the next API request (no mid-stream effect) for all providers with per-request effort support
  • Adaptive-class Anthropic requests carry output_config.effort when effort resolves; omitted otherwise (no 400s)
  • State resets at task end; persisted Settings value is never modified
  • Tests: state set/get/reset, metadata precedence over settings, envelope presence/absence; 100% patch coverage; <= 1000 diff lines

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions