feat(config): add context_window field to decouple input/output token limits
Adds a new `context_window` field to AgentDefaults that separates the context window (used for summarization threshold calculation) from max_tokens (used for output length limit). Changes: - pkg/config/config.go: Add ContextWindow field with JSON/env support - pkg/config/defaults.go: Set default to 131072 (128K) - pkg/agent/instance.go: Use context_window with fallback to max_tokens - config/config.example.json: Add example configuration - README.md, docs/docker.md, docs/providers.md: Update documentation Backward compatibility: If context_window is not set, it defaults to max_tokens. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6148ccc529
commit
d2294daa85
7 changed files with 17 additions and 3 deletions
|
|
@ -274,6 +274,7 @@ picoclaw onboard
|
|||
"workspace": "~/.picoclaw/workspace",
|
||||
"model_name": "gpt-5.4",
|
||||
"max_tokens": 8192,
|
||||
"context_window": 131072,
|
||||
"temperature": 0.7,
|
||||
"max_tool_iterations": 20
|
||||
}
|
||||
|
|
@ -1019,6 +1020,7 @@ picoclaw onboard
|
|||
"workspace": "~/.picoclaw/workspace",
|
||||
"model_name": "gpt-5.4",
|
||||
"max_tokens": 8192,
|
||||
"context_window": 131072,
|
||||
"temperature": 0.7,
|
||||
"max_tool_iterations": 20
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
"restrict_to_workspace": true,
|
||||
"model_name": "gpt-5.4",
|
||||
"max_tokens": 8192,
|
||||
"context_window": 131072,
|
||||
"temperature": 0.7,
|
||||
"max_tool_iterations": 20,
|
||||
"summarize_message_threshold": 20,
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ picoclaw onboard
|
|||
"workspace": "~/.picoclaw/workspace",
|
||||
"model_name": "gpt-5.4",
|
||||
"max_tokens": 8192,
|
||||
"context_window": 131072,
|
||||
"temperature": 0.7,
|
||||
"max_tool_iterations": 20
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,9 @@ This design also enables **multi-agent support** with flexible provider selectio
|
|||
],
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"model_name": "gpt-5.4"
|
||||
"model_name": "gpt-5.4",
|
||||
"max_tokens": 8192,
|
||||
"context_window": 131072
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,6 +130,12 @@ func NewAgentInstance(
|
|||
maxTokens = 8192
|
||||
}
|
||||
|
||||
// Resolve context window: use context_window if set, otherwise fall back to max_tokens
|
||||
contextWindow := defaults.ContextWindow
|
||||
if contextWindow == 0 {
|
||||
contextWindow = maxTokens
|
||||
}
|
||||
|
||||
temperature := 0.7
|
||||
if defaults.Temperature != nil {
|
||||
temperature = *defaults.Temperature
|
||||
|
|
@ -182,7 +188,7 @@ func NewAgentInstance(
|
|||
MaxTokens: maxTokens,
|
||||
Temperature: temperature,
|
||||
ThinkingLevel: thinkingLevel,
|
||||
ContextWindow: maxTokens,
|
||||
ContextWindow: contextWindow,
|
||||
SummarizeMessageThreshold: summarizeMessageThreshold,
|
||||
SummarizeTokenPercent: summarizeTokenPercent,
|
||||
Provider: provider,
|
||||
|
|
|
|||
|
|
@ -238,6 +238,7 @@ type AgentDefaults struct {
|
|||
ImageModel string `json:"image_model,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_IMAGE_MODEL"`
|
||||
ImageModelFallbacks []string `json:"image_model_fallbacks,omitempty"`
|
||||
MaxTokens int `json:"max_tokens" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_TOKENS"`
|
||||
ContextWindow int `json:"context_window" env:"PICOCLAW_AGENTS_DEFAULTS_CONTEXT_WINDOW"`
|
||||
Temperature *float64 `json:"temperature,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_TEMPERATURE"`
|
||||
MaxToolIterations int `json:"max_tool_iterations" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_TOOL_ITERATIONS"`
|
||||
SummarizeMessageThreshold int `json:"summarize_message_threshold" env:"PICOCLAW_AGENTS_DEFAULTS_SUMMARIZE_MESSAGE_THRESHOLD"`
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ func DefaultConfig() *Config {
|
|||
Provider: "",
|
||||
Model: "",
|
||||
MaxTokens: 32768,
|
||||
ContextWindow: 131072,
|
||||
Temperature: nil, // nil means use provider default
|
||||
MaxToolIterations: 50,
|
||||
SummarizeMessageThreshold: 20,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue