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

+9 -1
View File
@@ -54,7 +54,11 @@ public static class AgentEndpoint
Model = body.TryGetProperty("model", out var m) ? m.GetString() ?? "sonnet" : "sonnet",
ToolChoice = body.TryGetProperty("toolChoice", out var tc) ? tc.GetString() ?? "any" : "any",
CustomCommands = customCommands,
AutoCommit = body.TryGetProperty("autoCommit", out var ac) && ac.GetBoolean()
AutoCommit = body.TryGetProperty("autoCommit", out var ac) && ac.GetBoolean(),
UseSoul = !body.TryGetProperty("useSoul", out var us) || us.GetBoolean(),
UseIdentity = !body.TryGetProperty("useIdentity", out var ui) || ui.GetBoolean(),
UseUserInfo = !body.TryGetProperty("useUserInfo", out var uu) || uu.GetBoolean(),
UseMemory = !body.TryGetProperty("useMemory", out var um) || um.GetBoolean()
};
agent = await db.CreateAgent(agent);
@@ -80,6 +84,10 @@ public static class AgentEndpoint
if (body.TryGetProperty("customCommands", out var cc))
agent.CustomCommands = cc.ValueKind == JsonValueKind.Null ? null : cc.GetRawText();
if (body.TryGetProperty("autoCommit", out var ac)) agent.AutoCommit = ac.GetBoolean();
if (body.TryGetProperty("useSoul", out var us)) agent.UseSoul = us.GetBoolean();
if (body.TryGetProperty("useIdentity", out var ui)) agent.UseIdentity = ui.GetBoolean();
if (body.TryGetProperty("useUserInfo", out var uu)) agent.UseUserInfo = uu.GetBoolean();
if (body.TryGetProperty("useMemory", out var um)) agent.UseMemory = um.GetBoolean();
await db.UpdateAgent(agent);
memoryService.InitializeAgentFiles(agentId, agent.Name);
+1 -1
View File
@@ -161,7 +161,7 @@ public static class ChatEndpoint
streamingTracker.Start(sessionId, chainId);
try
{
await anthropic.StreamChat(res, modelId, systemPrompt, messages, chainId, workspace, sessionId, agentId: agent.AgentId, maxIterations: maxIterations, toolChoice: toolChoice, cancellationToken: cancellationToken);
await anthropic.StreamChat(res, modelId, systemPrompt, messages, chainId, workspace, sessionId, agentId: agent.AgentId, useMemory: agent.UseMemory, maxIterations: maxIterations, toolChoice: toolChoice, cancellationToken: cancellationToken);
}
finally
{
+4
View File
@@ -11,6 +11,10 @@ public class AgentRecord
public string ToolChoice { get; set; } // "any" oder "auto"
public string CustomCommands { get; set; }
public bool AutoCommit { get; set; }
public bool UseSoul { get; set; } = true;
public bool UseIdentity { get; set; } = true;
public bool UseUserInfo { get; set; } = true;
public bool UseMemory { get; set; } = true;
public bool IsDeleted { get; set; }
public string CreatedAt { get; set; }
public string UpdatedAt { get; set; }
+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>
{
+16
View File
@@ -125,6 +125,22 @@
<input type="checkbox" id="agentAutoCommit">
Auto-Commit erlauben <span class="checkbox-hint">(Agent darf eigenständig committen)</span>
</label>
<label class="checkbox-label">
<input type="checkbox" id="agentUseSoul" checked>
Hat eine Seele <span class="checkbox-hint">(SOUL.md im System-Prompt)</span>
</label>
<label class="checkbox-label">
<input type="checkbox" id="agentUseIdentity" checked>
Hat eine Identität <span class="checkbox-hint">(IDENTITY.md im System-Prompt)</span>
</label>
<label class="checkbox-label">
<input type="checkbox" id="agentUseUserInfo" checked>
Kennt sein Gegenüber <span class="checkbox-hint">(USER.md im System-Prompt)</span>
</label>
<label class="checkbox-label">
<input type="checkbox" id="agentUseMemory" checked>
Auf Erinnerungen zugreifen <span class="checkbox-hint">(Memory-Tools verfügbar)</span>
</label>
<label>Benutzerdefinierte Befehle</label>
<div class="custom-commands" id="agentCommandsList"></div>
<button type="button" id="agentAddCommandBtn" class="add-cmd-btn">+ Befehl hinzufügen</button>
+12
View File
@@ -20,6 +20,10 @@ registerPage('agent', {
const modelEl = document.getElementById('agentModel');
const toolChoiceEl = document.getElementById('agentToolChoice');
const autoCommitEl = document.getElementById('agentAutoCommit');
const useSoulEl = document.getElementById('agentUseSoul');
const useIdentityEl = document.getElementById('agentUseIdentity');
const useUserInfoEl = document.getElementById('agentUseUserInfo');
const useMemoryEl = document.getElementById('agentUseMemory');
const avatarPreview = document.getElementById('avatarPreview');
const avatarInput = document.getElementById('avatarInput');
const avatarBtn = document.getElementById('avatarBtn');
@@ -39,6 +43,10 @@ registerPage('agent', {
modelEl.value = agent.model || 'sonnet';
toolChoiceEl.checked = (agent.toolChoice || 'any') === 'any';
autoCommitEl.checked = !!agent.autoCommit;
useSoulEl.checked = agent.useSoul !== false;
useIdentityEl.checked = agent.useIdentity !== false;
useUserInfoEl.checked = agent.useUserInfo !== false;
useMemoryEl.checked = agent.useMemory !== false;
_agentAvatarData = agent.avatar || null;
deleteBtn.hidden = false;
@@ -100,6 +108,10 @@ registerPage('agent', {
model: modelEl.value,
toolChoice: toolChoiceEl.checked ? 'any' : 'auto',
autoCommit: autoCommitEl.checked,
useSoul: useSoulEl.checked,
useIdentity: useIdentityEl.checked,
useUserInfo: useUserInfoEl.checked,
useMemory: useMemoryEl.checked,
avatar: _agentAvatarData,
customCommands: getCommandsFromUI(commandsList)
};