Agent: Max Output Tokens + Thinking deaktivieren einstellbar
Zwei neue Agent-Einstellungen (Frontend, DB-Migration additiv): - MaxOutputTokens: hartes Ausgabelimit. CLI: CLAUDE_CODE_MAX_OUTPUT_TOKENS, API: max_tokens (statt hart 16384). 0 = aus. - DisableThinking: CLI: CLAUDE_CODE_DISABLE_THINKING=1 + MAX_THINKING_TOKENS=0; entfernt CLAUDE_CODE_EFFORT_LEVEL (Explizit-Aus schlaegt Effort). API-Pfad ohne Aequivalent (Hint im UI). Die einzigen zwei Parameter, die z.ai/GLM nachweislich honoriert (Sampling-Parameter wie temperature/top_p werden dort still verworfen). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7305a5a50f
commit
81892d6e65
13 files changed
+88
-9
No files matched your search
@@ -38,6 +38,8 @@ public partial class AnthropicService
|
||||
string mcpServers = null,
|
||||
bool useAutoContext = true,
|
||||
string effort = null,
|
||||
int maxOutputTokens = 0,
|
||||
bool disableThinking = false,
|
||||
TokenUsage seedUsage = null,
|
||||
CancellationToken workCt = default,
|
||||
CancellationToken sseCt = default)
|
||||
@@ -377,6 +379,8 @@ public partial class AnthropicService
|
||||
mcpConfigPath: mcpConfigPath,
|
||||
mcpServerNames: mcpServerList.Select(s => s.Name).ToList(),
|
||||
effort: effort,
|
||||
maxOutputTokens: maxOutputTokens,
|
||||
disableThinking: disableThinking,
|
||||
sessionId: sessionId,
|
||||
chainId: chainId,
|
||||
cancellationToken: segCts.Token
|
||||
|
||||
@@ -76,6 +76,7 @@ public partial class AnthropicService
|
||||
bool useGitHubSearch = false,
|
||||
bool useSerperSearch = false,
|
||||
string effort = null,
|
||||
int maxOutputTokens = 0,
|
||||
CancellationToken workCt = default,
|
||||
CancellationToken hardCt = default,
|
||||
CancellationToken sseCt = default,
|
||||
@@ -136,7 +137,8 @@ public partial class AnthropicService
|
||||
var payload = new Dictionary<string, object>
|
||||
{
|
||||
["model"] = modelId,
|
||||
["max_tokens"] = 16384,
|
||||
// Agent-Einstellung "Max Output Tokens" (0 = aus → bisheriger Default 16384).
|
||||
["max_tokens"] = maxOutputTokens > 0 ? maxOutputTokens : 16384,
|
||||
["messages"] = messages,
|
||||
["stream"] = true
|
||||
};
|
||||
|
||||
@@ -252,6 +252,8 @@ Für welche Plattform soll die App entwickelt werden? Web, Mobile oder Desktop?
|
||||
UseMemory = agent.UseMemory,
|
||||
WebSearchVersion = agent.WebSearchVersion,
|
||||
Effort = agent.Effort,
|
||||
MaxOutputTokens = agent.MaxOutputTokens,
|
||||
DisableThinking = agent.DisableThinking,
|
||||
MaxIterations = maxIterations,
|
||||
Agent = agent,
|
||||
Session = session,
|
||||
|
||||
@@ -136,7 +136,7 @@ public class ClaudeCliService
|
||||
catch { /* Telemetrie darf den Stream nie stören */ }
|
||||
}
|
||||
|
||||
private ProcessStartInfo CreateCliStartInfo(List<string> args, bool redirectInput = false, string effort = null, string workingDirectory = null, string modelId = null)
|
||||
private ProcessStartInfo CreateCliStartInfo(List<string> args, bool redirectInput = false, string effort = null, string workingDirectory = null, string modelId = null, int maxOutputTokens = 0, bool disableThinking = false)
|
||||
{
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
@@ -168,6 +168,23 @@ public class ClaudeCliService
|
||||
if (!string.IsNullOrEmpty(effort) && effort != "high")
|
||||
psi.Environment["CLAUDE_CODE_EFFORT_LEVEL"] = effort;
|
||||
|
||||
// Hartes Ausgabelimit (Agent-Einstellung, 0 = aus). Bremst "Wall of Text".
|
||||
// Wirkt auch über die z.ai/Anthropic-Route – dort einer der wenigen Parameter,
|
||||
// die tatsächlich honoriert werden (Sampling-Parameter wirft z.ai still weg).
|
||||
if (maxOutputTokens > 0)
|
||||
psi.Environment["CLAUDE_CODE_MAX_OUTPUT_TOKENS"] = maxOutputTokens.ToString();
|
||||
|
||||
// Thinking/Reasoning komplett abschalten (Agent-Einstellung). MAX_THINKING_TOKENS=0
|
||||
// zusätzlich, damit auch Backends ohne den Disable-Schalter kein Budget bekommen.
|
||||
if (disableThinking)
|
||||
{
|
||||
psi.Environment["CLAUDE_CODE_DISABLE_THINKING"] = "1";
|
||||
psi.Environment["MAX_THINKING_TOKENS"] = "0";
|
||||
// Effort steuert genau das Reasoning-Budget, das hier abgeschaltet wird –
|
||||
// beides gleichzeitig zu setzen wäre widersprüchlich. Explizit-Aus gewinnt.
|
||||
psi.Environment.Remove("CLAUDE_CODE_EFFORT_LEVEL");
|
||||
}
|
||||
|
||||
// z.ai / GLM: das Anthropic-kompatible z.ai-Backend NUR für diesen Prozess aktivieren.
|
||||
// Da gott pro Request einen eigenen CLI-Prozess startet, gilt das ausschließlich für
|
||||
// diesen Lauf – das Claude-OAuth-Login aller anderen Requests bleibt unberührt.
|
||||
@@ -324,6 +341,8 @@ public class ClaudeCliService
|
||||
string mcpConfigPath = null,
|
||||
List<string> mcpServerNames = null,
|
||||
string effort = null,
|
||||
int maxOutputTokens = 0,
|
||||
bool disableThinking = false,
|
||||
string sessionId = null,
|
||||
string chainId = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
@@ -489,7 +508,7 @@ public class ClaudeCliService
|
||||
|
||||
try
|
||||
{
|
||||
return await RunCliStreamingAsync(args, prompt, onEvent, cancellationToken, effortToUse, workspace, modelId, sessionId, chainId);
|
||||
return await RunCliStreamingAsync(args, prompt, onEvent, cancellationToken, effortToUse, workspace, modelId, sessionId, chainId, maxOutputTokens, disableThinking);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -510,7 +529,9 @@ public class ClaudeCliService
|
||||
string workspace = null,
|
||||
string modelId = null,
|
||||
string sessionId = null,
|
||||
string chainId = null)
|
||||
string chainId = null,
|
||||
int maxOutputTokens = 0,
|
||||
bool disableThinking = false)
|
||||
{
|
||||
var result = new CliChatResult();
|
||||
var fullOutput = new StringBuilder();
|
||||
@@ -530,7 +551,7 @@ public class ClaudeCliService
|
||||
|
||||
try
|
||||
{
|
||||
var startInfo = CreateCliStartInfo(args, redirectInput: true, effort: effort, workingDirectory: workspace, modelId: modelId);
|
||||
var startInfo = CreateCliStartInfo(args, redirectInput: true, effort: effort, workingDirectory: workspace, modelId: modelId, maxOutputTokens: maxOutputTokens, disableThinking: disableThinking);
|
||||
|
||||
using var process = new Process { StartInfo = startInfo };
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ public partial class DatabaseService
|
||||
agent.CreatedAt = now;
|
||||
agent.UpdatedAt = now;
|
||||
await conn.ExecuteAsync(@"
|
||||
INSERT INTO agents (agent_id, user_id, name, avatar, avatar_small, description, model, tool_choice, custom_commands, auto_commit, use_soul, use_identity, use_user_info, use_memory, use_auto_context, use_github_search, use_serper_search, use_web_search, web_search_version, allow_user_choice, task_instruction, effort, avatar_scale, avatar_offset_x, avatar_offset_y, is_public, is_deleted, created_at, updated_at)
|
||||
VALUES (@AgentId, @UserId, @Name, @Avatar, @AvatarSmall, @Description, @Model, @ToolChoice, @CustomCommands, @AutoCommit, @UseSoul, @UseIdentity, @UseUserInfo, @UseMemory, @UseAutoContext, @UseGitHubSearch, @UseSerperSearch, @UseWebSearch, @WebSearchVersion, @AllowUserChoice, @TaskInstruction, @Effort, @AvatarScale, @AvatarOffsetX, @AvatarOffsetY, @IsPublic, 0, @CreatedAt, @UpdatedAt)
|
||||
INSERT INTO agents (agent_id, user_id, name, avatar, avatar_small, description, model, tool_choice, custom_commands, auto_commit, use_soul, use_identity, use_user_info, use_memory, use_auto_context, use_github_search, use_serper_search, use_web_search, web_search_version, allow_user_choice, task_instruction, effort, max_output_tokens, disable_thinking, avatar_scale, avatar_offset_x, avatar_offset_y, is_public, is_deleted, created_at, updated_at)
|
||||
VALUES (@AgentId, @UserId, @Name, @Avatar, @AvatarSmall, @Description, @Model, @ToolChoice, @CustomCommands, @AutoCommit, @UseSoul, @UseIdentity, @UseUserInfo, @UseMemory, @UseAutoContext, @UseGitHubSearch, @UseSerperSearch, @UseWebSearch, @WebSearchVersion, @AllowUserChoice, @TaskInstruction, @Effort, @MaxOutputTokens, @DisableThinking, @AvatarScale, @AvatarOffsetX, @AvatarOffsetY, @IsPublic, 0, @CreatedAt, @UpdatedAt)
|
||||
", agent);
|
||||
return agent;
|
||||
}
|
||||
@@ -56,6 +56,7 @@ public partial class DatabaseService
|
||||
custom_commands = @CustomCommands, auto_commit = @AutoCommit,
|
||||
use_soul = @UseSoul, use_identity = @UseIdentity, use_user_info = @UseUserInfo, use_memory = @UseMemory, use_auto_context = @UseAutoContext, use_github_search = @UseGitHubSearch, use_serper_search = @UseSerperSearch, use_web_search = @UseWebSearch, web_search_version = @WebSearchVersion,
|
||||
allow_user_choice = @AllowUserChoice, task_instruction = @TaskInstruction, effort = @Effort,
|
||||
max_output_tokens = @MaxOutputTokens, disable_thinking = @DisableThinking,
|
||||
avatar_scale = @AvatarScale, avatar_offset_x = @AvatarOffsetX, avatar_offset_y = @AvatarOffsetY,
|
||||
is_public = @IsPublic, updated_at = @UpdatedAt
|
||||
WHERE agent_id = @AgentId AND user_id = @UserId
|
||||
|
||||
@@ -201,6 +201,8 @@ public partial class DatabaseService
|
||||
TryAddColumn(conn, "messages", "tag", "TEXT");
|
||||
TryAddColumn(conn, "agents", "effort", "TEXT NOT NULL DEFAULT ''");
|
||||
TryAddColumn(conn, "chains", "effort", "TEXT NOT NULL DEFAULT ''");
|
||||
TryAddColumn(conn, "agents", "max_output_tokens", "INTEGER NOT NULL DEFAULT 0");
|
||||
TryAddColumn(conn, "agents", "disable_thinking", "INTEGER NOT NULL DEFAULT 0");
|
||||
TryAddColumn(conn, "sessions", "multi_model_mode", "TEXT");
|
||||
TryAddColumn(conn, "sessions", "panel_agent_ids", "TEXT");
|
||||
TryAddColumn(conn, "sessions", "moa_layers", "INTEGER NOT NULL DEFAULT 2");
|
||||
|
||||
Reference in new issue
Block a user