본문으로 건너뛰기

타입 별칭: AgentLoopStrategy

type AgentLoopStrategy = (state) => boolean;

정의 위치: packages/ai/src/types.ts:964

에이전트 루프를 계속 실행할지 결정하는 전략 함수입니다.

매개변수

state

AgentLoopState

에이전트 루프의 현재 상태입니다.

반환값

boolean

루프를 계속하려면 true, 중지하려면 false를 반환합니다.

예시

// Continue for up to 5 iterations (model turns, not tool calls)
const strategy: AgentLoopStrategy = ({ iterationCount }) => iterationCount < 5;
// Cap total tool calls across the run (or use middleware onShouldContinue)
const byTools: AgentLoopStrategy = ({ toolCallCount }) => toolCallCount < 20;