From 8a995c1b131e780e78aedf030e3fa06969eb70b2 Mon Sep 17 00:00:00 2001 From: ollie Date: Sat, 18 Jul 2026 17:05:48 +0200 Subject: [PATCH] route: use numbered classification for reliability Ask classifier to reply with 1 or 2 instead of full model names. Previous approach produced garbled partial names. --- pkg/backend/oneshot.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pkg/backend/oneshot.go b/pkg/backend/oneshot.go index 796dfb7..f295438 100644 --- a/pkg/backend/oneshot.go +++ b/pkg/backend/oneshot.go @@ -101,15 +101,14 @@ func Route(ctx context.Context, req RouteRequest) (RouteResult, error) { powerModel = "anthropic/claude-sonnet-4-20250514" } - classifyPrompt := fmt.Sprintf(`You are a task router. Given a task description, select the most appropriate model. + classifyPrompt := fmt.Sprintf(`You are a task router. Given a task, reply with ONLY the number 1 or 2. -Available models: -1. %s \u2014 fast, cheap, good for: simple edits, single-file changes, straightforward bugs, docs, tests, standard API usage -2. %s \u2014 powerful, expensive, good for: multi-file architecture, security-sensitive code, complex algorithms, system design, subtle debugging, performance optimization +1 = fast/cheap model, good for: simple edits, single-file changes, straightforward bugs, docs, tests, standard API usage +2 = powerful/expensive model, good for: multi-file architecture, security-sensitive code, complex algorithms, system design, subtle debugging, performance optimization -Reply with ONLY the model name, nothing else. +Reply with ONLY the digit 1 or 2. Nothing else. -Task: %s`, fastModel, powerModel, req.Task) +Task: %s`, req.Task) msgs := []Message{ {Role: "user", Content: classifyPrompt}, @@ -124,9 +123,9 @@ Task: %s`, fastModel, powerModel, req.Task) } result := strings.TrimSpace(sb.String()) - // Match result to one of the configured models + // Match: if the response contains "2", pick the powerful model model := fastModel - if strings.Contains(result, powerModel) { + if strings.Contains(result, "2") { model = powerModel }