feat: Auto-Commit Flag für Agents - neues Property AgentRecord.AutoCommit (bool) - DB-Migration: agents.auto_commit INTEGER NOT NULL DEFAULT 0 - Agent Create/Update um autoCommit erweitert - SystemPromptBuilder: bedingte Commit-Regel im Verhalten-Abschnitt - AutoCommit=true: Agent MUSS nach Änderungen committen - AutoCommit=false: Agent darf NIE eigenständig committen - Frontend: Checkbox 'Auto-Commit erlauben' in Agent-Settings
This commit is contained in:
1 parent
ab4ce839b4
commit
5037c7d24e
6 files changed
+35
-10
No files matched your search
@@ -55,7 +55,8 @@ public static class AgentEndpoint
|
||||
Persona = body.TryGetProperty("persona", out var p) ? p.GetString() : null,
|
||||
Instructions = body.TryGetProperty("instructions", out var i) ? i.GetString() : null,
|
||||
ToolChoice = body.TryGetProperty("toolChoice", out var tc) ? tc.GetString() ?? "any" : "any",
|
||||
CustomCommands = customCommands
|
||||
CustomCommands = customCommands,
|
||||
AutoCommit = body.TryGetProperty("autoCommit", out var ac) && ac.GetBoolean()
|
||||
};
|
||||
|
||||
agent = await db.CreateAgent(agent);
|
||||
@@ -81,6 +82,7 @@ public static class AgentEndpoint
|
||||
if (body.TryGetProperty("toolChoice", out var tc)) agent.ToolChoice = tc.GetString();
|
||||
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();
|
||||
|
||||
await db.UpdateAgent(agent);
|
||||
agent = await db.GetAgent(agentId);
|
||||
|
||||
@@ -12,6 +12,7 @@ public class AgentRecord
|
||||
public string Instructions { get; set; }
|
||||
public string ToolChoice { get; set; } // "any" oder "auto"
|
||||
public string CustomCommands { get; set; }
|
||||
public bool AutoCommit { get; set; }
|
||||
public bool IsDeleted { get; set; }
|
||||
public string CreatedAt { get; set; }
|
||||
public string UpdatedAt { get; set; }
|
||||
|
||||
@@ -129,6 +129,7 @@ public class DatabaseService
|
||||
TryAddColumn(conn, "agents", "tool_choice", "TEXT DEFAULT 'any'");
|
||||
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");
|
||||
}
|
||||
|
||||
private void TryAddColumn(SqliteConnection conn, string table, string column, string type)
|
||||
@@ -147,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, is_deleted, created_at, updated_at)
|
||||
VALUES (@AgentId, @Name, @Avatar, @Description, @Model, @Persona, @Instructions, @ToolChoice, @CustomCommands, 0, @CreatedAt, @UpdatedAt)
|
||||
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)
|
||||
", agent);
|
||||
return agent;
|
||||
}
|
||||
@@ -174,7 +175,7 @@ public class DatabaseService
|
||||
await conn.ExecuteAsync(@"
|
||||
UPDATE agents SET name = @Name, avatar = @Avatar, description = @Description,
|
||||
model = @Model, persona = @Persona, instructions = @Instructions, tool_choice = @ToolChoice,
|
||||
custom_commands = @CustomCommands, updated_at = @UpdatedAt
|
||||
custom_commands = @CustomCommands, auto_commit = @AutoCommit, updated_at = @UpdatedAt
|
||||
WHERE agent_id = @AgentId
|
||||
", agent);
|
||||
}
|
||||
|
||||
@@ -41,13 +41,27 @@ Wenn der User auf eine bestimmte Zeile in einer Datei verweist (z.B. `[Datei: fo
|
||||
|
||||
if (toolAny)
|
||||
{
|
||||
parts.Add(@"## Verhalten
|
||||
- Wenn du Dateien lesen, schreiben, bearbeiten, erstellen oder löschen willst: IMMER das entsprechende Tool aufrufen. NIEMALS den Inhalt nur in die Antwort schreiben.
|
||||
- Wenn du Shell-Befehle ausführen willst: IMMER das execute-Tool verwenden.
|
||||
- Behaupte NIEMALS etwas getan zu haben (Datei geschrieben, Commit gemacht, Befehl ausgeführt) ohne das entsprechende Tool tatsächlich aufgerufen zu haben. Wenn kein Tool-Aufruf stattgefunden hat, ist nichts passiert.
|
||||
- Plane nicht nur - handle sofort über Tool-Aufrufe.
|
||||
var verhaltensRegeln = new List<string>
|
||||
{
|
||||
"## Verhalten",
|
||||
"- Wenn du Dateien lesen, schreiben, bearbeiten, erstellen oder löschen willst: IMMER das entsprechende Tool aufrufen. NIEMALS den Inhalt nur in die Antwort schreiben.",
|
||||
"- Wenn du Shell-Befehle ausführen willst: IMMER das execute-Tool verwenden.",
|
||||
@"- Behaupte NIEMALS etwas getan zu haben (Datei geschrieben, Commit gemacht, Befehl ausgeführt) ohne das entsprechende Tool tatsächlich aufgerufen zu haben. Wenn kein Tool-Aufruf stattgefunden hat, ist nichts passiert.",
|
||||
"- Plane nicht nur - handle sofort über Tool-Aufrufe."
|
||||
};
|
||||
|
||||
## ERINNERUNG
|
||||
if (agent.AutoCommit)
|
||||
{
|
||||
verhaltensRegeln.Add(@"- Nach jeder abgeschlossenen Änderung MUSS ein Git-Commit erstellt werden. Prüfe Änderungen mit `git diff`, erstelle einen passenden Commit mit einer aussagekräftigen Message. Mehrere zusammenhängende Änderungen dürfen in einem Commit zusammengefasst werden.");
|
||||
}
|
||||
else
|
||||
{
|
||||
verhaltensRegeln.Add(@"- Git-Commits NIEMALS eigenständig erstellen. Commits werden NUR durchgeführt wenn der User es EXPLIZIT anfordert (z.B. ""erstelle einen Commit"", ""commit""). Auch nach abgeschlossenen Aufgaben NICHT automatisch committen.");
|
||||
}
|
||||
|
||||
parts.Add(string.Join("\n", verhaltensRegeln));
|
||||
|
||||
parts.Add(@"## ERINNERUNG
|
||||
Diese Regel hat höchste Priorität und gilt für JEDE Antwort: Wenn eine Datei gelesen, geschrieben, bearbeitet, erstellt oder gelöscht werden soll, oder ein Befehl ausgeführt werden soll, MUSS der entsprechende Tool-Aufruf erfolgen. Ohne Tool-Aufruf ist NICHTS passiert. Beschreibe keine Änderungen - führe sie durch.");
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +131,10 @@
|
||||
<input type="checkbox" id="agentToolChoice" checked>
|
||||
Tool-Nutzung erzwingen <span class="checkbox-hint">(tool_choice: any)</span>
|
||||
</label>
|
||||
<label class="checkbox-label">
|
||||
<input type="checkbox" id="agentAutoCommit">
|
||||
Auto-Commit erlauben <span class="checkbox-hint">(Agent darf eigenständig committen)</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>
|
||||
|
||||
@@ -21,6 +21,7 @@ registerPage('agent', {
|
||||
const personaEl = document.getElementById('agentPersona');
|
||||
const instructionsEl = document.getElementById('agentInstructions');
|
||||
const toolChoiceEl = document.getElementById('agentToolChoice');
|
||||
const autoCommitEl = document.getElementById('agentAutoCommit');
|
||||
const avatarPreview = document.getElementById('avatarPreview');
|
||||
const avatarInput = document.getElementById('avatarInput');
|
||||
const avatarBtn = document.getElementById('avatarBtn');
|
||||
@@ -41,6 +42,7 @@ registerPage('agent', {
|
||||
personaEl.value = agent.persona || '';
|
||||
instructionsEl.value = agent.instructions || '';
|
||||
toolChoiceEl.checked = (agent.toolChoice || 'any') === 'any';
|
||||
autoCommitEl.checked = !!agent.autoCommit;
|
||||
_agentAvatarData = agent.avatar || null;
|
||||
deleteBtn.hidden = false;
|
||||
|
||||
@@ -103,6 +105,7 @@ registerPage('agent', {
|
||||
persona: personaEl.value,
|
||||
instructions: instructionsEl.value,
|
||||
toolChoice: toolChoiceEl.checked ? 'any' : 'auto',
|
||||
autoCommit: autoCommitEl.checked,
|
||||
avatar: _agentAvatarData,
|
||||
customCommands: getCommandsFromUI(commandsList)
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user