Skip to content

Add reasoning/thinking support for OpenAI and Anthropic providers#24

Open
freddiev4 wants to merge 2 commits into
mainfrom
claude/add-reasoning-support-UTrhu
Open

Add reasoning/thinking support for OpenAI and Anthropic providers#24
freddiev4 wants to merge 2 commits into
mainfrom
claude/add-reasoning-support-UTrhu

Conversation

@freddiev4
Copy link
Copy Markdown
Owner

  • Add ReasoningConfig dataclass (effort for OpenAI, budget_tokens for Anthropic)
  • OpenAI: detect o-series models (o1/o3/o4-mini) and use reasoning_effort
    instead of temperature; skip tool_choice for compatibility
  • Anthropic: enable extended thinking via thinking param with forced
    temperature=1 (API requirement); normalise thinking/redacted_thinking
    content blocks and carry them through in ChatMessage.thinking
  • Session: store thinking_blocks on assistant Message so they are
    round-tripped verbatim in subsequent turns (Anthropic requirement)
  • AgentConfig: add reasoning: ReasoningConfig | None field threaded
    through to _call_model()
  • Export ReasoningConfig from the public rune package

https://claude.ai/code/session_01Bv6PGmH4CY6hjYEmYpAs8i

claude added 2 commits March 24, 2026 18:15
- Add `ReasoningConfig` dataclass (effort for OpenAI, budget_tokens for Anthropic)
- OpenAI: detect o-series models (o1/o3/o4-mini) and use `reasoning_effort`
  instead of temperature; skip `tool_choice` for compatibility
- Anthropic: enable extended thinking via `thinking` param with forced
  temperature=1 (API requirement); normalise `thinking`/`redacted_thinking`
  content blocks and carry them through in `ChatMessage.thinking`
- Session: store `thinking_blocks` on assistant `Message` so they are
  round-tripped verbatim in subsequent turns (Anthropic requirement)
- `AgentConfig`: add `reasoning: ReasoningConfig | None` field threaded
  through to `_call_model()`
- Export `ReasoningConfig` from the public `rune` package

https://claude.ai/code/session_01Bv6PGmH4CY6hjYEmYpAs8i
62 tests covering:
- parse_model_string and ReasoningConfig dataclass
- OpenAI o-series model detection (base names and date-suffixed variants)
- OpenAI chat(): reasoning_effort routing, temperature/tool_choice omission
- Anthropic chat(): thinking param injection, forced temperature=1
- Anthropic _normalise(): thinking/redacted_thinking block extraction and
  round-trip storage via _thinking_blocks attribute
- Anthropic _convert_messages(): thinking block replay in assistant turns
- create_provider factory routing
- Message.thinking_blocks field and to_api_format() serialisation
- Session.add_assistant_message() with thinking_blocks
- Session save/load round-trip including thinking_blocks
- Backward-compatible load for sessions without thinking_blocks

https://claude.ai/code/session_01Bv6PGmH4CY6hjYEmYpAs8i
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