From 0d771c7ee34daa92e3b4ed15526cdb71fdf592ae Mon Sep 17 00:00:00 2001 From: Julian Lechner Date: Fri, 25 Sep 2026 17:52:35 +0200 Subject: [PATCH] chore(prompt-budget): separate soft target from hard limit --- adapters/prompt-budget-baseline.json | 2 +- adapters/prompt-budget-baseline.tsv | 4 ++-- scripts/commands/prompt-budget.ps1 | 6 +++--- scripts/commands/prompt-budget.sh | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/adapters/prompt-budget-baseline.json b/adapters/prompt-budget-baseline.json index 6d678b5..5e360f9 100644 --- a/adapters/prompt-budget-baseline.json +++ b/adapters/prompt-budget-baseline.json @@ -1 +1 @@ -{"Claude permanent context":6000,"Codex permanent context":6000,"Claude permanent context absolute limit":6900,"Codex permanent context absolute limit":6900} +{"Claude permanent context":4000,"Codex permanent context":4000,"Claude permanent context absolute limit":6000,"Codex permanent context absolute limit":6000} diff --git a/adapters/prompt-budget-baseline.tsv b/adapters/prompt-budget-baseline.tsv index edfc7cc..237718e 100644 --- a/adapters/prompt-budget-baseline.tsv +++ b/adapters/prompt-budget-baseline.tsv @@ -1,2 +1,2 @@ -Claude 6000 6900 -Codex 6000 6900 +Claude 4000 6000 +Codex 4000 6000 diff --git a/scripts/commands/prompt-budget.ps1 b/scripts/commands/prompt-budget.ps1 index c0eed58..7d8a3e0 100644 --- a/scripts/commands/prompt-budget.ps1 +++ b/scripts/commands/prompt-budget.ps1 @@ -24,11 +24,11 @@ if ($old) { $previous = [double]$old.($row.Name) $absolute = [double]$old.(($row.Name + ' absolute limit')) $baselineValues[$row.Name] = @($previous, $absolute) - if ($previous -gt 0 -and $row.Bytes -gt $previous * 1.15) { $fail = $true; Write-Error "Prompt budget relative limit failed: $($row.Name) $($row.Bytes) bytes (baseline $previous, limit 15%)." } - if ($absolute -gt 0 -and $row.Bytes -gt $absolute) { $fail = $true; Write-Error "Prompt budget absolute limit failed: $($row.Name) $($row.Bytes) bytes (absolute limit $absolute)." } + if ($previous -gt 0 -and $row.Bytes -gt $previous * 1.15) { Write-Warning "Prompt budget soft target exceeded: $($row.Name) $($row.Bytes) bytes (target $previous, 15% tolerance)." } + if ($absolute -gt 0 -and $row.Bytes -gt $absolute) { $fail = $true; Write-Error "Prompt budget hard limit failed: $($row.Name) $($row.Bytes) bytes (hard limit $absolute)." } } } -if ($Summary) { Write-Output 'Prompt Budget'; foreach ($row in $rows | Select-Object -First 2) { $limits = $baselineValues[$row.Name]; $base = if($limits){$limits[0]}else{'-'}; $absolute = if($limits){$limits[1]}else{'-'}; Write-Output ('{0,-28} {1,8} bytes baseline {2} relative 115% absolute {3}' -f $row.Name,$row.Bytes,$base,$absolute) }; $rows | Select-Object -Skip 2 | ForEach-Object { Write-Output ('{0,-28} {1,8} bytes {2,6} tokens' -f $_.Name,$_.Bytes,$_.Tokens) } } else { $rows | ForEach-Object { Write-Output ('{0}: {1} bytes / {2} tokens' -f $_.Name,$_.Bytes,$_.Tokens) } } +if ($Summary) { Write-Output 'Prompt Budget'; foreach ($row in $rows | Select-Object -First 2) { $limits = $baselineValues[$row.Name]; $base = if($limits){$limits[0]}else{'-'}; $absolute = if($limits){$limits[1]}else{'-'}; Write-Output ('{0,-28} {1,8} bytes soft target {2} hard limit {3}' -f $row.Name,$row.Bytes,$base,$absolute) }; $rows | Select-Object -Skip 2 | ForEach-Object { Write-Output ('{0,-28} {1,8} bytes {2,6} tokens' -f $_.Name,$_.Bytes,$_.Tokens) } } else { $rows | ForEach-Object { Write-Output ('{0}: {1} bytes / {2} tokens' -f $_.Name,$_.Bytes,$_.Tokens) } } & python (Join-Path $root 'scripts/lib/prompt-inventory.py') --home ([Environment]::GetFolderPath('UserProfile')) if ($LASTEXITCODE -ne 0) { throw 'Prompt inventory failed.' } if ($fail) { exit 1 } diff --git a/scripts/commands/prompt-budget.sh b/scripts/commands/prompt-budget.sh index 7193689..b1febda 100644 --- a/scripts/commands/prompt-budget.sh +++ b/scripts/commands/prompt-budget.sh @@ -16,11 +16,11 @@ if [ -f "$root/adapters/prompt-budget-baseline.tsv" ]; then current=$([ "$name" = Claude ] && printf '%s' "$claude" || printf '%s' "$codex") [ "$name" = Claude ] && claude_baseline=$old && claude_absolute=$absolute [ "$name" = Codex ] && codex_baseline=$old && codex_absolute=$absolute - if awk -v n="$current" -v o="$old" 'BEGIN { exit !(o > 0 && n > o * 1.15) }'; then printf 'Prompt budget relative limit failed: %s %s bytes (baseline %s, limit 15%%).\n' "$name" "$current" "$old" >&2; fail=true; fi - if awk -v n="$current" -v a="$absolute" 'BEGIN { exit !(a > 0 && n > a) }'; then printf 'Prompt budget absolute limit failed: %s %s bytes (absolute limit %s).\n' "$name" "$current" "$absolute" >&2; fail=true; fi + if awk -v n="$current" -v o="$old" 'BEGIN { exit !(o > 0 && n > o * 1.15) }'; then printf 'Prompt budget soft target exceeded: %s %s bytes (target %s, 15%% tolerance).\n' "$name" "$current" "$old" >&2; fi + if awk -v n="$current" -v a="$absolute" 'BEGIN { exit !(a > 0 && n > a) }'; then printf 'Prompt budget hard limit failed: %s %s bytes (hard limit %s).\n' "$name" "$current" "$absolute" >&2; fail=true; fi done < "$root/adapters/prompt-budget-baseline.tsv" fi -if [ "$summary" = true ]; then printf 'Prompt Budget\nClaude permanent context %8s bytes baseline %s relative 115%% absolute %s\nCodex permanent context %8s bytes baseline %s relative 115%% absolute %s\nClaude skill files (lazy) %8s bytes %6s tokens\nLargest lazy rule %8s bytes %6s tokens\n' "$claude" "$claude_baseline" "$claude_absolute" "$codex" "$codex_baseline" "$codex_absolute" "$skills" "$(tokens "$skills")" "$lazy" "$(tokens "$lazy")"; else printf 'Prompt budget: Claude %s bytes, Codex %s bytes, skills %s bytes, largest lazy rule %s bytes\n' "$claude" "$codex" "$skills" "$lazy"; fi +if [ "$summary" = true ]; then printf 'Prompt Budget\nClaude permanent context %8s bytes soft target %s hard limit %s\nCodex permanent context %8s bytes soft target %s hard limit %s\nClaude skill files (lazy) %8s bytes %6s tokens\nLargest lazy rule %8s bytes %6s tokens\n' "$claude" "$claude_baseline" "$claude_absolute" "$codex" "$codex_baseline" "$codex_absolute" "$skills" "$(tokens "$skills")" "$lazy" "$(tokens "$lazy")"; else printf 'Prompt budget: Claude %s bytes, Codex %s bytes, skills %s bytes, largest lazy rule %s bytes\n' "$claude" "$codex" "$skills" "$lazy"; fi python3 "$root/scripts/lib/prompt-inventory.py" --home "${HOME:?HOME is required}" -$fail && { printf 'Prompt budget: permanent context increased by more than 15 percent.\n' >&2; exit 1; } +$fail && { printf 'Prompt budget: permanent context exceeded hard limit.\n' >&2; exit 1; } exit 0