eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 786 B
JavaScript
import{derivePendingState}from"#execution/session/pending-turn-state.js";async function runModelCallBatch(e){let t=e.initialSession,n=e.initialInput,r=0;for(;;){let i=await e.runStep({firstCall:r===0,session:t,stepInput:n});if(r++,e.steeringSignal?.aborted===!0||i.steered===!0||!shouldRunAnotherModelCall({completedModelCalls:r,modelCallsPerStep:e.modelCallsPerStep,result:i}))return i;t=i.session,n=void 0}}function shouldRunAnotherModelCall(e){if(e.completedModelCalls>=e.modelCallsPerStep||typeof e.result.next!=`function`||e.result.backgroundTaskSession!==void 0||e.result.backgroundTasks!==void 0)return!1;let t=derivePendingState(e.result.session);return!t.hasPendingAuthorization&&!t.hasPendingInputBatch&&(t.pendingCoordinationCallIds?.length??0)===0}export{runModelCallBatch};