diff --git a/source/Calamari/AiAgent/ClaudeCodeBehaviour/InjectionCheck/AnthropicInjectionCheckClient.cs b/source/Calamari/AiAgent/ClaudeCodeBehaviour/InjectionCheck/AnthropicInjectionCheckClient.cs index 637fc1f68..5cb3bdea8 100644 --- a/source/Calamari/AiAgent/ClaudeCodeBehaviour/InjectionCheck/AnthropicInjectionCheckClient.cs +++ b/source/Calamari/AiAgent/ClaudeCodeBehaviour/InjectionCheck/AnthropicInjectionCheckClient.cs @@ -63,6 +63,9 @@ public async Task AnalyzeAsync(string systemPrompt, string if (string.Equals(message.StopReason, "refusal", StringComparison.OrdinalIgnoreCase)) throw new InjectionCheckException("The injection-check model refused the request."); + if (string.Equals(message.StopReason, "max_tokens", StringComparison.OrdinalIgnoreCase)) + throw new InjectionCheckException($"The injection-check model ran out of output tokens after {message.Usage?.OutputTokens?.ToString() ?? "unknown"} tokens (max tokens is {options.MaxTokens})."); + var verdictJson = message.Content?.FirstOrDefault(b => b.Type == "text")?.Text; if (string.IsNullOrWhiteSpace(verdictJson)) throw new InjectionCheckException("The injection-check model returned no verdict content."); diff --git a/source/Calamari/AiAgent/ClaudeCodeBehaviour/InjectionCheck/InjectionCheckOptions.cs b/source/Calamari/AiAgent/ClaudeCodeBehaviour/InjectionCheck/InjectionCheckOptions.cs index ed2e833f9..c7d55d451 100644 --- a/source/Calamari/AiAgent/ClaudeCodeBehaviour/InjectionCheck/InjectionCheckOptions.cs +++ b/source/Calamari/AiAgent/ClaudeCodeBehaviour/InjectionCheck/InjectionCheckOptions.cs @@ -8,8 +8,8 @@ namespace Calamari.AiAgent.ClaudeCodeBehaviour.InjectionCheck; // promoted to step configuration later by setting the matching Octopus.Action.Claude.* variable. public class InjectionCheckOptions { - const string DefaultModel = "claude-haiku-4-5"; - const int DefaultMaxTokens = 1024; + const string DefaultModel = "claude-haiku-5-5"; + const int DefaultMaxTokens = 2048; const int DefaultMaxInputCharacters = 200_000; public bool Enabled { get; init; } diff --git a/source/Calamari/AiAgent/ClaudeCodeBehaviour/InjectionCheck/PromptInjectionGuard.cs b/source/Calamari/AiAgent/ClaudeCodeBehaviour/InjectionCheck/PromptInjectionGuard.cs index 8678ea48a..74486274c 100644 --- a/source/Calamari/AiAgent/ClaudeCodeBehaviour/InjectionCheck/PromptInjectionGuard.cs +++ b/source/Calamari/AiAgent/ClaudeCodeBehaviour/InjectionCheck/PromptInjectionGuard.cs @@ -74,6 +74,7 @@ public async Task CheckAsync(string workingDir, string prompt, string apiToken, void ReportUsage(InjectionCheckResult result) { + log.Verbose($"Prompt-injection check used {result.InputTokens?.ToString() ?? "unknown"} input tokens and {result.OutputTokens?.ToString() ?? "unknown"} output tokens (model '{result.Model}')."); usageReporter.AddModelUsage(new[] { new ClaudeCodeModelUsage