Skip to content

feat: runtime thinking config switching across REPL, ACP, and HTTP - #564

Merged
delete-cloud merged 3 commits into
mainfrom
feat/runtime-thinking-config
Jun 10, 2026
Merged

delete-cloud merged 3 commits into
mainfrom
feat/runtime-thinking-config

Conversation

@delete-cloud

@delete-cloud delete-cloud commented Jun 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

Store thinking/reasoning configuration as a mutable dict reference in ctx.config, read per-turn by providers without requiring pipeline rebuild. This means /thinking changes take effect on the very next turn with zero rebuilding overhead — thinking is not structurally tied to provider/model identity.

Problem

Previously:

  • REPL /thinking only controlled UI visibility of thinking chunks (RichConsumer callbacks); it never reached the provider API call
  • AnthropicProvider accepted thinking: dict at construction time but LLMProviderPlugin never passed it
  • OpenAICompatProvider had no reasoning_effort entry point
  • ACP and HTTP had zero thinking configuration
  • No way to toggle extended thinking / reasoning effort at runtime

Solution

Single mutable dict {"enabled": bool, "effort": str} shared across all layers:

ctx.config["thinking_config"]  ← session.thinking_config (same dict ref)
         │
    provider.stream(thinking_config=...)
         │
  ┌──────┼──────┐
  ▼      ▼      ▼
Anthropic  OpenAI  Codex
budget    effort  ignore

Per-provider translation

Provider enabled=True → API parameter
Anthropic effort→{"low": 4k, "medium": 16k, "high": 32k} thinking: {type, budget_tokens}
OpenAI compat effort passed directly reasoning_effort
Codex/DeepSeek model-controlled not applicable

Why no rebuild

thinking is a per-turn flag, not a structural runtime property. The dict reference pattern means changing thinking doesn't require full pipeline reconstruction — it's immediately visible to the provider on the next stream() call. This is consistent with how RichConsumer already used mutable callbacks for the same state.

Changes

11 files, +158/-40 lines

  • providers/anthropic.py — stream() reads thinking_config from kwargs
  • providers/openai_compat.py — stream() reads thinking_config, sets reasoning_effort
  • pipeline.py — passes ctx.config["thinking_config"] to provider.stream()
  • session_manager.py — Session gains mutable thinking_config dict field
  • runtime_preparation.py — wires session.thinking_config into ctx.config
  • commands.py — /thinking uses single dict, writes to shared reference
  • repl.py — context["thinking_config"] shared with pipeline ctx
  • schemas.py — ThinkingConfigSchema, RuntimeConfigUpdateRequest.thinking
  • http_server.py — PATCH applies thinking, thinking-only skips rebuild
  • acp/server.py — AcpMode.thinking, set_mode applies it
  • acp_command.py — parse thinking shorthand in --acp-mode

Verification

  • 13-layer static+dynamic verification script: all passed
  • 118 regression tests: 0 failures
  • Effort→budget_tokens mapping verified per-level

Usage

REPL:

/thinking effort high   # enable extended thinking, high depth
/thinking off           # disable
/thinking               # show current state

HTTP:

# Thinking only — no rebuild
curl -X PATCH /sessions/{id}/runtime-config \
  -H "Content-Type: application/json" \
  -d '{"thinking": {"enabled": true, "effort": "high"}}'

ACP:

--acp-mode 'deep:DeepThink:anthropic:claude-sonnet-4-6::on:high' \
--acp-mode 'fast:Fast:deepseek:deepseek-chat::off'

🤖 Generated with Claude Code
Co-Authored-By: Claude Fable 5 noreply@anthropic.com

Summary by CodeRabbit

  • New Features

    • AI thinking and reasoning configuration now supported across CLI, API, and mode-switching interfaces.
    • Users can enable/disable thinking and adjust effort levels (low, medium, high).
    • Settings persist and update seamlessly without requiring pipeline rebuilds.
  • Documentation

    • Updated agent working rules to require explicit decision transparency at each decision point.

delete-cloud and others added 2 commits June 11, 2026 04:56
Store thinking/reasoning configuration as a mutable dict reference
in ctx.config, read per-turn by providers without requiring pipeline
rebuild. This means /thinking changes take effect on the very next
turn with zero rebuilding overhead.

Core architecture:
- ctx.config['thinking_config'] holds {'enabled': bool, 'effort': str}
- This dict is a shared mutable reference: REPL context, session
  config, and pipeline ctx all reference the same object
- Providers read thinking_config from stream() kwargs each turn
- No RuntimeReplacementService rebuild needed for thinking-only changes

Per-provider translation:
- Anthropic: effort -> budget_tokens (low=4k, medium=16k, high=32k)
- OpenAI compat: effort -> reasoning_effort parameter
- Codex/DeepSeek: ignore (model-controlled reasoning)

REPL:
- /thinking on|off controls enabled flag
- /thinking effort low|medium|high sets model reasoning depth
- /thinking with no args displays current state
- Backward compatible: context dict structure unified

HTTP:
- PATCH /sessions/{id}/runtime-config accepts 'thinking' field
- Thinking-only changes skip pipeline rebuild (fast path)
- Schema: ThinkingConfigSchema {enabled: bool, effort: str}

ACP:
- AcpMode gains optional 'thinking' field
- CLI shorthand: --acp-mode 'id:name:provider:model::on:high'
- session/set_mode applies thinking directly to session dict

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Require explicit output of decisions and rationale at every decision
point before proceeding — choosing approaches, trade-offs, design
patterns, scope deferrals, or ambiguous requirements.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d118350d-6b27-4340-9b6e-26e2d774ee08

📥 Commits

Reviewing files that changed from the base of the PR and between 453dfcb and 2a36c11.

📒 Files selected for processing (12)
  • coding-agent/AGENTS.md
  • coding-agent/src/agentkit/runtime/pipeline.py
  • coding-agent/src/coding_agent/acp/server.py
  • coding-agent/src/coding_agent/cli/acp_command.py
  • coding-agent/src/coding_agent/cli/commands.py
  • coding-agent/src/coding_agent/cli/repl.py
  • coding-agent/src/coding_agent/providers/anthropic.py
  • coding-agent/src/coding_agent/providers/openai_compat.py
  • coding-agent/src/coding_agent/runs/runtime_preparation.py
  • coding-agent/src/coding_agent/server/http_server.py
  • coding-agent/src/coding_agent/server/schemas.py
  • coding-agent/src/coding_agent/server/session_manager.py

📝 Walkthrough

Walkthrough

This PR adds thinking configuration throughout the system, enabling users to control reasoning behavior via session modes, CLI commands, and HTTP APIs. The configuration flows from session storage through runtime context and pipeline into provider implementations, with support for per-call overrides mapping effort levels to provider-specific parameters.

Changes

Thinking Configuration System

Layer / File(s) Summary
Data model and schema definitions
coding-agent/src/coding_agent/server/session_manager.py, coding-agent/src/coding_agent/server/schemas.py
Session gains thinking_config field with {"enabled": True, "effort": "medium"} default; new ThinkingConfigSchema validates enabled boolean and effort in {low, medium, high}; RuntimeConfigUpdateRequest extended with optional thinking field.
Runtime context flow and pipeline wiring
coding-agent/src/coding_agent/runs/runtime_preparation.py, coding-agent/src/agentkit/runtime/pipeline.py, coding-agent/src/coding_agent/cli/repl.py
LocalDaemonRuntimePreparationService initializes ctx.config["thinking_config"] from session; Pipeline._stage_run_model passes thinking_config to ctx.llm_provider.stream(); REPL maintains thinking_config in session context and wires it into pipeline context during agent setup and on session/model changes.
Provider thinking implementations
coding-agent/src/coding_agent/providers/anthropic.py, coding-agent/src/coding_agent/providers/openai_compat.py
AnthropicProvider.stream extracts per-call thinking_config, maps effort to budget_tokens, and sets api_kwargs["thinking"]; OpenAICompatProvider.stream similarly extracts config and maps effort to reasoning_effort parameter.
CLI and mode parsing for thinking configuration
coding-agent/src/coding_agent/cli/acp_command.py, coding-agent/src/coding_agent/cli/commands.py, coding-agent/src/coding_agent/acp/server.py
--acp-mode parsing recognizes thinking enable/disable tokens and parses effort level into AcpMode.thinking dict; /thinking command stores/reads consolidated thinking_config from context with on/off and effort <level> subcommands; AcpMode dataclass includes optional thinking field applied by _session_set_mode without triggering full runtime rebuild.
HTTP runtime-config endpoint thinking updates
coding-agent/src/coding_agent/server/http_server.py
/sessions/{session_id}/runtime-config endpoint supports thinking-only updates: when only thinking is provided, endpoint mutates session.thinking_config directly without rebuilding session runtime; validates that at least one of model, provider, base_url, or thinking is supplied.
Agent decision transparency policy
coding-agent/AGENTS.md
Repository-wide working rule added requiring explicit decision output and rationale at every decision point before proceeding.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • delete-cloud/Coding-Agent-Loop#134: Introduces DeepSeek provider work that disables Anthropic "thinking" via construction-time configuration, which intersects with this PR's per-call thinking_config handling in AnthropicProvider.

Poem

🐰 A thinking config flows through every layer,
From session state to provider care,
With effort levels mapped just right,
The agent reasons with new delight!
CLI commands flip the switch with ease,
While APIs update with certainty. ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/runtime-thinking-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Avoid redundant second fetch of the session object when applying
thinking config. The first call on line 461 now captures the return
value, used by both the thinking update and the runtime change path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@delete-cloud
delete-cloud marked this pull request as ready for review June 10, 2026 20:59
@delete-cloud
delete-cloud merged commit 25b5f60 into main Jun 10, 2026
1 check was pending
@delete-cloud
delete-cloud deleted the feat/runtime-thinking-config branch June 10, 2026 21:00
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