Token-Optimierung: Prompt Caching + Tool-Result-Truncation in History

This commit is contained in:
Meleki committed 2026-02-28 16:21:08 +01:00
1 parent ec5917ef63
commit f74409dd89
12 files changed
+220 -59

No files matched your search

+1 -12
View File
@@ -121,18 +121,7 @@ public static class SessionEndpoint
return;
}
var promptParts = new List<string>();
promptParts.Add($"Du bist {agent.Name}.");
if (!string.IsNullOrWhiteSpace(agent.Persona))
promptParts.Add($"## Persona\n{agent.Persona}");
if (!string.IsNullOrWhiteSpace(agent.Instructions))
promptParts.Add($"## Instructions\n{agent.Instructions}");
if (!string.IsNullOrWhiteSpace(session.Workspace))
promptParts.Add("## Tools\nDu hast Tools zur Verfügung (read_file, write_file, edit_file, list_files, delete_file, execute). Benutze sie um Dateien zu lesen, schreiben und bearbeiten. Beschreibe NICHT was du tun würdest - tu es einfach über die Tools.");
if (!string.IsNullOrWhiteSpace(session.Context))
promptParts.Add($"## Kontext\n{session.Context}");
var systemPrompt = string.Join("\n\n", promptParts);
var systemPrompt = SystemPromptBuilder.Build(agent, session);
ctx.Response.ContentType = "text/plain; charset=utf-8";
await ctx.Response.WriteAsync(systemPrompt);