summaryrefslogtreecommitdiff
path: root/src/Agent.Core/Tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/Agent.Core/Tools')
-rw-r--r--src/Agent.Core/Tools/TaskGraphToolHandler.cs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Agent.Core/Tools/TaskGraphToolHandler.cs b/src/Agent.Core/Tools/TaskGraphToolHandler.cs
index edc1cc5..10094d3 100644
--- a/src/Agent.Core/Tools/TaskGraphToolHandler.cs
+++ b/src/Agent.Core/Tools/TaskGraphToolHandler.cs
@@ -21,13 +21,13 @@ public sealed class TaskGraphToolHandler(int maxTasks = 32, SessionStore? sessio
TaskGraph graph = new(maxTasks);
if (sessions is not null && sessions.TryGet(sessionId, out AgentSession? session) && session is not null)
{
- if (!session.TaskGraphs.TryAdd(taskId, graph))
- throw new InvalidOperationException($"TaskGraph for '{taskId}' already exists in session '{sessionId}'.");
+ // PlanAsync may have already created a TaskGraph for this taskId.
+ // If so, keep the planned graph; otherwise add a new empty one.
+ session.TaskGraphs.TryAdd(taskId, graph);
}
else
{
- if (!_fallbackGraphs.TryAdd(taskId, graph))
- throw new InvalidOperationException($"TaskGraph for '{taskId}' already exists.");
+ _fallbackGraphs.TryAdd(taskId, graph);
}
}