Token-Optimierung: Prompt Caching + Tool-Result-Truncation in History
This commit is contained in:
1 parent
ec5917ef63
commit
f74409dd89
12 files changed
+220
-59
No files matched your search
+29
-11
@@ -11,7 +11,7 @@ namespace Gott.Services;
|
||||
|
||||
public class ToolService
|
||||
{
|
||||
public object[] GetToolDefinitions()
|
||||
public object[] GetToolDefinitions(bool markLastAsCached = false)
|
||||
{
|
||||
return new object[]
|
||||
{
|
||||
@@ -88,20 +88,38 @@ public class ToolService
|
||||
required = new[] { "path" }
|
||||
}
|
||||
},
|
||||
new
|
||||
{
|
||||
name = "execute",
|
||||
description = "Führt einen Shell-Befehl im Workspace-Verzeichnis aus. Gibt stdout und stderr zurück. Timeout: 30 Sekunden.",
|
||||
input_schema = new
|
||||
// Letztes Tool bekommt cache_control – Anthropic cached alles bis einschließlich
|
||||
// dieses Breakpoints (System-Prompt + alle Tool-Definitionen) für 5 Minuten.
|
||||
markLastAsCached
|
||||
? (object)new
|
||||
{
|
||||
type = "object",
|
||||
properties = new Dictionary<string, object>
|
||||
name = "execute",
|
||||
description = "Führt einen Shell-Befehl im Workspace-Verzeichnis aus. Gibt stdout und stderr zurück. Timeout: 30 Sekunden.",
|
||||
input_schema = new
|
||||
{
|
||||
["command"] = new { type = "string", description = "Shell-Befehl zum Ausführen" }
|
||||
type = "object",
|
||||
properties = new Dictionary<string, object>
|
||||
{
|
||||
["command"] = new { type = "string", description = "Shell-Befehl zum Ausführen" }
|
||||
},
|
||||
required = new[] { "command" }
|
||||
},
|
||||
required = new[] { "command" }
|
||||
cache_control = new { type = "ephemeral" }
|
||||
}
|
||||
: new
|
||||
{
|
||||
name = "execute",
|
||||
description = "Führt einen Shell-Befehl im Workspace-Verzeichnis aus. Gibt stdout und stderr zurück. Timeout: 30 Sekunden.",
|
||||
input_schema = new
|
||||
{
|
||||
type = "object",
|
||||
properties = new Dictionary<string, object>
|
||||
{
|
||||
["command"] = new { type = "string", description = "Shell-Befehl zum Ausführen" }
|
||||
},
|
||||
required = new[] { "command" }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user