Cap Claude thinking budget (#14731)

Summary:
### Motivation
Claude's auto review workflow classifies the PR as complex and sets `MAX_THINKING_TOKENS`=**32000** in `.github/workflows/ai-review-analysis.yml:534`. The Claude action then sends a request where `thinking.budget_tokens` is **32000**, but the request `max_tokens` is not greater than that, so Anthropic rejects it before the review starts ([example](https://github.com/facebook/rocksdb/actions/runs/25691112276/job/75427435133)).

### Fix
Reduce the "complex" thinking budget from **32000** to **24000** tokens and clamps manual overrides to the same ceiling, preventing the thinking budget from exceeding or equalling the action's effective `max_tokens`. 24k is still generous — enough for deep reasoning on complex PRs while guaranteeing the model can emit the formatted review.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/14731

Reviewed By: xingbowang

Differential Revision: D104749426

Pulled By: mszeszko-meta

fbshipit-source-id: bf94d0f50e7c2c9bc9e4d4cdffd61087d739018a
This commit is contained in:
Maciej Szeszko
2026-05-11 17:45:43 -07:00
committed by meta-codesync[bot]
parent 795f3bd61f
commit 46ce1a03a9
2 changed files with 19 additions and 5 deletions
+18 -4
View File
@@ -531,7 +531,9 @@ jobs:
core.warning(
`Could not parse classifier output: ${error.message}`);
}
const budget = label === 'simple' ? '16000' : '32000';
// Keep Claude's thinking budget below the action's effective
// max_tokens so the API has room for the final review text.
const budget = label === 'simple' ? '16000' : '24000';
core.info(
`Complexity classified as: ${label} ` +
`-> MAX_THINKING_TOKENS=${budget}`
@@ -1115,9 +1117,19 @@ jobs:
}
const override = (process.env.OVERRIDE || '').trim();
if (override && /^\d+$/.test(override)) {
core.info(`Using thinking_budget override: ${override}`);
const maxSafeBudget = 24000;
const requested = parseInt(override, 10);
const budget = Math.min(requested, maxSafeBudget).toString();
if (budget !== override) {
core.info(
`Clamping thinking_budget override from ${override} ` +
`to ${budget} so max_tokens can exceed thinking tokens.`
);
} else {
core.info(`Using thinking_budget override: ${budget}`);
}
core.setOutput('label', 'override');
core.setOutput('tokens', override);
core.setOutput('tokens', budget);
return;
}
let label = 'complex';
@@ -1135,7 +1147,9 @@ jobs:
core.warning(
`Could not parse classifier output: ${error.message}`);
}
const budget = label === 'simple' ? '16000' : '32000';
// Keep Claude's thinking budget below the action's effective
// max_tokens so the API has room for the final review text.
const budget = label === 'simple' ? '16000' : '24000';
core.info(
`Complexity classified as: ${label} ` +
`-> MAX_THINKING_TOKENS=${budget}`
+1 -1
View File
@@ -34,7 +34,7 @@ on:
- claude-sonnet-4-6
default: claude-opus-4-6
thinking_budget:
description: Override MAX_THINKING_TOKENS (blank = auto-classify)
description: Override MAX_THINKING_TOKENS (blank = auto-classify, capped at 24000)
required: false
type: string
default: ""