Skip to content

Commit 270de0a

Browse files
committed
Don't enable thinking by default
This should be explicitly set on the model config Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
1 parent 91475fe commit 270de0a

10 files changed

Lines changed: 87 additions & 1189 deletions

File tree

cmd/root/run.go

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"log/slog"
88
"os"
99
"path/filepath"
10-
"strings"
1110

1211
"github.com/mattn/go-isatty"
1312
"github.com/spf13/cobra"
@@ -16,7 +15,6 @@ import (
1615
"github.com/docker/cagent/pkg/app"
1716
"github.com/docker/cagent/pkg/cli"
1817
"github.com/docker/cagent/pkg/config"
19-
"github.com/docker/cagent/pkg/config/latest"
2018
"github.com/docker/cagent/pkg/paths"
2119
"github.com/docker/cagent/pkg/runtime"
2220
"github.com/docker/cagent/pkg/session"
@@ -312,17 +310,14 @@ func (f *runExecFlags) createLocalRuntimeAndSession(ctx context.Context, loadRes
312310

313311
slog.Debug("Loaded existing session", "session_id", f.sessionID, "agent", f.agentName)
314312
} else {
315-
// Determine initial thinking state based on config version and user configuration.
316-
thinking := computeInitialThinking(loadResult, f.agentName)
317313
sess = session.New(
318314
session.WithMaxIterations(agent.MaxIterations()),
319315
session.WithToolsApproved(f.autoApprove),
320316
session.WithHideToolResults(f.hideToolResults),
321-
session.WithThinking(thinking),
322317
)
323318
// Session is stored lazily on first UpdateSession call (when content is added)
324319
// This avoids creating empty sessions in the database
325-
slog.Debug("Using local runtime", "agent", f.agentName, "thinking", thinking)
320+
slog.Debug("Using local runtime", "agent", f.agentName)
326321
}
327322

328323
return localRt, sess, nil
@@ -382,50 +377,3 @@ func (f *runExecFlags) handleRunMode(ctx context.Context, rt runtime.Runtime, se
382377

383378
return runTUI(ctx, rt, sess, opts...)
384379
}
385-
386-
// computeInitialThinking determines whether thinking should be enabled at session startup.
387-
// For v4+ configs: thinking is enabled by default (provider defaults will apply).
388-
// For v0-v3 configs: thinking is disabled unless the user explicitly configured thinking_budget
389-
// in their model config with an enabled value.
390-
func computeInitialThinking(loadResult *teamloader.LoadResult, agentName string) bool {
391-
// For v4 and newer (or unknown/empty version), default to thinking enabled
392-
if loadResult.ConfigVersion == "" || loadResult.ConfigVersion == latest.Version {
393-
return true
394-
}
395-
396-
// For older configs (v0-v3), check if user explicitly configured thinking_budget
397-
// Get the agent's default model reference
398-
modelRef := loadResult.AgentDefaultModels[agentName]
399-
if modelRef == "" {
400-
// No model reference - thinking disabled for old configs
401-
return false
402-
}
403-
404-
// If using multiple models (comma-separated), check only the first (primary) model
405-
if idx := strings.Index(modelRef, ","); idx != -1 {
406-
modelRef = modelRef[:idx]
407-
}
408-
409-
// Look up the raw model config (before provider defaults were applied)
410-
rawModelCfg, exists := loadResult.Models[modelRef]
411-
if !exists {
412-
// Inline model spec (e.g., "openai/gpt-4o") or not found - no explicit thinking config
413-
return false
414-
}
415-
416-
// Check if user explicitly set thinking_budget in their config
417-
if rawModelCfg.ThinkingBudget == nil {
418-
// Not set - disable thinking for old configs
419-
return false
420-
}
421-
422-
// User set thinking_budget - check if it's enabled (not "none" and not tokens=0)
423-
tb := rawModelCfg.ThinkingBudget
424-
if tb.Effort == "none" || (tb.Tokens == 0 && tb.Effort == "") {
425-
// Explicitly disabled
426-
return false
427-
}
428-
429-
// User explicitly enabled thinking
430-
return true
431-
}

cmd/root/run_test.go

Lines changed: 0 additions & 267 deletions
This file was deleted.

0 commit comments

Comments
 (0)