Agent-Flags: useSoul, useIdentity, useUserInfo, useMemory

- 4 neue bool-Properties auf AgentRecord (Default: true)
- DB-Migration: use_soul, use_identity, use_user_info, use_memory
- SystemPromptBuilder: IDENTITY.md, SOUL.md, USER.md, Memory-Block bedingt
- AnthropicService: Memory-Tools nur wenn useMemory aktiv
- Agent-Formular: 4 Checkboxen (Seele, Identität, Gegenüber, Erinnerungen)
- API: Create + Update lesen/speichern die neuen Flags
This commit is contained in:
Meleki committed 2026-03-01 14:33:11 +01:00
1 parent da34739cba
commit 6df3591d8b
8 files changed
+57 -10

No files matched your search

+2 -1
View File
@@ -38,6 +38,7 @@ public class AnthropicService
string workspace,
string sessionId = null,
string agentId = null,
bool useMemory = true,
int maxIterations = 100,
string toolChoice = "any",
CancellationToken cancellationToken = default)
@@ -72,7 +73,7 @@ public class AnthropicService
if (!string.IsNullOrEmpty(workspace))
{
var includeMemory = _memoryService != null && !string.IsNullOrEmpty(agentId);
var includeMemory = useMemory && _memoryService != null && !string.IsNullOrEmpty(agentId);
payload["tools"] = _toolService.GetToolDefinitions(includeMemory);
// "any" erzwingt Tool-Nutzung, aber nur in der ersten Iteration,
// damit Claude nicht endlos Tools aufruft wenn die Aufgabe erledigt ist.
+9 -3
View File
@@ -130,6 +130,10 @@ public class DatabaseService
TryAddColumn(conn, "agents", "custom_commands", "TEXT");
TryAddColumn(conn, "messages", "is_marked", "INTEGER NOT NULL DEFAULT 0");
TryAddColumn(conn, "agents", "auto_commit", "INTEGER NOT NULL DEFAULT 0");
TryAddColumn(conn, "agents", "use_soul", "INTEGER NOT NULL DEFAULT 1");
TryAddColumn(conn, "agents", "use_identity", "INTEGER NOT NULL DEFAULT 1");
TryAddColumn(conn, "agents", "use_user_info", "INTEGER NOT NULL DEFAULT 1");
TryAddColumn(conn, "agents", "use_memory", "INTEGER NOT NULL DEFAULT 1");
}
private void TryAddColumn(SqliteConnection conn, string table, string column, string type)
@@ -148,8 +152,8 @@ public class DatabaseService
agent.CreatedAt = now;
agent.UpdatedAt = now;
await conn.ExecuteAsync(@"
INSERT INTO agents (agent_id, name, avatar, description, model, tool_choice, custom_commands, auto_commit, is_deleted, created_at, updated_at)
VALUES (@AgentId, @Name, @Avatar, @Description, @Model, @ToolChoice, @CustomCommands, @AutoCommit, 0, @CreatedAt, @UpdatedAt)
INSERT INTO agents (agent_id, name, avatar, description, model, tool_choice, custom_commands, auto_commit, use_soul, use_identity, use_user_info, use_memory, is_deleted, created_at, updated_at)
VALUES (@AgentId, @Name, @Avatar, @Description, @Model, @ToolChoice, @CustomCommands, @AutoCommit, @UseSoul, @UseIdentity, @UseUserInfo, @UseMemory, 0, @CreatedAt, @UpdatedAt)
", agent);
return agent;
}
@@ -175,7 +179,9 @@ public class DatabaseService
await conn.ExecuteAsync(@"
UPDATE agents SET name = @Name, avatar = @Avatar, description = @Description,
model = @Model, tool_choice = @ToolChoice,
custom_commands = @CustomCommands, auto_commit = @AutoCommit, updated_at = @UpdatedAt
custom_commands = @CustomCommands, auto_commit = @AutoCommit,
use_soul = @UseSoul, use_identity = @UseIdentity, use_user_info = @UseUserInfo, use_memory = @UseMemory,
updated_at = @UpdatedAt
WHERE agent_id = @AgentId
", agent);
}
+4 -4
View File
@@ -12,7 +12,7 @@ public static class SystemPromptBuilder
// IDENTITY.md - Wer bin ich (ersetzt "Du bist {Name}.")
var hasIdentity = false;
if (memoryService != null && !string.IsNullOrWhiteSpace(agent.AgentId))
if (agent.UseIdentity && memoryService != null && !string.IsNullOrWhiteSpace(agent.AgentId))
{
var identity = memoryService.ReadMemoryFile(agent.AgentId, "IDENTITY.md");
if (!string.IsNullOrEmpty(identity))
@@ -25,7 +25,7 @@ public static class SystemPromptBuilder
parts.Add($"Du bist {agent.Name}.");
// SOUL.md - Persönlichkeit + Regeln
if (memoryService != null && !string.IsNullOrWhiteSpace(agent.AgentId))
if (agent.UseSoul && memoryService != null && !string.IsNullOrWhiteSpace(agent.AgentId))
{
var soul = memoryService.ReadMemoryFile(agent.AgentId, "SOUL.md");
if (!string.IsNullOrEmpty(soul))
@@ -33,7 +33,7 @@ public static class SystemPromptBuilder
}
// USER.md - Global (aus data-Ordner)
if (!string.IsNullOrWhiteSpace(dataDir))
if (agent.UseUserInfo && !string.IsNullOrWhiteSpace(dataDir))
{
var userFile = System.IO.Path.Combine(dataDir, "USER.md");
if (System.IO.File.Exists(userFile))
@@ -67,7 +67,7 @@ Wenn der User auf eine bestimmte Zeile in einer Datei verweist (z.B. `[Datei: fo
parts.Add($"## Kontext\n{session.Context}");
// Memory-System
if (memoryService != null && !string.IsNullOrWhiteSpace(agent.AgentId))
if (agent.UseMemory && memoryService != null && !string.IsNullOrWhiteSpace(agent.AgentId))
{
var memoryLines = new List<string>
{