fix: the take-home sheet gives a reasoning model room to think and still write
The 1,800-token ceiling was spent entirely on hidden reasoning, so the sheet came back empty. Same budget as the answer path now, with one retry at a larger budget if the reply is still blank. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dv6sqaY6Vq3ChZHMem3cnU
This commit is contained in:
parent
012a06c107
commit
1d58e5b509
1 changed files with 15 additions and 6 deletions
|
|
@ -27,13 +27,22 @@ async function generatePatientTakehome(opts) {
|
|||
{ role: 'system', content: behavior },
|
||||
{ role: 'user', content: 'Clinical answer:\n' + answer + '\n\nWrite the patient take-home sheet now.' }
|
||||
];
|
||||
// The budget covers the model's hidden reasoning as well as the sheet. At
|
||||
// 1,800 tokens a reasoning model (DeepSeek flash spent 8,400 characters
|
||||
// thinking about a discharge sheet) hit the limit before writing a word and
|
||||
// the user saw "empty take-home sheet". Same ceiling as the answer path,
|
||||
// and one retry with more room when the reply still comes back empty.
|
||||
var ai;
|
||||
try {
|
||||
ai = await opts.callAI(messages, assistantGenerationOptions({ model: opts.model || undefined, temperature: 0.15, maxTokens: 1800 }));
|
||||
} catch (err) {
|
||||
err = err || new Error('Take-home generation failed');
|
||||
if (!err.statusCode && !err.response) err.statusCode = 502;
|
||||
throw err;
|
||||
var budgets = [5000, 9000];
|
||||
for (var attempt = 0; attempt < budgets.length; attempt++) {
|
||||
try {
|
||||
ai = await opts.callAI(messages, assistantGenerationOptions({ model: opts.model || undefined, temperature: 0.15, maxTokens: budgets[attempt] }));
|
||||
} catch (err) {
|
||||
err = err || new Error('Take-home generation failed');
|
||||
if (!err.statusCode && !err.response) err.statusCode = 502;
|
||||
throw err;
|
||||
}
|
||||
if (ai && String(ai.content || '').trim()) break;
|
||||
}
|
||||
var text = stripCitationTokens(ai && ai.content || '').slice(0, MAX_RESULT_CHARS);
|
||||
if (!text) { e = new Error('The model returned an empty take-home sheet'); e.statusCode = 502; throw e; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue