diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-08-11 22:36:21 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-08-11 22:36:21 +0900 |
| commit | 8f8e82e00e5d0e9347feef10111faac788ad7d88 (patch) | |
| tree | 300934ab2cf1af03c0eeeb18e496608fe4d63e60 /src/Agent.Core/Runtime/PlannerService.cs | |
| parent | c34a0df11ee4dd899781b44e7c4557e76b511fd5 (diff) | |
Require task-specific tool evidence
Diffstat (limited to 'src/Agent.Core/Runtime/PlannerService.cs')
| -rw-r--r-- | src/Agent.Core/Runtime/PlannerService.cs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/Agent.Core/Runtime/PlannerService.cs b/src/Agent.Core/Runtime/PlannerService.cs index 18e4043..b5ac80e 100644 --- a/src/Agent.Core/Runtime/PlannerService.cs +++ b/src/Agent.Core/Runtime/PlannerService.cs @@ -94,7 +94,7 @@ public sealed class PlannerService(IOllamaClient ollama, AgentRuntimeSettings se string description = string.IsNullOrWhiteSpace(pt.Description) ? originalRequest : pt.Description; PlannerTask task = graph.AddTask(description, budgetClass, estimate, dependencies, pt.RequiresExternalEffect, - requiredEffectTools: ValidateRequiredEffectTools(pt)); + requiredTools: ValidateRequiredTools(pt)); idMap.Add(task.Id); } @@ -112,7 +112,7 @@ public sealed class PlannerService(IOllamaClient ollama, AgentRuntimeSettings se foreach (PlannerTask item in completed) { Guid[] dependencies = item.Dependencies.Where(id => completed.Any(candidate => candidate.Id == id)).ToArray(); - PlannerTask copy = graph.AddTask(item.Description, item.BudgetClass, item.Estimate, dependencies, item.RequiresExternalEffect, item.Id, item.RequiredEffectTools); + PlannerTask copy = graph.AddTask(item.Description, item.BudgetClass, item.Estimate, dependencies, item.RequiresExternalEffect, item.Id, item.RequiredTools); graph.AddUsage(copy.Id, item.ActualInputTokens, item.ActualOutputTokens); graph.SetState(copy.Id, PlannerTaskState.Completed); } @@ -142,7 +142,7 @@ public sealed class PlannerService(IOllamaClient ollama, AgentRuntimeSettings se string description = string.IsNullOrWhiteSpace(pt.Description) ? originalRequest : pt.Description; PlannerTask task = graph.AddTask(description, bc, est, dependencies, pt.RequiresExternalEffect, - requiredEffectTools: ValidateRequiredEffectTools(pt)); + requiredTools: ValidateRequiredTools(pt)); idMap.Add(task.Id); } @@ -169,16 +169,16 @@ public sealed class PlannerService(IOllamaClient ollama, AgentRuntimeSettings se return new TokenEstimate(o, m, p); } - private static IReadOnlySet<string> ValidateRequiredEffectTools(PlannedTask task) + private static IReadOnlySet<string> ValidateRequiredTools(PlannedTask task) { - HashSet<string> tools = task.RequiredEffectTools.ToHashSet(StringComparer.Ordinal); - string[] allowed = ["file_edit", "process_run", "dir"]; + HashSet<string> tools = task.RequiredTools.ToHashSet(StringComparer.Ordinal); + string[] allowed = ["file_search", "file_read", "file_edit", "process_run", "task_update", "dir"]; if (tools.Any(tool => !allowed.Contains(tool, StringComparer.Ordinal))) - throw new PlannerValidationException("required_effect_tools contains a Tool that cannot provide external-effect evidence."); + throw new PlannerValidationException("required_tools contains an unknown Internal Tool."); if (task.RequiresExternalEffect && tools.Count == 0) - throw new PlannerValidationException("An external-effect Task must provide required_effect_tools."); - if (!task.RequiresExternalEffect && tools.Count != 0) - throw new PlannerValidationException("A non-effect Task must have empty required_effect_tools."); + throw new PlannerValidationException("An external-effect Task must provide required_tools."); + if (!task.RequiresExternalEffect && tools.Any(tool => tool is "file_edit" or "process_run")) + throw new PlannerValidationException("A non-effect Task cannot require an effect-only Tool."); return tools; } @@ -300,12 +300,12 @@ public sealed class PlannerService(IOllamaClient ollama, AgentRuntimeSettings se - budget_class: one of 1K, 2K, 4K, 8K, 16K, 32K, 64K, 128K (token budget for this task) - optimistic_tokens, most_likely_tokens, pessimistic_tokens: PERT estimates (0 < O <= M <= P <= budget) - requires_external_effect: true if this task requires a verifiable external effect (file edit, process run, etc.) - - required_effect_tools: the exact effect-producing Internal Tool names whose successful result can complete this task; use only file_edit, process_run, or dir + - required_tools: the exact Internal Tool names whose successful result is required to complete this task; use names from the supplied Tool catalog, or [] for a pure response task For pure analysis or informational tasks, requires_external_effect should be false. For tasks that modify files, run processes, or produce verifiable side effects, requires_external_effect should be true. Read-only operations (file_read, file_search, and dir list) do not create an external effect and must use requires_external_effect=false. - When requires_external_effect is false, required_effect_tools must be empty. When true, it must contain at least one Tool and only the Tool(s) that prove this task's own expected effect. + A read/search/list task must name file_read, file_search, or dir in required_tools even though requires_external_effect is false. A pure response task uses an empty array. When requires_external_effect is true, required_tools must include the effect Tool that proves this task's own expected effect. Preserve every user-supplied absolute path, executable, cwd, argument array, operation name, and literal value exactly in the task that uses it; never abbreviate these values into a shell-like command. Keep each task limited to its own described operation. Do not put later dependent operations into an earlier task. A single task is valid for simple requests. |
