using Agent.Core.Ollama; using Agent.Core.Sessions; using Agent.Core.Skills; namespace Agent.Core.Prompts; public sealed record PromptContext( string FixedSystemPrompt, string UserSystemPrompt, string Locale, IReadOnlyList AvailableSkills, IReadOnlyList SelectedSkills, string SandboxCapabilitySummary, string TaskGraphSummary, string PreviousSummary, IReadOnlyList Conversation, string Request, IReadOnlyList? Images = null); public static class PromptComposer { public static IReadOnlyList Compose(PromptContext context) { var messages = new List { new("system", context.FixedSystemPrompt), new("system", context.UserSystemPrompt), new("system", $"Respond in locale: {context.Locale}."), new("system", ComposeSkillCatalog(context.AvailableSkills)), new("system", context.SandboxCapabilitySummary), new("system", context.TaskGraphSummary), new("system", context.PreviousSummary) }; // Inject selected skill instructions (Progressive Disclosure Stage 3). foreach (AgentSkill skill in context.SelectedSkills) messages.Add(new("system", skill.Instructions)); messages.AddRange(context.Conversation.Select(static item => new OllamaMessage(item.Role, item.Content))); messages.Add(new OllamaMessage("user", context.Request, context.Images)); return messages; } /// /// Stage 1 Discovery: only name + description are included. Full instructions are NOT included. /// private static string ComposeSkillCatalog(IReadOnlyList skills) { if (skills.Count == 0) return "No skills available."; var lines = new List { "Available skills:" }; foreach (AgentSkill skill in skills) lines.Add($"- {skill.Name}: {skill.Description}"); lines.Add("If a skill is relevant to the request, indicate which skills to use."); return string.Join("\n", lines); } }