Skip to content

feat(agent): add thinking/reasoning level control per message#4332

Merged
SimianAstronaut7 merged 2 commits into
zeroclaw-labs:masterfrom
rareba:feat/thinking-levels
Mar 28, 2026
Merged

feat(agent): add thinking/reasoning level control per message#4332
SimianAstronaut7 merged 2 commits into
zeroclaw-labs:masterfrom
rareba:feat/thinking-levels

Conversation

@rareba
Copy link
Copy Markdown
Contributor

@rareba rareba commented Mar 23, 2026

Summary

  • Adds configurable thinking/reasoning depth levels per message
  • Allows the agent to control how much internal reasoning the model produces
  • Useful for balancing response quality vs latency/cost

Supersedes #4242 (accidentally closed during rebase)

Risk

  • Medium — src/agent/** behavior change

Test plan

  • Verify thinking levels are passed to provider correctly
  • Verify default level works when none specified
  • Verify level names are validated

Add ThinkingLevel enum (Off, Minimal, Low, Medium, High, Max) that
controls how deeply the model reasons per message, trading speed for
depth.

- New `src/agent/thinking.rs` module with:
  - ThinkingLevel enum with serde/JsonSchema support
  - ThinkingConfig with configurable default_level
  - parse_thinking_directive() to parse `/think:<level>` from messages
  - apply_thinking_level() returning temperature/token/prompt adjustments
  - resolve_thinking_level() with priority hierarchy:
    inline directive > session override > agent config > global default
  - Comprehensive tests for parsing, application, and resolution

- Wired into all three agent paths in loop_.rs:
  - Single-shot CLI path (run with message)
  - Interactive REPL path (with per-turn system prompt restoration)
  - Channel/daemon path (process_message)

- Added ThinkingConfig to AgentConfig in schema.rs (`[agent.thinking]`)
- Added /think:<level> to interactive /help output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The rebase conflict resolution doubled the `base_` prefix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@SimianAstronaut7 SimianAstronaut7 merged commit b67be41 into zeroclaw-labs:master Mar 28, 2026
18 checks passed
DCPRevere pushed a commit to DCPRevere/opsclaw that referenced this pull request Apr 8, 2026
…aw-labs#4332)

* feat(agent): add thinking/reasoning level control per message

Add ThinkingLevel enum (Off, Minimal, Low, Medium, High, Max) that
controls how deeply the model reasons per message, trading speed for
depth.

- New `src/agent/thinking.rs` module with:
  - ThinkingLevel enum with serde/JsonSchema support
  - ThinkingConfig with configurable default_level
  - parse_thinking_directive() to parse `/think:<level>` from messages
  - apply_thinking_level() returning temperature/token/prompt adjustments
  - resolve_thinking_level() with priority hierarchy:
    inline directive > session override > agent config > global default
  - Comprehensive tests for parsing, application, and resolution

- Wired into all three agent paths in loop_.rs:
  - Single-shot CLI path (run with message)
  - Interactive REPL path (with per-turn system prompt restoration)
  - Channel/daemon path (process_message)

- Added ThinkingConfig to AgentConfig in schema.rs (`[agent.thinking]`)
- Added /think:<level> to interactive /help output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: correct base_system_prompt variable name in thinking-level restore

The rebase conflict resolution doubled the `base_` prefix.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: rareba <rareba@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant