perf(worker): stop echoing task description from writing MCP tools
update_task, update_task_status, add_task, add_subtask, set_my_day, abort_merge, review_task, and their batch variants now return a lean TaskRefDto (id/listId/title/status/sortOrder/isMyDay) instead of the full TaskDto. Those tools were re-sending the caller's own description text back on every call, wasting a large share of session context on list-handler-style runs. get_task/list_tasks/batch_get_tasks are untouched and still return the full DTO.
This commit is contained in:
@@ -189,6 +189,41 @@ public sealed class ExternalMcpServiceTests : IDisposable
|
||||
Assert.Equal("new title", loaded!.Title);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateTask_ReturnsLeanReference_NotFullTaskDto()
|
||||
{
|
||||
// TaskRefDto has no Description/Result properties -- a writing tool that echoes it back
|
||||
// would re-send the (possibly long) description the caller just sent.
|
||||
Assert.DoesNotContain(nameof(TaskDto.Description), typeof(TaskRefDto).GetProperties().Select(p => p.Name));
|
||||
Assert.DoesNotContain("Result", typeof(TaskRefDto).GetProperties().Select(p => p.Name));
|
||||
|
||||
var listId = await SeedListAsync();
|
||||
var task = await SeedTaskAsync(listId, "old title");
|
||||
task.Description = "a long description the caller already has";
|
||||
await _tasks.UpdateAsync(task, CancellationToken.None);
|
||||
var sut = BuildSut(CreateQueue());
|
||||
|
||||
var dto = await sut.UpdateTask(task.Id, "new title", null, null, CancellationToken.None);
|
||||
|
||||
Assert.Equal(task.Id, dto.Id);
|
||||
Assert.Equal(listId, dto.ListId);
|
||||
Assert.Equal("new title", dto.Title);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetTask_ReturnsFullDtoIncludingDescription()
|
||||
{
|
||||
var listId = await SeedListAsync();
|
||||
var task = await SeedTaskAsync(listId, "with description");
|
||||
task.Description = "the full description text";
|
||||
await _tasks.UpdateAsync(task, CancellationToken.None);
|
||||
var sut = BuildSut(CreateQueue());
|
||||
|
||||
var dto = await sut.GetTask(task.Id, CancellationToken.None);
|
||||
|
||||
Assert.Equal("the full description text", dto.Description);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateTask_OnRunning_Throws()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user