mirror of
https://github.com/facebook/rocksdb.git
synced 2026-07-07 14:47:40 +08:00
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:
committed by
meta-codesync[bot]
parent
795f3bd61f
commit
46ce1a03a9
@@ -531,7 +531,9 @@ jobs:
|
|||||||
core.warning(
|
core.warning(
|
||||||
`Could not parse classifier output: ${error.message}`);
|
`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(
|
core.info(
|
||||||
`Complexity classified as: ${label} ` +
|
`Complexity classified as: ${label} ` +
|
||||||
`-> MAX_THINKING_TOKENS=${budget}`
|
`-> MAX_THINKING_TOKENS=${budget}`
|
||||||
@@ -1115,9 +1117,19 @@ jobs:
|
|||||||
}
|
}
|
||||||
const override = (process.env.OVERRIDE || '').trim();
|
const override = (process.env.OVERRIDE || '').trim();
|
||||||
if (override && /^\d+$/.test(override)) {
|
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('label', 'override');
|
||||||
core.setOutput('tokens', override);
|
core.setOutput('tokens', budget);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let label = 'complex';
|
let label = 'complex';
|
||||||
@@ -1135,7 +1147,9 @@ jobs:
|
|||||||
core.warning(
|
core.warning(
|
||||||
`Could not parse classifier output: ${error.message}`);
|
`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(
|
core.info(
|
||||||
`Complexity classified as: ${label} ` +
|
`Complexity classified as: ${label} ` +
|
||||||
`-> MAX_THINKING_TOKENS=${budget}`
|
`-> MAX_THINKING_TOKENS=${budget}`
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ on:
|
|||||||
- claude-sonnet-4-6
|
- claude-sonnet-4-6
|
||||||
default: claude-opus-4-6
|
default: claude-opus-4-6
|
||||||
thinking_budget:
|
thinking_budget:
|
||||||
description: Override MAX_THINKING_TOKENS (blank = auto-classify)
|
description: Override MAX_THINKING_TOKENS (blank = auto-classify, capped at 24000)
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
default: ""
|
default: ""
|
||||||
|
|||||||
Reference in New Issue
Block a user