class PendingStep

A generation step handed to agent middleware before the model is called.

Methods

__construct(int $number, bool $isFinalStep, string $provider, string $model, string|null $instructions, array $messages, array $tools, array|null $schema, TextGenerationOptions|null $options, array $steps = [], TextUsage $usage = new TextUsage(), int|null $timeout = null, string|null $invocationId = null)

Create a generation step for agent middleware.

bool
isFirstStep()

Determine whether this is the first generation step.

withModel(string $model)

Create a copy using a different model.

withInstructions(string|null $instructions)

Create a copy using different instructions.

withMessages(iterable $messages)

Replace the history sent for this step only; the run's history still grows from the original.

withTools(iterable $tools)

Create a copy using the given tools.

onlyTools(string ...$names)

Create a copy containing only the named tools.

withoutTools(string ...$names)

Create a copy excluding the named tools.

withToolChoice(ToolChoice|string|array|null $toolChoice)

Create a copy using a different tool choice.

withMaxTokens(int|null $maxTokens)

Create a copy using a different maximum token count.

withProviderOptions(array $providerOptions)

Create a copy using the given provider options.

withOptions(TextGenerationOptions $options)

Create a copy using the given options.

resolvedOptions()

Get the step options, creating an empty set when none were provided.

with(array $overrides)

Create a copy with the given property overrides.

Details

at line 29
__construct(int $number, bool $isFinalStep, string $provider, string $model, string|null $instructions, array $messages, array $tools, array|null $schema, TextGenerationOptions|null $options, array $steps = [], TextUsage $usage = new TextUsage(), int|null $timeout = null, string|null $invocationId = null)

Create a generation step for agent middleware.

Parameters

int $number
bool $isFinalStep
string $provider
string $model
string|null $instructions
array $messages
array $tools
array|null $schema
TextGenerationOptions|null $options
array $steps

the steps completed so far in this run

TextUsage $usage

the usage accumulated by the completed steps

int|null $timeout
string|null $invocationId

at line 49
bool isFirstStep()

Determine whether this is the first generation step.

Return Value

bool

at line 57
PendingStep withModel(string $model)

Create a copy using a different model.

Parameters

string $model

Return Value

PendingStep

at line 65
PendingStep withInstructions(string|null $instructions)

Create a copy using different instructions.

Parameters

string|null $instructions

Return Value

PendingStep

at line 75
PendingStep withMessages(iterable $messages)

Replace the history sent for this step only; the run's history still grows from the original.

Parameters

iterable $messages

Return Value

PendingStep

at line 85
PendingStep withTools(iterable $tools)

Create a copy using the given tools.

Parameters

iterable $tools

Return Value

PendingStep

at line 93
PendingStep onlyTools(string ...$names)

Create a copy containing only the named tools.

Parameters

string ...$names

Return Value

PendingStep

at line 101
PendingStep withoutTools(string ...$names)

Create a copy excluding the named tools.

Parameters

string ...$names

Return Value

PendingStep

at line 111
PendingStep withToolChoice(ToolChoice|string|array|null $toolChoice)

Create a copy using a different tool choice.

Parameters

ToolChoice|string|array|null $toolChoice

Return Value

PendingStep

at line 121
PendingStep withMaxTokens(int|null $maxTokens)

Create a copy using a different maximum token count.

Parameters

int|null $maxTokens

Return Value

PendingStep

at line 131
PendingStep withProviderOptions(array $providerOptions)

Create a copy using the given provider options.

Parameters

array $providerOptions

Return Value

PendingStep

at line 141
protected PendingStep withOptions(TextGenerationOptions $options)

Create a copy using the given options.

Parameters

TextGenerationOptions $options

Return Value

PendingStep

at line 149
protected TextGenerationOptions resolvedOptions()

Get the step options, creating an empty set when none were provided.

Return Value

TextGenerationOptions

at line 159
protected PendingStep with(array $overrides)

Create a copy with the given property overrides.

Parameters

array $overrides

Return Value

PendingStep