feat(worker): accept #123 task numbers as MCP tool input

TaskIdResolver resolves a #123/bare-123 taskId parameter to its GUID
before any lookup, across every External/ MCP tool that takes a task
id, including the batch tools' id arrays (via delegation to the
already-resolving single-entity methods) and update_task's
dependsOnTaskId (empty string still passes through unchanged as the
clear-link sentinel). An unknown number throws a clear error instead
of a silent null. McpToolDocs.TaskNumberHint tells the agent to refer
to tasks as #<number> when reporting to the user, added to the
description of get_task, list_tasks, add_task, update_task_status and
review_task.
This commit is contained in:
mika kuns
2026-08-11 13:10:49 +02:00
parent 9660a29da4
commit 2a3133efad
14 changed files with 298 additions and 7 deletions
+8 -1
View File
@@ -21,8 +21,13 @@ public sealed record TaskLogResult(
public sealed class RunHistoryMcpTools
{
private readonly TaskRunRepository _runs;
private readonly TaskRepository _tasks;
public RunHistoryMcpTools(TaskRunRepository runs) => _runs = runs;
public RunHistoryMcpTools(TaskRunRepository runs, TaskRepository tasks)
{
_runs = runs;
_tasks = tasks;
}
[McpServerTool, Description(
"List all execution runs for a task — metadata, tokens, turns, result, and error per run — ordered " +
@@ -30,6 +35,7 @@ public sealed class RunHistoryMcpTools
"get_run to fetch it individually.")]
public async Task<IReadOnlyList<RunDto>> ListRuns(string taskId, CancellationToken cancellationToken)
{
taskId = await TaskIdResolver.ResolveAsync(_tasks, taskId, cancellationToken);
var runs = await _runs.GetByTaskIdAsync(taskId, cancellationToken);
return runs.Select(ToDto).ToList();
}
@@ -56,6 +62,7 @@ public sealed class RunHistoryMcpTools
int? limit = null,
CancellationToken cancellationToken = default)
{
taskId = await TaskIdResolver.ResolveAsync(_tasks, taskId, cancellationToken);
var run = await _runs.GetLatestByTaskIdAsync(taskId, cancellationToken);
if (run is null || string.IsNullOrWhiteSpace(run.LogPath) || !File.Exists(run.LogPath))
return new TaskLogResult(false, [], 0, false);