Agent-Persona auf File-Basis umgestellt (IDENTITY.md, SOUL.md, USER.md)

- Persona/Instructions DB-Felder aus AgentRecord, DB-Queries, API und Frontend entfernt
- SystemPromptBuilder liest jetzt IDENTITY.md + SOUL.md aus data/agents/{agentId}/
- Globale USER.md aus data/ wird in jeden System-Prompt injiziert
- MemoryService.DataDir als public Property exponiert
- Denker: IDENTITY.md + SOUL.md erstellt
- Meleki: Migrations-Vorlagen unter migration/meleki/ angelegt
- USER.md global unter publish/data/ erstellt
This commit is contained in:
Meleki committed 2026-03-01 13:53:49 +01:00
1 parent a73a67f810
commit 3fba628bd2
11 files changed
+102 -26

No files matched your search

+3 -3
View File
@@ -148,8 +148,8 @@ public class DatabaseService
agent.CreatedAt = now;
agent.UpdatedAt = now;
await conn.ExecuteAsync(@"
INSERT INTO agents (agent_id, name, avatar, description, model, persona, instructions, tool_choice, custom_commands, auto_commit, is_deleted, created_at, updated_at)
VALUES (@AgentId, @Name, @Avatar, @Description, @Model, @Persona, @Instructions, @ToolChoice, @CustomCommands, @AutoCommit, 0, @CreatedAt, @UpdatedAt)
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)
", agent);
return agent;
}
@@ -174,7 +174,7 @@ public class DatabaseService
agent.UpdatedAt = DateTime.UtcNow.ToString("o");
await conn.ExecuteAsync(@"
UPDATE agents SET name = @Name, avatar = @Avatar, description = @Description,
model = @Model, persona = @Persona, instructions = @Instructions, tool_choice = @ToolChoice,
model = @Model, tool_choice = @ToolChoice,
custom_commands = @CustomCommands, auto_commit = @AutoCommit, updated_at = @UpdatedAt
WHERE agent_id = @AgentId
", agent);
+2
View File
@@ -9,6 +9,8 @@ public class MemoryService
{
private readonly string _dataDir;
public string DataDir => _dataDir;
public MemoryService(string dataDir)
{
_dataDir = dataDir;
+27 -5
View File
@@ -6,16 +6,38 @@ namespace Gott.Services;
public static class SystemPromptBuilder
{
public static string Build(AgentRecord agent, SessionRecord session, IEnumerable<MessageRecord> markedMessages = null, MemoryService memoryService = null, string agentMemoryDir = null)
public static string Build(AgentRecord agent, SessionRecord session, IEnumerable<MessageRecord> markedMessages = null, MemoryService memoryService = null, string agentMemoryDir = null, string dataDir = null)
{
var parts = new List<string>();
parts.Add($"Du bist {agent.Name}.");
if (!string.IsNullOrWhiteSpace(agent.Persona))
parts.Add($"## Persona\n{agent.Persona}");
// IDENTITY.md - Wer bin ich
if (memoryService != null && !string.IsNullOrWhiteSpace(agent.AgentId))
{
var identity = memoryService.ReadMemoryFile(agent.AgentId, "IDENTITY.md");
if (!string.IsNullOrEmpty(identity))
parts.Add(identity);
}
if (!string.IsNullOrWhiteSpace(agent.Instructions))
parts.Add($"## Instructions\n{agent.Instructions}");
// SOUL.md - Persönlichkeit + Regeln
if (memoryService != null && !string.IsNullOrWhiteSpace(agent.AgentId))
{
var soul = memoryService.ReadMemoryFile(agent.AgentId, "SOUL.md");
if (!string.IsNullOrEmpty(soul))
parts.Add(soul);
}
// USER.md - Global (aus data-Ordner)
if (!string.IsNullOrWhiteSpace(dataDir))
{
var userFile = System.IO.Path.Combine(dataDir, "USER.md");
if (System.IO.File.Exists(userFile))
{
var userContent = System.IO.File.ReadAllText(userFile);
if (!string.IsNullOrWhiteSpace(userContent))
parts.Add(userContent);
}
}
bool toolAny = string.Equals(agent.ToolChoice, "any", System.StringComparison.OrdinalIgnoreCase);