added auto-continue mechanics, updated default ctx to 262144 tokens
This commit is contained in:
@@ -67,7 +67,7 @@ var llmTransport = &http.Transport{
|
||||
DialContext: (&net.Dialer{Timeout: 300 * time.Second}).DialContext,
|
||||
}
|
||||
|
||||
var defCfg = Cfg{"https://opencode.ai/zen/v1", "big-pickle", "-", 0.7, 300, 120, 1000, true, "auto", 200000, nil}
|
||||
var defCfg = Cfg{"https://opencode.ai/zen/v1", "big-pickle", "-", 0.7, 300, 120, 1000, true, "auto", 262144, nil}
|
||||
|
||||
func atoiD(s string, d int) int {
|
||||
if v, e := strconv.Atoi(strings.TrimSpace(s)); e == nil {
|
||||
@@ -115,7 +115,7 @@ var cwCache = map[string]int{}
|
||||
|
||||
func fetchContextWindow(cfg *Cfg) int {
|
||||
// Only values discovered from the /models endpoint are cached, keyed by
|
||||
// endpoint+model. The context_window-override and 200000 default are derived
|
||||
// endpoint+model. The context_window-override and 262144 default are derived
|
||||
// per call from cfg so they never shadow each other across configs.
|
||||
key := cfg.Endpoint + "\x00" + cfg.Model
|
||||
cwCacheMu.Lock()
|
||||
@@ -131,9 +131,9 @@ func fetchContextWindow(cfg *Cfg) int {
|
||||
return cw
|
||||
}
|
||||
if v, ok := cfg.Raw["context_window"]; ok {
|
||||
return atoiD(v, 200000)
|
||||
return atoiD(v, 262144)
|
||||
}
|
||||
return 200000
|
||||
return 262144
|
||||
}
|
||||
|
||||
func getCfg(path string) Cfg {
|
||||
@@ -705,7 +705,7 @@ func estTokens(msgs []Message) int {
|
||||
}
|
||||
|
||||
func contextPct(u Usage, cw int) float64 {
|
||||
if cw <= 0 { cw = 200000 }
|
||||
if cw <= 0 { cw = 262144 }
|
||||
return float64(u.PromptTokens) * 100.0 / float64(cw)
|
||||
}
|
||||
|
||||
@@ -1087,7 +1087,17 @@ func AL(ctx context.Context, cfg *Cfg, msgs []Message, sp string, depth int) ([]
|
||||
}
|
||||
if m.Content != nil { fmt.Println(renderMD(*m.Content)) }
|
||||
}
|
||||
if len(m.ToolCalls) == 0 { done = true; break }
|
||||
if len(m.ToolCalls) == 0 {
|
||||
// If the model returned only a reasoning block with no non-reasoning
|
||||
// tokens or tool calls, nudge it to continue rather than ending the turn.
|
||||
if m.ReasoningContent != "" && (m.Content == nil || strings.TrimSpace(*m.Content) == "") {
|
||||
fmt.Println(c("[auto continue: response was reasoning-only]", 33))
|
||||
msgs = append(msgs, Message{Role: "user", Content: strp("continue")})
|
||||
continue
|
||||
}
|
||||
done = true
|
||||
break
|
||||
}
|
||||
for _, tc := range m.ToolCalls {
|
||||
if err := ctx.Err(); err != nil { return msgs, turnUsage, err }
|
||||
fn, astr := tc.Function.Name, filterText(tc.Function.Arguments)
|
||||
|
||||
Reference in New Issue
Block a user