Skip to content

Commit b7996d2

Browse files
committed
Generalize starvation note for the no-text/no-function-call case to also cover stuck-loop withholding -- part 5
1 parent 7be69e9 commit b7996d2

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

connectors/frontend/agent.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,10 @@ export async function runDesignAgent({ owner, repo, branch, task, max_steps = FR
370370
// why a run stopping here never actually surfaced a usable
371371
// resume_run_id despite the message implying resumability.
372372
await saveState(step - 1);
373-
const starvationNote = isFinalStep && candidate.finishReason === "MALFORMED_FUNCTION_CALL"
374-
? ` This was the final allowed step, which never includes tools -- but the model attempted a function call anyway, which Gemini rejects as malformed when no tools are available. This usually means the task needed more steps than max_steps (${cappedSteps}) allowed. Retry with a higher max_steps.`
373+
const starvationNote = withholdTools && candidate.finishReason === "MALFORMED_FUNCTION_CALL"
374+
? (stuckLoopForce
375+
? ` Tools were withheld this step because the agent appeared stuck repeating the same call(s) for ${consecutiveAllRepeatSteps} consecutive steps, but the model attempted a function call anyway, which Gemini rejects as malformed when no tools are available.`
376+
: ` This was the final allowed step, which never includes tools -- but the model attempted a function call anyway, which Gemini rejects as malformed when no tools are available. This usually means the task needed more steps than max_steps (${cappedSteps}) allowed. Retry with a higher max_steps.`)
375377
: "";
376378
return {
377379
answer: `(Gemini stopped without a final answer -- finishReason: ${candidate.finishReason || "unknown"})${starvationNote} ${transcript.length} tool call(s) already completed this run are saved. Call again with resume_run_id: "${runId}" to continue instead of starting over. Checkpoint expires in 1 hour.`,

0 commit comments

Comments
 (0)