fix(mcp): stop set_list_config from clearing settings it doesn't expose

This commit is contained in:
mika kuns
2026-08-11 08:32:52 +02:00
parent d451edd367
commit f31b1b4fb2
2 changed files with 83 additions and 4 deletions
+17 -4
View File
@@ -75,7 +75,9 @@ public sealed class ConfigMcpTools
[McpServerTool, Description(
"Set a list's default model/system prompt/agent path/max turns — the fallback for tasks in this list " +
"that don't override them. Only the fields you pass are changed; omitted fields keep their current " +
"value. To clear a field instead, name it in clearFields; clearing all four deletes the list's config.")]
"value. To clear a field instead, name it in clearFields; clearing all four deletes the list's config " +
"unless it also carries settings this tool doesn't expose (session skills, verify command, file-scope " +
"serialization), which are always preserved.")]
public async Task<SetListConfigResult> SetListConfig(
string listId, string? model = null, string? systemPrompt = null, string? agentPath = null,
int? maxTurns = null,
@@ -95,13 +97,23 @@ public sealed class ConfigMcpTools
var ap = clear.Contains("agentPath") ? null : agentPath.NullIfBlank() ?? existing?.AgentPath;
var mt = clear.Contains("maxTurns") ? null : maxTurns ?? existing?.MaxTurns;
// Fields this tool doesn't expose but that live on the same row. They must survive every
// write here — ListRepository.SetConfigAsync copies the entity verbatim, so anything left
// at its default would silently reset (SerializeOnFileOverlap in particular has no UI
// affordance at all, so a reset is invisible until tasks stop serializing).
var hasUnrelatedSettings = existing is not null
&& (existing.SessionSkills is not null
|| existing.VerifyCommand is not null
|| existing.SerializeOnFileOverlap);
TaskConfigDto? config;
if (m is null && sp is null && ap is null && mt is null && clear.Count > 0)
var allCleared = m is null && sp is null && ap is null && mt is null;
if (allCleared && clear.Count > 0 && !hasUnrelatedSettings)
{
await _lists.DeleteConfigAsync(listId, cancellationToken);
config = null;
}
else if (m is null && sp is null && ap is null && mt is null && existing is null)
else if (allCleared && existing is null)
{
config = null;
}
@@ -111,8 +123,9 @@ public sealed class ConfigMcpTools
{
ListId = listId, Model = m, SystemPrompt = sp, AgentPath = ap, MaxTurns = mt,
SessionSkills = existing?.SessionSkills, VerifyCommand = existing?.VerifyCommand,
SerializeOnFileOverlap = existing?.SerializeOnFileOverlap ?? false,
}, cancellationToken);
config = new TaskConfigDto(m, sp, ap, mt);
config = allCleared ? null : new TaskConfigDto(m, sp, ap, mt);
}
await _broadcaster.ListUpdated(listId);