feat(worker): let Claude set the cheapest model per generated task via MCP

AddTask, planning CreateChildTask, and SuggestImprovement now accept an
optional alias-validated model (haiku/sonnet/opus; blank = inherit) so the
model is chosen at creation time instead of a follow-up set_task_config call.
The planning, system, and improvement prompts instruct Claude to pick the
cheapest capable model (haiku < sonnet < opus).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-06-09 22:22:17 +02:00
parent 1448794748
commit c27a179d2b
12 changed files with 181 additions and 18 deletions

View File

@@ -108,12 +108,35 @@ public sealed class PlanningMcpServiceTests : IDisposable
var parent = await SeedPlanningParentAsync();
var sut = BuildSut(parent.Id);
var result = await sut.CreateChildTask("My child", "desc", null, CancellationToken.None);
var result = await sut.CreateChildTask("My child", "desc", null, model: null, CancellationToken.None);
Assert.Equal("Idle", result.Status);
var child = await _tasks.GetByIdAsync(result.TaskId);
Assert.Equal("My child", child!.Title);
Assert.Equal(TaskStatus.Idle, child.Status);
Assert.Null(child.Model);
}
[Fact]
public async Task CreateChildTask_PersistsNormalizedModel()
{
var parent = await SeedPlanningParentAsync();
var sut = BuildSut(parent.Id);
var result = await sut.CreateChildTask("c", null, null, model: "Opus", CancellationToken.None);
var child = await _tasks.GetByIdAsync(result.TaskId);
Assert.Equal("opus", child!.Model);
}
[Fact]
public async Task CreateChildTask_RejectsUnknownModel()
{
var parent = await SeedPlanningParentAsync();
var sut = BuildSut(parent.Id);
await Assert.ThrowsAsync<ArgumentException>(
() => sut.CreateChildTask("c", null, null, model: "turbo", CancellationToken.None));
}
[Fact]
@@ -244,7 +267,7 @@ public sealed class PlanningMcpServiceTests : IDisposable
var parent = await SeedPlanningParentAsync();
var sut = BuildSut(parent.Id);
var result = await sut.CreateChildTask("c", null, null, CancellationToken.None);
var result = await sut.CreateChildTask("c", null, null, model: null, CancellationToken.None);
var ids = TaskUpdatedIds();
Assert.Contains(result.TaskId, ids);