Spaces:
Sleeping
Sleeping
| // S515 — estratto da agentLoop.ts: fast-exit check iter===0 per risposte dirette | |
| // S432-FIX2/FIX2b: evita il gauntlet retry per query semplici → risposta in <2s su iPhone. | |
| import type { AgentStep } from "../storage"; | |
| export interface FastExitParams { | |
| iter: number; | |
| steps: AgentStep[]; | |
| isCodeTask: boolean; | |
| finalText: string; | |
| isDirectAnswer: boolean; | |
| } | |
| /** | |
| * Verifica se la risposta soddisfa i criteri di fast-exit (iter 0, risposta diretta). | |
| * Restituisce `shouldReturn: true` se il caller deve emettere la risposta e fare `return`. | |
| * | |
| * - FIX2: iter===0, nessun tool chiamato, query non-code, risposta ≥30 chars | |
| * - FIX2b: iter===0, isDirectAnswer===true, query non-code, risposta ≥20 chars | |
| */ | |
| export function checkFastExit(p: FastExitParams): { shouldReturn: boolean } { | |
| // S432-FIX2: iter 0, nessun tool, query non-code | |
| if (p.iter === 0 && p.steps.length === 0 && !p.isCodeTask && p.finalText.length >= 30) { | |
| return { shouldReturn: true }; | |
| } | |
| // S432-FIX2b: isDirectAnswer=true, iter 0, query non-code (soglia più bassa) | |
| if (p.iter === 0 && p.isDirectAnswer && !p.isCodeTask && p.finalText.length >= 20) { | |
| return { shouldReturn: true }; | |
| } | |
| return { shouldReturn: false }; | |
| } | |