Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public async Task<InjectionCheckResult> 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.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down