Skip to content

feat(effort): add independent effort control for Anthropic 4.6 models#27812

Open
GodsBoy wants to merge 1 commit intoopenclaw:mainfrom
GodsBoy:feat/independent-effort-control
Open

feat(effort): add independent effort control for Anthropic 4.6 models#27812
GodsBoy wants to merge 1 commit intoopenclaw:mainfrom
GodsBoy:feat/independent-effort-control

Conversation

@GodsBoy
Copy link
Contributor

@GodsBoy GodsBoy commented Feb 26, 2026

Summary

Adds an independent /effort control for Anthropic Claude Opus 4.6 and Sonnet 4.6 models, decoupling effort from the existing /think toggle.

Problem

Anthropic's Claude 4.6 models support two independent parameters:

  • thinking (on/off/adaptive with budget guidance) — controlled by /think
  • effort (low/medium/high, plus max for Opus only) — not exposed

Currently OpenClaw ties both to the single /think toggle. Users cannot configure "thinking off + high effort" which scored #1 out of 60 non-reasoning models on the Artificial Analysis Intelligence Index, with faster TTFT and no thinking token overhead.

pi-ai v0.55.1 already exposes AnthropicOptions.effort (AnthropicEffort: "low" | "medium" | "high" | "max"). This PR wires it through OpenClaw.

Changes

  • src/auto-reply/thinking.ts: New EffortLevel type, normalizeEffortLevel(), listEffortLevels(), formatEffortLevels()
  • src/auto-reply/commands-registry.data.ts: Register /effort slash command with /e alias
  • src/agents/pi-embedded-runner/extra-params.ts: Pass effort independently to AnthropicOptions.effort for Anthropic provider; OpenRouter backward compat maintained
  • src/agents/pi-embedded-runner/run/: Accept and forward effortLevel alongside thinkLevel
  • Session state: effortLevel stored alongside thinkLevel in session config
  • /status: Shows current effort level
  • Tests: 96 new lines covering effort normalization and independence
  • Docs: Updated docs/providers/anthropic.md with effort control section

Behavior

  • /effort high — sets effort independently from thinking
  • /effort off — clears effort override (provider decides)
  • /think off + /effort high — the optimal non-reasoning config
  • max only available for Opus 4.6 models
  • Fully backward compatible: /think works exactly as before

Testing

  • pnpm check — passes
  • pnpm build — passes
  • pnpm test — 111 tests pass across related files (3 pre-existing env-specific failures unrelated)

Closes #9837 (effort portion)

@openclaw-barnacle openclaw-barnacle bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M labels Feb 26, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 26, 2026

Greptile Summary

This PR successfully adds independent /effort control for Anthropic Claude 4.6 models, decoupling effort configuration from the existing /think toggle. The implementation is clean, well-tested, and follows existing code patterns.

Key Changes:

  • New EffortLevel type and normalization functions in src/auto-reply/thinking.ts (following the same pattern as ThinkLevel)
  • /effort command registered with /e alias in the commands registry
  • Effort level stored in session state and displayed in /status output
  • output_config.effort injected into Anthropic API payloads via createAnthropicEffortWrapper() in extra-params.ts
  • Model-aware validation: max effort restricted to Opus 4.6 models only
  • 96 new test lines covering effort normalization, model support detection, and directive parsing
  • Documentation updated in docs/providers/anthropic.md

Implementation Quality:

  • Properly scoped to anthropic provider only (line 753 in extra-params.ts)
  • OpenRouter continues using thinking level for reasoning.effort (backward compatible)
  • Comprehensive test coverage for all new functions
  • Session persistence properly implemented
  • Follows existing directive handling patterns

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is exceptionally clean and well-architected. It follows established patterns in the codebase, includes comprehensive test coverage (96 new test lines), and properly validates edge cases like model-specific effort levels. The changes are properly scoped to only affect Anthropic provider, maintaining backward compatibility with OpenRouter and other providers. All code paths are accounted for from command registration through session persistence to API invocation.
  • No files require special attention

Last reviewed commit: b2d5df6

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2d5df6652

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch from b2d5df6 to 920a35b Compare February 26, 2026 18:20
@GodsBoy
Copy link
Contributor Author

GodsBoy commented Feb 26, 2026

Good catch @chatgpt-codex-connector — fixed in 920a35b. Added hasEffortDirective: false and effortLevel: undefined to the unauthorized sender gate in get-reply-directives.ts, consistent with the other command directives.

@chatgpt-codex-connector
Copy link

To use Codex here, create a Codex account and connect to github.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 920a35b6a1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch from 920a35b to 5d77d6f Compare February 26, 2026 18:31
@GodsBoy
Copy link
Contributor Author

GodsBoy commented Feb 26, 2026

Second catch fixed in 5d77d6f — added hasEffortDirective to the hasInlineDirective guard in get-reply-directives.ts (line 237). Now /effort in mixed chat content triggers the directive-only check and gets cleared, consistent with /think and other inline directives.

@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch from 5d77d6f to 80ab716 Compare February 26, 2026 18:35
@GodsBoy
Copy link
Contributor Author

GodsBoy commented Feb 26, 2026

All three Codex review comments addressed and resolved:

  1. P1 — Auth bypass (920a35b): hasEffortDirective: false + effortLevel: undefined added to unauthorized sender gate
  2. P1 — Mixed content (5d77d6f): hasEffortDirective added to hasInlineDirective guard
  3. P2 — Stale max effort (80ab716): resolvedEffortLevel now clamps max to high when model doesn't support it (e.g. session stored /effort max on Opus then switched to Sonnet)

All checks pass: pnpm check && pnpm build

@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch from 80ab716 to 709398a Compare February 26, 2026 18:41
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 709398a149

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch 2 times, most recently from e00f974 to 8b3c236 Compare February 26, 2026 19:05
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b3c236e66

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch from 8b3c236 to b587a67 Compare February 26, 2026 19:30
@GodsBoy
Copy link
Contributor Author

GodsBoy commented Feb 26, 2026

All 6 Codex review threads now addressed and resolved:

Round 1 (fixed earlier):

  1. P1 — Auth bypass: effort directives stripped for unauthorized senders ✅
  2. P1 — Mixed content: effort added to inline directive guard ✅
  3. P2 — Stale max on model switch: clamped in directive resolution ✅

Round 2 (fixed in b587a67):
4. P1 — Propagation: false positive — effortLevel was already wired through the full chain ✅
5. P2 — Max effort on fallback: extra-params.ts now clamps max→high for non-Opus models ✅
6. P1 — Gate to 4.6 models: new supportsEffort() function checks both provider AND model family before injecting effort ✅

Additional improvements in this round:

  • Added EFFORT_MODEL_PREFIXES for all Claude 4.6 family (opus-4-6, sonnet-4-6, sonnet-4-5)
  • Added supportsEffort() export with 4 new test cases (34 total thinking tests)
  • Effort injection docs added to docs/tools/slash-commands.md (fixes doc test)

All tests pass (72/72), pnpm check && pnpm build clean.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b587a674dc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch from b587a67 to 770f93c Compare February 26, 2026 19:45
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 770f93c431

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch from 770f93c to ec68145 Compare February 26, 2026 19:55
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ec68145b92

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch 2 times, most recently from 780d661 to 4110f49 Compare February 26, 2026 20:35
@openclaw-barnacle openclaw-barnacle bot added app: web-ui App: web-ui gateway Gateway runtime commands Command implementations labels Feb 26, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4110f495ff

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch from 4110f49 to 6a332c2 Compare February 26, 2026 20:54
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a332c29be

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch from 6a332c2 to 519426f Compare February 26, 2026 21:20
@openclaw-barnacle openclaw-barnacle bot added the app: macos App: macos label Feb 26, 2026
@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch 3 times, most recently from c7a7568 to 6e778d9 Compare February 26, 2026 21:33
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e778d9754

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch 2 times, most recently from c6371fb to 95bc782 Compare February 26, 2026 21:50
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95bc7823b8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@GodsBoy
Copy link
Contributor Author

GodsBoy commented Feb 27, 2026

PR Summary

What: Independent /effort control for Anthropic Claude 4.6 models (Opus and Sonnet), decoupled from the existing /think toggle.

Why: Anthropic Claude 4.6 models support effort as an independent parameter from thinking. Currently OpenClaw conflates them via /think. With effort separated, users can run thinking: off + effort: high (the #1 non-reasoning config on Artificial Analysis benchmarks per #9837).

How:

  • New /effort slash command (/e alias) with levels: off, low, medium, high, max (max = Opus only)
  • supportsEffort() / supportsMaxEffort() model capability gates (Claude 4.6 family only)
  • Effort wired through the full chain: directives → session state → embedded runs → followup queue → status display → gateway APIs → Swift protocol
  • Falls back gracefully: persists on unsupported models (no-op at runtime, consistent with /think behavior), clamps maxhigh on non-Opus

CI note: The 3 failing checks are pre-existing on main:

  • bun test: nodes-utils.test.ts assertion (Bun object iteration order differs from Node)
  • windows test (x2): plugins/loader.test.ts + config/includes.test.ts

All Linux Node checks pass. Single squashed commit, 42 files changed.

Refs: #9837

@kennedybaird
Copy link

@GodsBoy are you running this as a local patch for yourself at the moment?

@GodsBoy
Copy link
Contributor Author

GodsBoy commented Mar 1, 2026

Yes — running it as a local patch on my production OpenClaw instance. Been using it daily for a few weeks now. The main use case for me is running sub-agents with thinking disabled but effort high (nothink mode) for faster non-reasoning tasks, while keeping effort: high with thinking enabled for complex reasoning sessions. The two controls are genuinely independent in the API and it makes a real difference in practice.

Would love a second pair of eyes on it if you're interested in testing. Happy to answer any questions about the implementation.

@GodsBoy
Copy link
Contributor Author

GodsBoy commented Mar 2, 2026

Thanks for flagging — but the 3.1 change doesn't cover this PR.

The 3.1 changelog entry ("set adaptive as the default thinking level for Anthropic Claude 4.6 models") only changes the default thinking level — equivalent to auto-enabling /think for 4.6 models. That's the thinking parameter.

This PR is about the effort parameter — a completely separate API field that controls reasoning depth independently of whether thinking blocks are active at all. The word "effort" doesn't appear in the 3.1 changelog and the feature isn't in the codebase.

The use case this unlocks that 3.1 doesn't address:

  • Thinking off + effort high — the "nothink" configuration. No thinking token overhead, but maximum reasoning budget for computation. This scored #1 out of 60 non-reasoning models on the Artificial Analysis Intelligence Index in TTFT-adjusted benchmarks.
  • Thinking adaptive + effort low — reduced cost for lighter tasks where full effort isn't needed.
  • Any mix of the two controls independently — which is what Anthropic's API actually exposes.

I've been running this as a local patch on production for several weeks. The two controls are genuinely independent at the API level and the current /think toggle cannot replicate them. Happy to rebase on latest main if that helps move this forward.

@GodsBoy GodsBoy force-pushed the feat/independent-effort-control branch from 95bc782 to 4f45a05 Compare March 6, 2026 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: macos App: macos app: web-ui App: web-ui commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support Anthropic adaptive thinking and effort parameter for Opus 4.6

2 participants