fix(worker): wire mcp config into resumed runs
TaskRunner.ContinueAsync resolved a ClaudeRunConfig but never attached a per-run MCP token/config or AllowedTools the way RunAsync does, so a --resume continuation (e.g. reject-rerun with feedback) lost every mcp__claudedo_run__* tool, including AskUser. Extracted the setup into SetupMcpConfigAsync and call it from both paths, with matching cleanup in ContinueAsync's finally block.
This commit is contained in:
@@ -92,6 +92,59 @@ public sealed class ContinueAsyncExceptionTests : IDisposable
|
||||
Assert.Equal(TaskStatus.Failed, task.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ContinueAsync_WiresMcpConfigAndAllowedTools_LikeAFreshRun()
|
||||
{
|
||||
string listId, taskId;
|
||||
|
||||
using (var ctx = _db.CreateContext())
|
||||
{
|
||||
listId = Guid.NewGuid().ToString();
|
||||
ctx.Lists.Add(new ListEntity { Id = listId, Name = "L", WorkingDir = null, CreatedAt = DateTime.UtcNow });
|
||||
|
||||
taskId = Guid.NewGuid().ToString();
|
||||
ctx.Tasks.Add(new TaskEntity
|
||||
{
|
||||
Id = taskId,
|
||||
ListId = listId,
|
||||
Title = "Continue me",
|
||||
Status = TaskStatus.WaitingForReview,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
});
|
||||
await ctx.SaveChangesAsync();
|
||||
|
||||
await new TaskRunRepository(ctx).AddAsync(new TaskRunEntity
|
||||
{
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
TaskId = taskId,
|
||||
RunNumber = 1,
|
||||
IsRetry = false,
|
||||
Prompt = "original prompt",
|
||||
SessionId = "sess-continue-mcp-test",
|
||||
StartedAt = DateTime.UtcNow.AddMinutes(-5),
|
||||
FinishedAt = DateTime.UtcNow.AddMinutes(-1),
|
||||
ExitCode = 0,
|
||||
ResultMarkdown = "first result",
|
||||
});
|
||||
}
|
||||
|
||||
IReadOnlyList<string>? capturedArgs = null;
|
||||
var claude = new FakeClaudeProcess((_, _, args, _, _) =>
|
||||
{
|
||||
capturedArgs = args;
|
||||
return Task.FromResult(new RunResult { ExitCode = 0, SessionId = "sess-continue-mcp-test", ResultMarkdown = "ok" });
|
||||
});
|
||||
|
||||
using var ctx2 = _db.CreateContext();
|
||||
var runner = BuildRunner(claude, ctx2);
|
||||
|
||||
await runner.ContinueAsync(taskId, "please continue", "slot-1", CancellationToken.None);
|
||||
|
||||
Assert.NotNull(capturedArgs);
|
||||
Assert.Contains("--mcp-config", capturedArgs!);
|
||||
Assert.Contains("--allowedTools", capturedArgs!);
|
||||
}
|
||||
|
||||
private sealed class ThrowingClaudeProcess : IClaudeProcess
|
||||
{
|
||||
private readonly Exception _ex;
|
||||
|
||||
Reference in New Issue
Block a user