picoclaw/pkg/agent
Larry Koo 204038ec60
feat: add extended thinking support for Anthropic models (#1076)
* feat: add extended thinking support for Anthropic models

Support configurable thinking levels (off/low/medium/high/xhigh/adaptive)
via `agents.defaults.thinking_level` config field.

- "adaptive": uses Anthropic's adaptive thinking API (Claude 4.6+)
- "low/medium/high/xhigh": uses budget_tokens (all thinking-capable models)
- "off": disables thinking (default)

API constraints handled:
- Temperature cleared when thinking is enabled
- budget_tokens clamped to max_tokens-1
- Thinking response blocks parsed into Reasoning field

Relates to #645, #966

* fix: address PR review feedback for thinking support

- Add ThinkingCapable interface for provider capability detection
- Warn when thinking_level is set but provider doesn't support it
- Warn when temperature is cleared due to thinking enabled
- Adjust budget values per Anthropic best practices (medium=16K, xhigh=64K)
- Add budget clamp warning and 80% threshold warning
- Add parseResponse thinking block tests
- Add thinking_level field to config.example.json

* refactor: move ThinkingLevel from AgentDefaults to ModelConfig

Thinking is a model-level capability, not a global agent property.
Per-model config avoids silent ignoring on non-Anthropic providers
and eliminates spurious warning logs in multi-provider setups.

Addresses PR #1076 review feedback from @yinwm.
2026-03-05 09:51:18 +08:00
..
context.go Merge pull request #1020 from shikihane/feat/agent-vision-pipeline-v2 2026-03-03 18:35:23 +08:00
context_cache_test.go fix(agent): invalidate system prompt cache for global/builtin skills (#845) 2026-03-03 18:25:00 +08:00
context_test.go fix: handle multi-tool-call orphan detection in sanitizeHistoryForProvider 2026-02-24 21:35:15 +08:00
instance.go feat: add extended thinking support for Anthropic models (#1076) 2026-03-05 09:51:18 +08:00
instance_test.go enable dupl check 2026-03-01 18:17:32 +11:00
loop.go feat: add extended thinking support for Anthropic models (#1076) 2026-03-05 09:51:18 +08:00
loop_media.go fix: resolve linter issues (gci import grouping, gofumpt, govet shadow) 2026-03-03 17:04:54 +08:00
loop_test.go fix: resolve linter issues (gci import grouping, gofumpt, govet shadow) 2026-03-03 17:04:54 +08:00
memory.go refactor(modernize): apply safe modernize fixes 2026-02-27 16:35:07 +08:00
mock_provider_test.go feat(fmt): Fix formatting 2026-02-19 22:05:15 +02:00
registry.go feat(fmt): Run formatters 2026-02-18 21:48:23 +02:00
registry_test.go feat(fmt): Run formatters 2026-02-18 21:48:23 +02:00
thinking.go feat: add extended thinking support for Anthropic models (#1076) 2026-03-05 09:51:18 +08:00
thinking_test.go feat: add extended thinking support for Anthropic models (#1076) 2026-03-05 09:51:18 +08:00