Remove tool_choice agent option - auto-detect based on workspace/skills/memory
- Remove tool_choice from AgentEndpoint (create, update, list responses) - ChatService: automatically set tool_choice='any' when workspace, memory or skills present, null otherwise. Same for preparer/review/finalizer - SystemPromptBuilder: remove 3 toolAny-conditional prompt blocks (KRITISCH, Verhalten, ERINNERUNG) - Frontend: remove checkbox, badge and JS references - Agent.ToolChoice DB field preserved for backward compat, no longer read
This commit is contained in:
1 parent
677b227200
commit
83945689a6
6 files changed
+10
-55
No files matched your search
@@ -46,7 +46,6 @@ public static class AgentEndpoint
|
|||||||
Avatar = a.AvatarSmall ?? a.Avatar,
|
Avatar = a.AvatarSmall ?? a.Avatar,
|
||||||
a.Description,
|
a.Description,
|
||||||
a.Model,
|
a.Model,
|
||||||
a.ToolChoice,
|
|
||||||
a.CustomCommands,
|
a.CustomCommands,
|
||||||
a.AutoCommit,
|
a.AutoCommit,
|
||||||
a.UseSoul,
|
a.UseSoul,
|
||||||
@@ -94,7 +93,6 @@ public static class AgentEndpoint
|
|||||||
Avatar = a.AvatarSmall ?? a.Avatar,
|
Avatar = a.AvatarSmall ?? a.Avatar,
|
||||||
a.Description,
|
a.Description,
|
||||||
a.Model,
|
a.Model,
|
||||||
a.ToolChoice,
|
|
||||||
a.CustomCommands,
|
a.CustomCommands,
|
||||||
a.AutoCommit,
|
a.AutoCommit,
|
||||||
a.UseSoul,
|
a.UseSoul,
|
||||||
@@ -150,7 +148,6 @@ public static class AgentEndpoint
|
|||||||
AvatarSmall = imageService.ResizeDataUrlSmall(avatarRaw),
|
AvatarSmall = imageService.ResizeDataUrlSmall(avatarRaw),
|
||||||
Description = body.TryGetProperty("description", out var d) ? d.GetString() : null,
|
Description = body.TryGetProperty("description", out var d) ? d.GetString() : null,
|
||||||
Model = body.TryGetProperty("model", out var m) ? m.GetString() ?? "sonnet" : "sonnet",
|
Model = body.TryGetProperty("model", out var m) ? m.GetString() ?? "sonnet" : "sonnet",
|
||||||
ToolChoice = body.TryGetProperty("toolChoice", out var tc) ? tc.GetString() ?? "any" : "any",
|
|
||||||
CustomCommands = customCommands,
|
CustomCommands = customCommands,
|
||||||
AutoCommit = body.TryGetProperty("autoCommit", out var ac) ? ac.GetString() ?? "" : "",
|
AutoCommit = body.TryGetProperty("autoCommit", out var ac) ? ac.GetString() ?? "" : "",
|
||||||
UseSoul = !body.TryGetProperty("useSoul", out var us) || us.GetBoolean(),
|
UseSoul = !body.TryGetProperty("useSoul", out var us) || us.GetBoolean(),
|
||||||
@@ -191,7 +188,6 @@ public static class AgentEndpoint
|
|||||||
}
|
}
|
||||||
if (body.TryGetProperty("description", out var d)) agent.Description = d.GetString();
|
if (body.TryGetProperty("description", out var d)) agent.Description = d.GetString();
|
||||||
if (body.TryGetProperty("model", out var m)) agent.Model = m.GetString();
|
if (body.TryGetProperty("model", out var m)) agent.Model = m.GetString();
|
||||||
if (body.TryGetProperty("toolChoice", out var tc)) agent.ToolChoice = tc.GetString();
|
|
||||||
if (body.TryGetProperty("customCommands", out var cc))
|
if (body.TryGetProperty("customCommands", out var cc))
|
||||||
agent.CustomCommands = cc.ValueKind == JsonValueKind.Null ? null : cc.GetRawText();
|
agent.CustomCommands = cc.ValueKind == JsonValueKind.Null ? null : cc.GetRawText();
|
||||||
if (body.TryGetProperty("autoCommit", out var ac)) agent.AutoCommit = ac.GetString() ?? "";
|
if (body.TryGetProperty("autoCommit", out var ac)) agent.AutoCommit = ac.GetString() ?? "";
|
||||||
|
|||||||
+10
-6
@@ -68,11 +68,12 @@ public class ChatService
|
|||||||
agentSkills, _skillService, userPersona: user?.GetEffectivePersona(),
|
agentSkills, _skillService, userPersona: user?.GetEffectivePersona(),
|
||||||
resolvedWorkspace: workspace, planMode: planMode);
|
resolvedWorkspace: workspace, planMode: planMode);
|
||||||
|
|
||||||
var toolChoice = agent.ToolChoice ?? "any";
|
|
||||||
var hasWorkspace = !string.IsNullOrEmpty(workspace);
|
var hasWorkspace = !string.IsNullOrEmpty(workspace);
|
||||||
var includeMemory = agent.UseMemory && !string.IsNullOrEmpty(agent.AgentId);
|
var includeMemory = agent.UseMemory && !string.IsNullOrEmpty(agent.AgentId);
|
||||||
|
var hasTools = hasWorkspace || includeMemory;
|
||||||
|
var toolChoice = hasTools ? "any" : null;
|
||||||
|
|
||||||
var toolDefs = (hasWorkspace || includeMemory)
|
var toolDefs = hasTools
|
||||||
? _toolService.GetToolDefinitions(includeFileTools: hasWorkspace, includeMemory: includeMemory, includeUserChoice: agent.AllowUserChoice)
|
? _toolService.GetToolDefinitions(includeFileTools: hasWorkspace, includeMemory: includeMemory, includeUserChoice: agent.AllowUserChoice)
|
||||||
: Array.Empty<object>();
|
: Array.Empty<object>();
|
||||||
var toolNames = toolDefs.Length > 0
|
var toolNames = toolDefs.Length > 0
|
||||||
@@ -93,7 +94,7 @@ public class ChatService
|
|||||||
AgentId = agent.AgentId,
|
AgentId = agent.AgentId,
|
||||||
Model = modelId,
|
Model = modelId,
|
||||||
SystemPrompt = systemPromptText,
|
SystemPrompt = systemPromptText,
|
||||||
ToolChoice = (hasWorkspace || includeMemory) ? toolChoice : null,
|
ToolChoice = toolChoice,
|
||||||
ToolNames = toolNames,
|
ToolNames = toolNames,
|
||||||
PlanMode = planMode
|
PlanMode = planMode
|
||||||
});
|
});
|
||||||
@@ -159,6 +160,7 @@ Rückfrage (NUR mit [QUESTION] – stoppt die Weiterleitung):
|
|||||||
Für welche Plattform soll die App entwickelt werden? Web, Mobile oder Desktop?
|
Für welche Plattform soll die App entwickelt werden? Web, Mobile oder Desktop?
|
||||||
```" });
|
```" });
|
||||||
|
|
||||||
|
var preparerHasTools = !string.IsNullOrEmpty(preparerWorkspace) || preparerAgent.UseMemory;
|
||||||
preparerContext = new PreparerContext
|
preparerContext = new PreparerContext
|
||||||
{
|
{
|
||||||
ModelId = preparerModelId,
|
ModelId = preparerModelId,
|
||||||
@@ -167,7 +169,7 @@ Für welche Plattform soll die App entwickelt werden? Web, Mobile oder Desktop?
|
|||||||
Workspace = preparerWorkspace,
|
Workspace = preparerWorkspace,
|
||||||
UseMemory = preparerAgent.UseMemory,
|
UseMemory = preparerAgent.UseMemory,
|
||||||
WebSearchVersion = preparerAgent.WebSearchVersion,
|
WebSearchVersion = preparerAgent.WebSearchVersion,
|
||||||
ToolChoice = preparerAgent.ToolChoice ?? "any",
|
ToolChoice = preparerHasTools ? "any" : "auto",
|
||||||
AllowUserChoice = preparerAgent.AllowUserChoice,
|
AllowUserChoice = preparerAgent.AllowUserChoice,
|
||||||
Agent = preparerAgent
|
Agent = preparerAgent
|
||||||
};
|
};
|
||||||
@@ -195,6 +197,7 @@ Für welche Plattform soll die App entwickelt werden? Web, Mobile oder Desktop?
|
|||||||
if (!string.IsNullOrWhiteSpace(reviewSystemText))
|
if (!string.IsNullOrWhiteSpace(reviewSystemText))
|
||||||
reviewPrompt.Add(new { type = "text", text = reviewSystemText });
|
reviewPrompt.Add(new { type = "text", text = reviewSystemText });
|
||||||
|
|
||||||
|
var reviewHasTools = !string.IsNullOrEmpty(reviewWorkspace) || reviewAgent.UseMemory;
|
||||||
reviewContext = new ReviewContext
|
reviewContext = new ReviewContext
|
||||||
{
|
{
|
||||||
ModelId = reviewModelId,
|
ModelId = reviewModelId,
|
||||||
@@ -203,7 +206,7 @@ Für welche Plattform soll die App entwickelt werden? Web, Mobile oder Desktop?
|
|||||||
Workspace = reviewWorkspace,
|
Workspace = reviewWorkspace,
|
||||||
UseMemory = reviewAgent.UseMemory,
|
UseMemory = reviewAgent.UseMemory,
|
||||||
WebSearchVersion = reviewAgent.WebSearchVersion,
|
WebSearchVersion = reviewAgent.WebSearchVersion,
|
||||||
ToolChoice = reviewAgent.ToolChoice ?? "any",
|
ToolChoice = reviewHasTools ? "any" : "auto",
|
||||||
MaxReviewIterations = session.MaxReviewIterations > 0 ? session.MaxReviewIterations : 3,
|
MaxReviewIterations = session.MaxReviewIterations > 0 ? session.MaxReviewIterations : 3,
|
||||||
Agent = reviewAgent
|
Agent = reviewAgent
|
||||||
};
|
};
|
||||||
@@ -231,6 +234,7 @@ Für welche Plattform soll die App entwickelt werden? Web, Mobile oder Desktop?
|
|||||||
if (!string.IsNullOrWhiteSpace(finalizerSystemText))
|
if (!string.IsNullOrWhiteSpace(finalizerSystemText))
|
||||||
finalizerPrompt.Add(new { type = "text", text = finalizerSystemText });
|
finalizerPrompt.Add(new { type = "text", text = finalizerSystemText });
|
||||||
|
|
||||||
|
var finalizerHasTools = !string.IsNullOrEmpty(finalizerWorkspace) || finalizerAgent.UseMemory;
|
||||||
finalizerContext = new FinalizerContext
|
finalizerContext = new FinalizerContext
|
||||||
{
|
{
|
||||||
ModelId = finalizerModelId,
|
ModelId = finalizerModelId,
|
||||||
@@ -239,7 +243,7 @@ Für welche Plattform soll die App entwickelt werden? Web, Mobile oder Desktop?
|
|||||||
Workspace = finalizerWorkspace,
|
Workspace = finalizerWorkspace,
|
||||||
UseMemory = finalizerAgent.UseMemory,
|
UseMemory = finalizerAgent.UseMemory,
|
||||||
WebSearchVersion = finalizerAgent.WebSearchVersion,
|
WebSearchVersion = finalizerAgent.WebSearchVersion,
|
||||||
ToolChoice = finalizerAgent.ToolChoice ?? "any",
|
ToolChoice = finalizerHasTools ? "any" : "auto",
|
||||||
Agent = finalizerAgent
|
Agent = finalizerAgent
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,22 +51,9 @@ public static class SystemPromptBuilder
|
|||||||
blocks.Add(new PromptBlock { Icon = "fa-user", Label = "User · Persona (UseUserInfo)", Content = $"## Dein Gegenüber\nDie folgende Beschreibung stammt von der Person, die dir gerade schreibt:\n\n{userPersona}" });
|
blocks.Add(new PromptBlock { Icon = "fa-user", Label = "User · Persona (UseUserInfo)", Content = $"## Dein Gegenüber\nDie folgende Beschreibung stammt von der Person, die dir gerade schreibt:\n\n{userPersona}" });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool toolAny = string.Equals(agent.ToolChoice, "any", System.StringComparison.OrdinalIgnoreCase);
|
|
||||||
|
|
||||||
var effectiveWorkspace = resolvedWorkspace ?? session.Workspace;
|
var effectiveWorkspace = resolvedWorkspace ?? session.Workspace;
|
||||||
if (!string.IsNullOrWhiteSpace(effectiveWorkspace))
|
if (!string.IsNullOrWhiteSpace(effectiveWorkspace))
|
||||||
{
|
{
|
||||||
if (toolAny && !planMode)
|
|
||||||
{
|
|
||||||
blocks.Add(new PromptBlock
|
|
||||||
{
|
|
||||||
Icon = "fa-exclamation-triangle",
|
|
||||||
Label = "System · Workspace + ToolChoice: any",
|
|
||||||
Content = @$"## KRITISCH: Tool-Nutzung
|
|
||||||
JEDE Datei-Operation und JEDER Shell-Befehl MUSS über einen Tool-Aufruf erfolgen. NIEMALS eine Aktion nur beschreiben oder behaupten - IMMER das Tool tatsächlich aufrufen."
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (planMode)
|
if (planMode)
|
||||||
{
|
{
|
||||||
blocks.Add(new PromptBlock
|
blocks.Add(new PromptBlock
|
||||||
@@ -207,31 +194,7 @@ Alle Dateipfade in Tool-Aufrufen müssen relativ zu diesem Workspace sein oder a
|
|||||||
// autoCommit == "" → kein Block, Thema wird nicht erwähnt
|
// autoCommit == "" → kein Block, Thema wird nicht erwähnt
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolAny && !string.IsNullOrWhiteSpace(effectiveWorkspace) && !planMode)
|
|
||||||
{
|
|
||||||
blocks.Add(new PromptBlock
|
|
||||||
{
|
|
||||||
Icon = "fa-cog",
|
|
||||||
Label = "Agent · Verhalten (Workspace + ToolChoice: any)",
|
|
||||||
Content = string.Join("\n", new[]
|
|
||||||
{
|
|
||||||
"## 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."
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
blocks.Add(new PromptBlock
|
|
||||||
{
|
|
||||||
Icon = "fa-exclamation-circle",
|
|
||||||
Label = "System · Erinnerung (Workspace + ToolChoice: any)",
|
|
||||||
Content = @"## 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."
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// kein extra Erinnerungsblock ohne toolAny – Zeilenreferenz-Hinweise kommen direkt über die Nachricht
|
|
||||||
|
|
||||||
// Plan-Modus-Block
|
// Plan-Modus-Block
|
||||||
if (planMode)
|
if (planMode)
|
||||||
|
|||||||
@@ -198,10 +198,6 @@
|
|||||||
<div hidden>
|
<div hidden>
|
||||||
<label>Beschreibung</label>
|
<label>Beschreibung</label>
|
||||||
<input type="text" id="agentDescription" placeholder="Kurze Beschreibung (optional)">
|
<input type="text" id="agentDescription" placeholder="Kurze Beschreibung (optional)">
|
||||||
<label class="checkbox-label">
|
|
||||||
<input type="checkbox" id="agentToolChoice">
|
|
||||||
Tool-Nutzung erzwingen <span class="checkbox-hint">(tool_choice: any)</span>
|
|
||||||
</label>
|
|
||||||
<label class="checkbox-label">
|
<label class="checkbox-label">
|
||||||
<input type="checkbox" id="agentAllowUserChoice" checked>
|
<input type="checkbox" id="agentAllowUserChoice" checked>
|
||||||
Rückfragen erlauben <span class="checkbox-hint">(ask_user_choice Tool)</span>
|
Rückfragen erlauben <span class="checkbox-hint">(ask_user_choice Tool)</span>
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ function buildAgentCard(agent, skills) {
|
|||||||
|
|
||||||
// Badges
|
// Badges
|
||||||
const badges = [];
|
const badges = [];
|
||||||
if (agent.toolChoice === 'any') badges.push('<span class="badge badge-forced-feature" title="Tool-Nutzung erzwingen"><i class="fa fa-wrench"></i> Erzwungen</span>');
|
|
||||||
if (agent.allowUserChoice) badges.push('<span class="badge badge-feature" title="Rückfragen per Auswahl erlaubt"><i class="fa fa-question-circle"></i> Rückfragen</span>');
|
if (agent.allowUserChoice) badges.push('<span class="badge badge-feature" title="Rückfragen per Auswahl erlaubt"><i class="fa fa-question-circle"></i> Rückfragen</span>');
|
||||||
if (agent.autoCommit === 'mention') badges.push('<span class="badge badge-feature" title="Git-Commits nur auf Anweisung"><i class="fa fa-code-fork"></i> Anmerken</span>');
|
if (agent.autoCommit === 'mention') badges.push('<span class="badge badge-feature" title="Git-Commits nur auf Anweisung"><i class="fa fa-code-fork"></i> Anmerken</span>');
|
||||||
if (agent.autoCommit === 'enforce') badges.push('<span class="badge badge-forced-feature" title="Git-Commits nach jeder Änderung erzwungen"><i class="fa fa-code-fork"></i> Erzwungen</span>');
|
if (agent.autoCommit === 'enforce') badges.push('<span class="badge badge-forced-feature" title="Git-Commits nach jeder Änderung erzwungen"><i class="fa fa-code-fork"></i> Erzwungen</span>');
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ registerPage('agent', {
|
|||||||
const nameEl = document.getElementById('agentName');
|
const nameEl = document.getElementById('agentName');
|
||||||
const descEl = document.getElementById('agentDescription');
|
const descEl = document.getElementById('agentDescription');
|
||||||
const modelEl = document.getElementById('agentModel');
|
const modelEl = document.getElementById('agentModel');
|
||||||
const toolChoiceEl = document.getElementById('agentToolChoice');
|
|
||||||
const allowUserChoiceEl = document.getElementById('agentAllowUserChoice');
|
const allowUserChoiceEl = document.getElementById('agentAllowUserChoice');
|
||||||
const autoCommitEl = document.getElementById('agentAutoCommit');
|
const autoCommitEl = document.getElementById('agentAutoCommit');
|
||||||
const useSoulEl = document.getElementById('agentUseSoul');
|
const useSoulEl = document.getElementById('agentUseSoul');
|
||||||
@@ -58,7 +57,6 @@ registerPage('agent', {
|
|||||||
nameEl.value = agent.name || '';
|
nameEl.value = agent.name || '';
|
||||||
descEl.value = agent.description || '';
|
descEl.value = agent.description || '';
|
||||||
modelEl.value = agent.model || 'sonnet';
|
modelEl.value = agent.model || 'sonnet';
|
||||||
toolChoiceEl.checked = (agent.toolChoice || 'any') === 'any';
|
|
||||||
allowUserChoiceEl.checked = agent.allowUserChoice !== false;
|
allowUserChoiceEl.checked = agent.allowUserChoice !== false;
|
||||||
_agentTaskMde.value(agent.taskInstruction || '');
|
_agentTaskMde.value(agent.taskInstruction || '');
|
||||||
autoCommitEl.value = agent.autoCommit || '';
|
autoCommitEl.value = agent.autoCommit || '';
|
||||||
@@ -101,7 +99,6 @@ registerPage('agent', {
|
|||||||
name: nameEl.value.trim() || 'Unbenannt',
|
name: nameEl.value.trim() || 'Unbenannt',
|
||||||
description: descEl.value.trim(),
|
description: descEl.value.trim(),
|
||||||
model: modelEl.value,
|
model: modelEl.value,
|
||||||
toolChoice: toolChoiceEl.checked ? 'any' : 'auto',
|
|
||||||
allowUserChoice: allowUserChoiceEl.checked,
|
allowUserChoice: allowUserChoiceEl.checked,
|
||||||
autoCommit: autoCommitEl.value,
|
autoCommit: autoCommitEl.value,
|
||||||
useSoul: useSoulEl.checked,
|
useSoul: useSoulEl.checked,
|
||||||
|
|||||||
Reference in new issue
Block a user