Skip to content

StopWhen

Namespace: Vercel.AI

public static class StopWhen

Stop-condition factories. Maps to isStepCount, hasToolCall, and isLoopFinished.

Inheritance: object

View source

public static StopCondition HasToolCall(params string[] toolNames)

Stops when any of <code class=“paramref”>toolNames</code> was called on the latest step.

Parameters

Name Type Description
toolNames string[]

Returns: StopCondition

View source

public static StopCondition IsLoopFinished()

A stop condition that never stops the loop. The loop still ends when a step does not call a tool.

Returns: StopCondition

View source

public static StopCondition IsStepCount(int count)

Stops when the number of completed steps equals <code class=“paramref”>count</code>.

Parameters

Name Type Description
count int

Returns: StopCondition

View source

IsStopConditionMet(IReadOnlyList<Func<IReadOnlyList<StepResult>, Task<bool>>>, IReadOnlyList<StepResult>)

Section titled “IsStopConditionMet(IReadOnlyList<Func<IReadOnlyList<StepResult>, Task<bool>>>, IReadOnlyList<StepResult>)”
public static Task<bool> IsStopConditionMet(IReadOnlyList<Func<IReadOnlyList<StepResult>, Task<bool>>> stopConditions, IReadOnlyList<StepResult> steps)

Returns true when any stop condition returns true. Maps to isStopConditionMet.

Parameters

Name Type Description
stopConditions IReadOnlyList<Func<IReadOnlyList<StepResult>, Task<bool>>>
steps IReadOnlyList<StepResult>

Returns: Task<bool>

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product