Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ During TUI sessions, you can use special slash commands. Type `/` to see all ava
| `/sessions` | Browse and load past sessions |
| `/shell` | Start a shell |
| `/star` | Toggle star on current session |
| `/think` | Toggle thinking/reasoning mode |
| `/yolo` | Toggle automatic approval of tool calls |

#### Runtime Model Switching
Expand Down
1 change: 1 addition & 0 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ type SessionResponse struct {
Messages []session.Message `json:"messages,omitempty"`
CreatedAt time.Time `json:"created_at"`
ToolsApproved bool `json:"tools_approved"`
Thinking bool `json:"thinking"`
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
WorkingDir string `json:"working_dir,omitempty"`
Expand Down
32 changes: 19 additions & 13 deletions pkg/model/provider/anthropic/beta_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,27 @@ func (c *Client) createBetaStream(
params.OutputFormat = anthropic.BetaJSONSchemaOutputFormat(structuredOutput.Schema)
}

// Configure thinking if not explicitly disabled via /think command
// For interleaved thinking to make sense, we use a default of 16384 tokens for the thinking budget
thinkingTokens := int64(16384)
if c.ModelConfig.ThinkingBudget != nil {
thinkingTokens = int64(c.ModelConfig.ThinkingBudget.Tokens)
thinkingEnabled := c.ModelOptions.Thinking() == nil || *c.ModelOptions.Thinking()
if thinkingEnabled {
thinkingTokens := int64(16384)
if c.ModelConfig.ThinkingBudget != nil {
thinkingTokens = int64(c.ModelConfig.ThinkingBudget.Tokens)
} else {
slog.Info("Anthropic Beta API using default thinking_budget with interleaved thinking", "budget_tokens", thinkingTokens)
}
switch {
case thinkingTokens >= 1024 && thinkingTokens < maxTokens:
params.Thinking = anthropic.BetaThinkingConfigParamOfEnabled(thinkingTokens)
slog.Debug("Anthropic Beta API using thinking_budget with interleaved thinking", "budget_tokens", thinkingTokens)
case thinkingTokens >= maxTokens:
slog.Warn("Anthropic Beta API thinking_budget must be less than max_tokens, ignoring", "tokens", thinkingTokens, "max_tokens", maxTokens)
default:
slog.Warn("Anthropic Beta API thinking_budget below minimum (1024), ignoring", "tokens", thinkingTokens)
}
} else {
slog.Info("Anthropic Beta API using default thinking_budget with interleaved thinking", "budget_tokens", thinkingTokens)
}
switch {
case thinkingTokens >= 1024 && thinkingTokens < maxTokens:
params.Thinking = anthropic.BetaThinkingConfigParamOfEnabled(thinkingTokens)
slog.Debug("Anthropic Beta API using thinking_budget with interleaved thinking", "budget_tokens", thinkingTokens)
case thinkingTokens >= maxTokens:
slog.Warn("Anthropic Beta API thinking_budget must be less than max_tokens, ignoring", "tokens", thinkingTokens, "max_tokens", maxTokens)
default:
slog.Warn("Anthropic Beta API thinking_budget below minimum (1024), ignoring", "tokens", thinkingTokens)
slog.Debug("Anthropic Beta API: Thinking disabled via /think command")
}

if len(requestTools) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/provider/bedrock/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ func TestBuildInferenceConfig_DisablesTempTopPWhenThinkingEnabled(t *testing.T)
assert.Equal(t, int32(64000), *cfg.MaxTokens)
}

func TestBuildInferenceConfig_SetsTempTopPWhenThinkingDisabled(t *testing.T) {
func TestBuildInferenceConfig_SetsTempTopPWhenThinkingNotConfigured(t *testing.T) {
t.Parallel()

temp := 0.7
Expand Down
4 changes: 3 additions & 1 deletion pkg/model/provider/openai/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ func (c *Client) CreateResponseStream(

// Configure reasoning for models that support it (o-series, gpt-5)
// Request detailed reasoning summary to get thinking traces for reasoning models
if isOpenAIReasoningModel(c.ModelConfig.Model) {
// Skip reasoning configuration entirely if thinking is explicitly disabled (via /think command)
thinkingEnabled := c.ModelOptions.Thinking() == nil || *c.ModelOptions.Thinking()
if isOpenAIReasoningModel(c.ModelConfig.Model) && thinkingEnabled {
params.Reasoning = shared.ReasoningParam{
Summary: shared.ReasoningSummaryDetailed,
}
Expand Down
Loading