From d05ca4732710dd9cef7fffd998a03615ad2cb58c Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sun, 30 Nov 2025 00:27:55 -0500 Subject: Add task complexity field and model selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All tests pass. Let me summarize the changes made: - Added `taskComplexity :: Maybe Int` field to the `Task` data type (1-5 - Updated SQL schema to include `complexity INTEGER` column - Updated `FromRow` and `ToRow` instances to handle the new field - Updated `tasksColumns` migration spec for automatic schema migration - Updated `saveTask` to include complexity in SQL INSERT - Updated `createTask` signature to accept `Maybe Int` for complexity - Added `--complexity=` option to the docopt help string - Added complexity parsing in `create` command (validates 1-5 range) - Added complexity parsing in `edit` command - Updated `modifyFn` in edit to handle complexity updates - Updated all unit tests to use new `createTask` signature with complexi - Added CLI tests for `--complexity` flag parsing - Added unit tests for complexity field storage and persistence - Updated `selectModel` to use `selectModelByComplexity` based on task c - Added `selectModelByComplexity :: Maybe Int -> Text` function with map - `Nothing` or 3-4 → `anthropic/claude-sonnet-4-20250514` (default) - 1-2 → `anthropic/claude-haiku` (trivial/low complexity) - 5 → `anthropic/claude-opus-4-20250514` (expert complexity) - Updated `createTask` calls to include `Nothing` for complexity Task-Id: t-141.5 --- Omni/Agent/Worker.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'Omni/Agent') diff --git a/Omni/Agent/Worker.hs b/Omni/Agent/Worker.hs index dafd0b2..aa7c5ab 100644 --- a/Omni/Agent/Worker.hs +++ b/Omni/Agent/Worker.hs @@ -465,10 +465,20 @@ buildRetryPrompt (Just ctx) = <> "- If there were merge conflicts, the conflicting files may have been modified by others\n" <> "- Review the current state of those files before making changes\n" --- | Select model based on task complexity --- Currently always uses claude-sonnet-4, but can be extended for model selection +-- | Select model based on task complexity (1-5 scale) +-- Uses OpenRouter model identifiers for Claude models selectModel :: TaskCore.Task -> Text -selectModel _ = "anthropic/claude-sonnet-4-20250514" +selectModel task = selectModelByComplexity (TaskCore.taskComplexity task) + +-- | Select model based on complexity level +selectModelByComplexity :: Maybe Int -> Text +selectModelByComplexity Nothing = "anthropic/claude-sonnet-4-20250514" +selectModelByComplexity (Just 1) = "anthropic/claude-haiku" +selectModelByComplexity (Just 2) = "anthropic/claude-haiku" +selectModelByComplexity (Just 3) = "anthropic/claude-sonnet-4-20250514" +selectModelByComplexity (Just 4) = "anthropic/claude-sonnet-4-20250514" +selectModelByComplexity (Just 5) = "anthropic/claude-opus-4-20250514" +selectModelByComplexity (Just _) = "anthropic/claude-sonnet-4-20250514" formatTask :: TaskCore.Task -> Text formatTask t = -- cgit v1.2.3