diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Agent.Core/Prompts/PromptComposer.cs | 21 | ||||
| -rw-r--r-- | src/Agent.Core/Runtime/AgentRuntime.cs | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/Agent.Core/Prompts/PromptComposer.cs b/src/Agent.Core/Prompts/PromptComposer.cs index 69b18f3..2899088 100644 --- a/src/Agent.Core/Prompts/PromptComposer.cs +++ b/src/Agent.Core/Prompts/PromptComposer.cs @@ -13,8 +13,10 @@ public sealed record PromptContext( string SandboxCapabilitySummary, string TaskGraphSummary, string PreviousSummary, + IReadOnlyList<ExecutionResult> ExecutionResults, IReadOnlyList<ConversationMessage> Conversation, string Request, + bool RequiresExternalEffect, IReadOnlyList<string>? Images = null); public static class PromptComposer @@ -29,7 +31,9 @@ public static class PromptComposer new("system", ComposeSkillCatalog(context.AvailableSkills)), new("system", context.SandboxCapabilitySummary), new("system", context.TaskGraphSummary), - new("system", context.PreviousSummary) + new("system", context.PreviousSummary), + new("system", ComposeExecutionResults(context.ExecutionResults)), + new("system", ComposeExecutionRequirement(context.RequiresExternalEffect)) }; // Inject selected skill instructions (Progressive Disclosure Stage 3). foreach (AgentSkill skill in context.SelectedSkills) @@ -39,6 +43,21 @@ public static class PromptComposer return messages; } + private static string ComposeExecutionRequirement(bool requiresExternalEffect) => requiresExternalEffect + ? "The current Planner Task requires a verified external effect. Call the appropriate available Internal Tool now. " + + "A prose description, promise, plan, or fenced JSON example does not perform the operation and cannot complete this Task. " + + "After a successful read, use its returned content and proceed to the required write or process operation without repeating the read unnecessarily." + : "The current Planner Task does not require an external effect. Use an Internal Tool only when its verified result is needed; do not claim an unverified result."; + + private static string ComposeExecutionResults(IReadOnlyList<ExecutionResult> results) + { + if (results.Count == 0) return "No prior Execution Results are available for the current Session."; + var lines = new List<string> { "Recent verified Execution Results:" }; + foreach (ExecutionResult result in results) + lines.Add($"- {result.ToolName} ({(result.Success ? "success" : "failed")}): {result.Output}"); + return string.Join("\n", lines); + } + /// <summary> /// Stage 1 Discovery: only name + description are included. Full instructions are NOT included. /// </summary> diff --git a/src/Agent.Core/Runtime/AgentRuntime.cs b/src/Agent.Core/Runtime/AgentRuntime.cs index bc9fc5e..f1c7186 100644 --- a/src/Agent.Core/Runtime/AgentRuntime.cs +++ b/src/Agent.Core/Runtime/AgentRuntime.cs @@ -218,8 +218,10 @@ public sealed class AgentRuntime(TaskRegistry registry, IOllamaClient ollama, Ag settings.SandboxCapabilitySummary, BuildTaskGraphSummary(graph, plannerTask), session.Summary ?? string.Empty, + session.ExecutionResults, session.Conversation, plannerTask.Description, + plannerTask.RequiresExternalEffect, task.Images)).ToList(); var guard = new ToolUseGuard(settings.SameFailureLimit); |
