From b84f98a2cccc6c2027df903a045662057c7f72c9 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Sun, 16 Aug 2026 08:20:57 +0300 Subject: [PATCH] improved compacting algo and token visibility --- main.go | 18 +++++++++++++----- model.cfg | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 498e302..db9a1a3 100644 --- a/main.go +++ b/main.go @@ -727,7 +727,7 @@ func llm(ctx context.Context, cfg *Cfg, msgs []Message, tools []map[string]any) if cfg.Stream { p["stream_options"] = map[string]any{"include_usage": true} } for k, v := range cfg.Raw { switch k { - case "endpoint", "api_key", "timeout", "shell_timeout", "max_al_iterations", "color", "context_window": + case "endpoint", "model", "temperature", "stream", "api_key", "timeout", "shell_timeout", "max_al_iterations", "color", "context_window": continue default: var jv any @@ -1409,9 +1409,10 @@ func main() { sigCtx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) var usg Usage msgs, usg, err = AL(sigCtx, &cfg, msgs, sp, 0) + interrupted := sigCtx.Err() != nil cancel() if err != nil { - if errors.Is(err, context.Canceled) || sigCtx.Err() != nil { + if interrupted || errors.Is(err, context.Canceled) { fmt.Println(c("\n[interrupted]", 33)) } else { fmt.Println(c("[error: "+err.Error()+"]", 31)) @@ -1481,9 +1482,10 @@ func main() { fmt.Println(c("[compacting conversation...]", 33)) sigCtx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) nm, sm, err := compact(sigCtx, &cfg, msgs) + interrupted := sigCtx.Err() != nil cancel() if err != nil { - if errors.Is(err, context.Canceled) || sigCtx.Err() != nil { + if interrupted || errors.Is(err, context.Canceled) { fmt.Println(c("\n[interrupted]", 33)) } else { fmt.Println(c("[compact failed: "+err.Error()+"]", 31)) @@ -1542,9 +1544,10 @@ func main() { turnMsgs = append(turnMsgs, Message{Role: "user", Content: strp(u)}) sigCtx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) resMsgs, usg, err := AL(sigCtx, &cfg, turnMsgs, sp, 0) + interrupted := sigCtx.Err() != nil cancel() if err != nil { - if errors.Is(err, context.Canceled) || sigCtx.Err() != nil { + if interrupted || errors.Is(err, context.Canceled) { fmt.Println(c("\n[interrupted]", 33)) } else { fmt.Println(c("[error: "+err.Error()+"]", 31)) @@ -1564,9 +1567,14 @@ func main() { fmt.Println(c("[compacting conversation...]", 33)) sigCtx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) nm, sm, err := compact(sigCtx, &cfg, msgs) + interrupted := sigCtx.Err() != nil cancel() if err != nil { - fmt.Println(c("[compact failed: "+err.Error()+"]", 31)) + if interrupted || errors.Is(err, context.Canceled) { + fmt.Println(c("\n[interrupted]", 33)) + } else { + fmt.Println(c("[compact failed: "+err.Error()+"]", 31)) + } } else { msgs = nm autosave(msgs) diff --git a/model.cfg b/model.cfg index 17283cb..519dead 100644 --- a/model.cfg +++ b/model.cfg @@ -1,5 +1,5 @@ endpoint=https://opencode.ai/zen/v1 -model=big-pickle +model=hy3-free temperature=0.7 api_key=- stream=true