fix(worker): normalize model alias before preset lookup, wire DefaultMaxTurns as fallback
A full model id like claude-sonnet-4-6 in list_config.model never matched any ModelPresets row (only bare aliases did), so every run under it landed on the hardcoded 30-turn/DefaultLevel fallback instead of the sonnet preset row - this is what killed two autonomous tasks at the 30-turn limit. ModelRegistry.TryNormalizeAlias (non-throwing: exact match, then substring match against a full model id) lets ModelPresets.For resolve a full model id to its alias's preset row. For a model that still doesn't resolve, the hardcoded 30 is replaced by a caller-supplied fallbackMaxTurns, and TaskRunner now passes AppSettings.DefaultMaxTurns there - so that setting has a real effect instead of being dead, matching the direction already noted in docs/open.md.
This commit is contained in:
@@ -33,4 +33,28 @@ public class ModelRegistryTests
|
||||
{
|
||||
Assert.Equal(new[] { "haiku", "sonnet", "opus" }, ModelRegistry.ByCostAscending);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("sonnet", "sonnet")]
|
||||
[InlineData("OPUS", "opus")]
|
||||
[InlineData(" haiku ", "haiku")]
|
||||
[InlineData("claude-sonnet-4-6", "sonnet")]
|
||||
[InlineData("claude-opus-4-6", "opus")]
|
||||
[InlineData("claude-haiku-4-5-20251001", "haiku")]
|
||||
[InlineData("us.anthropic.claude-sonnet-4-6-v1:0", "sonnet")]
|
||||
public void TryNormalizeAlias_matches_aliases_and_full_model_ids(string input, string expected)
|
||||
{
|
||||
Assert.Equal(expected, ModelRegistry.TryNormalizeAlias(input));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData("gpt-4")]
|
||||
[InlineData("some-future-model")]
|
||||
public void TryNormalizeAlias_never_throws_and_returns_null_when_unrecognized(string? input)
|
||||
{
|
||||
Assert.Null(ModelRegistry.TryNormalizeAlias(input));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user