| 460 | } |
| 461 | |
| 462 | func (t *ToolSet) nextTask(_ context.Context, _ tools.ToolCall) (*tools.ToolCallResult, error) { |
| 463 | t.mu.Lock() |
| 464 | defer t.mu.Unlock() |
| 465 | |
| 466 | store := t.load() |
| 467 | var tasks []taskWithEffective |
| 468 | for _, task := range store.Tasks { |
| 469 | tasks = append(tasks, taskWithEffective{ |
| 470 | Task: task, |
| 471 | EffectiveStatus: effectiveStatus(task, store.Tasks), |
| 472 | }) |
| 473 | } |
| 474 | sortTasks(tasks) |
| 475 | |
| 476 | for _, task := range tasks { |
| 477 | if task.EffectiveStatus != StatusBlocked && task.EffectiveStatus != StatusDone { |
| 478 | return tools.ResultJSON(task), nil |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | return tools.ResultSuccess("No actionable tasks. Everything is either done or blocked."), nil |
| 483 | } |
| 484 | |
| 485 | func (t *ToolSet) addDependency(_ context.Context, params AddDependencyArgs) (*tools.ToolCallResult, error) { |
| 486 | t.mu.Lock() |