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
@@ -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 };
|
||||
|
||||
|
||||
Reference in new issue
Block a user