feat(worker): expose max-turns override over signalr and mcp config tools
This commit is contained in:
18
src/ClaudeDo.Worker/External/ConfigMcpTools.cs
vendored
18
src/ClaudeDo.Worker/External/ConfigMcpTools.cs
vendored
@@ -6,7 +6,7 @@ using ModelContextProtocol.Server;
|
||||
|
||||
namespace ClaudeDo.Worker.External;
|
||||
|
||||
public sealed record TaskConfigDto(string? Model, string? SystemPrompt, string? AgentPath);
|
||||
public sealed record TaskConfigDto(string? Model, string? SystemPrompt, string? AgentPath, int? MaxTurns);
|
||||
|
||||
[McpServerToolType]
|
||||
public sealed class ConfigMcpTools
|
||||
@@ -26,12 +26,12 @@ public sealed class ConfigMcpTools
|
||||
public async Task<TaskConfigDto?> GetListConfig(string listId, CancellationToken cancellationToken)
|
||||
{
|
||||
var cfg = await _lists.GetConfigAsync(listId, cancellationToken);
|
||||
return cfg is null ? null : new TaskConfigDto(cfg.Model, cfg.SystemPrompt, cfg.AgentPath);
|
||||
return cfg is null ? null : new TaskConfigDto(cfg.Model, cfg.SystemPrompt, cfg.AgentPath, cfg.MaxTurns);
|
||||
}
|
||||
|
||||
[McpServerTool, Description("Set a list's default model/system prompt/agent path. Passing all three as null clears the list config.")]
|
||||
[McpServerTool, Description("Set a list's default model/system prompt/agent path/max turns. Passing all four as null clears the list config.")]
|
||||
public async Task SetListConfig(
|
||||
string listId, string? model, string? systemPrompt, string? agentPath, CancellationToken cancellationToken)
|
||||
string listId, string? model, string? systemPrompt, string? agentPath, int? maxTurns, CancellationToken cancellationToken)
|
||||
{
|
||||
_ = await _lists.GetByIdAsync(listId, cancellationToken)
|
||||
?? throw new InvalidOperationException($"List {listId} not found.");
|
||||
@@ -40,25 +40,25 @@ public sealed class ConfigMcpTools
|
||||
var sp = systemPrompt.NullIfBlank();
|
||||
var ap = agentPath.NullIfBlank();
|
||||
|
||||
if (m is null && sp is null && ap is null)
|
||||
if (m is null && sp is null && ap is null && maxTurns is null)
|
||||
await _lists.DeleteConfigAsync(listId, cancellationToken);
|
||||
else
|
||||
await _lists.SetConfigAsync(new ListConfigEntity
|
||||
{
|
||||
ListId = listId, Model = m, SystemPrompt = sp, AgentPath = ap,
|
||||
ListId = listId, Model = m, SystemPrompt = sp, AgentPath = ap, MaxTurns = maxTurns,
|
||||
}, cancellationToken);
|
||||
|
||||
await _broadcaster.ListUpdated(listId);
|
||||
}
|
||||
|
||||
[McpServerTool, Description("Set per-task config overrides (model/system prompt/agent path). Pass null for any field to clear that override.")]
|
||||
[McpServerTool, Description("Set per-task config overrides (model/system prompt/agent path/max turns). Pass null for any field to clear that override.")]
|
||||
public async Task SetTaskConfig(
|
||||
string taskId, string? model, string? systemPrompt, string? agentPath, CancellationToken cancellationToken)
|
||||
string taskId, string? model, string? systemPrompt, string? agentPath, int? maxTurns, CancellationToken cancellationToken)
|
||||
{
|
||||
_ = await _tasks.GetByIdAsync(taskId, cancellationToken)
|
||||
?? throw new InvalidOperationException($"Task {taskId} not found.");
|
||||
|
||||
await _tasks.UpdateAgentSettingsAsync(taskId, model.NullIfBlank(), systemPrompt.NullIfBlank(), agentPath.NullIfBlank(), ct: cancellationToken);
|
||||
await _tasks.UpdateAgentSettingsAsync(taskId, model.NullIfBlank(), systemPrompt.NullIfBlank(), agentPath.NullIfBlank(), maxTurns, cancellationToken);
|
||||
await _broadcaster.TaskUpdated(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user