fix: separate ContextWindow from MaxTokens configuration
- Add ContextWindow field to AgentDefaults config - ContextWindow now defaults to 128K (most modern models support this) - Previously ContextWindow was incorrectly set to MaxTokens (output limit) - This fixes premature context compression for large-context models like GLM-5 (128K context) Fixes issue where: - GLM-5 with 128K context was limited to 65K (MaxTokens value) - Compression threshold was underestimated by 50% - Forced compression dropped 50% of history without summary
This commit is contained in:
parent
2c8416e658
commit
8ba784a736
2 changed files with 9 additions and 1 deletions
|
|
@ -82,6 +82,13 @@ func NewAgentInstance(
|
||||||
maxTokens = 8192
|
maxTokens = 8192
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContextWindow defaults to 128K if not specified (most modern models support this)
|
||||||
|
// For models with smaller context, users should configure this explicitly
|
||||||
|
contextWindow := defaults.ContextWindow
|
||||||
|
if contextWindow == 0 {
|
||||||
|
contextWindow = 128000
|
||||||
|
}
|
||||||
|
|
||||||
temperature := 0.7
|
temperature := 0.7
|
||||||
if defaults.Temperature != nil {
|
if defaults.Temperature != nil {
|
||||||
temperature = *defaults.Temperature
|
temperature = *defaults.Temperature
|
||||||
|
|
@ -103,7 +110,7 @@ func NewAgentInstance(
|
||||||
MaxIterations: maxIter,
|
MaxIterations: maxIter,
|
||||||
MaxTokens: maxTokens,
|
MaxTokens: maxTokens,
|
||||||
Temperature: temperature,
|
Temperature: temperature,
|
||||||
ContextWindow: maxTokens,
|
ContextWindow: contextWindow,
|
||||||
Provider: provider,
|
Provider: provider,
|
||||||
Sessions: sessionsManager,
|
Sessions: sessionsManager,
|
||||||
ContextBuilder: contextBuilder,
|
ContextBuilder: contextBuilder,
|
||||||
|
|
|
||||||
|
|
@ -177,6 +177,7 @@ type AgentDefaults struct {
|
||||||
ImageModel string `json:"image_model,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_IMAGE_MODEL"`
|
ImageModel string `json:"image_model,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_IMAGE_MODEL"`
|
||||||
ImageModelFallbacks []string `json:"image_model_fallbacks,omitempty"`
|
ImageModelFallbacks []string `json:"image_model_fallbacks,omitempty"`
|
||||||
MaxTokens int `json:"max_tokens" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_TOKENS"`
|
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"`
|
Temperature *float64 `json:"temperature,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_TEMPERATURE"`
|
||||||
MaxToolIterations int `json:"max_tool_iterations" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_TOOL_ITERATIONS"`
|
MaxToolIterations int `json:"max_tool_iterations" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_TOOL_ITERATIONS"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue