trait GeneratesText

Traits

Methods

array|null
resumableApprovalFor(AgentPrompt $prompt, array $messages, array $tools)

Get the tool approval to resume with, unless a faked agent has no paused approval to resume.

array
withoutForeignReplayBlocks(array $messages)

Replace another provider's raw paused-turn replay state with its generic mapping, since raw blocks are only valid verbatim on the provider that produced them.

bool
resumesApproval(AgentPrompt $prompt, array $messages, array $tools)

Determine whether the prompt is a resume that runs the approved tools.

Closure|null
approvalResultRecorderFor(AgentPrompt $prompt, array|null $approval, Collection|null $resolvedApprovalResults)

Get a callback that captures a resume's resolved approval results for its completion event.

prompt(AgentPrompt $prompt)

Invoke the given agent.

array
gatherMiddlewareFor(Agent $agent)

Gather the internal run middleware for the given agent.

array
resolveTools(AgentPrompt $prompt)

Resolve the tools for the given prompt, wrapping any agent instances as tools.

array
declaredTools(Agent $agent)

Get the tools the agent declares, including the tool that loads its skills.

mixed
resolveTool(mixed $tool)

Resolve a tool returned by the agent into a native tool instance when needed.

prepareRunContext(string $invocationId, AgentPrompt $prompt, array|null $approval)

Build the run's context, letting a remembered conversation claim and record the approval decisions the run resumes.

runContextFor(string $invocationId, AgentPrompt $prompt)

Build the context that identifies this run and reports its step and tool events.

void
recordAgentFailure(string $invocationId, AgentPrompt $prompt, Throwable $exception, bool $retryable = true)

Dispatch the terminal failure event for a run, unless the caller may still retry it against another provider.

void
throwIfNotResumable(AgentPrompt $prompt)

Throw when a pause has surfaced on a prompt that cannot be resumed from persisted or replayed history.

Details

protected array|null resumableApprovalFor(AgentPrompt $prompt, array $messages, array $tools)

Get the tool approval to resume with, unless a faked agent has no paused approval to resume.

Parameters

AgentPrompt $prompt
array $messages
array $tools

Return Value

array|null

protected array withoutForeignReplayBlocks(array $messages)

Replace another provider's raw paused-turn replay state with its generic mapping, since raw blocks are only valid verbatim on the provider that produced them.

Parameters

array $messages

Return Value

array

protected bool resumesApproval(AgentPrompt $prompt, array $messages, array $tools)

Determine whether the prompt is a resume that runs the approved tools.

Parameters

AgentPrompt $prompt
array $messages
array $tools

Return Value

bool

protected Closure|null approvalResultRecorderFor(AgentPrompt $prompt, array|null $approval, Collection|null $resolvedApprovalResults)

Get a callback that captures a resume's resolved approval results for its completion event.

Parameters

AgentPrompt $prompt
array|null $approval
Collection|null $resolvedApprovalResults

Return Value

Closure|null

at line 53
AgentResponse prompt(AgentPrompt $prompt)

Invoke the given agent.

Parameters

AgentPrompt $prompt

Return Value

AgentResponse

at line 175
protected array gatherMiddlewareFor(Agent $agent)

Gather the internal run middleware for the given agent.

Parameters

Agent $agent

Return Value

array

at line 193
protected array resolveTools(AgentPrompt $prompt)

Resolve the tools for the given prompt, wrapping any agent instances as tools.

Parameters

AgentPrompt $prompt

Return Value

array

at line 204
protected array declaredTools(Agent $agent)

Get the tools the agent declares, including the tool that loads its skills.

Parameters

Agent $agent

Return Value

array

at line 214
protected mixed resolveTool(mixed $tool)

Resolve a tool returned by the agent into a native tool instance when needed.

Parameters

mixed $tool

Return Value

mixed

at line 233
protected RunContext prepareRunContext(string $invocationId, AgentPrompt $prompt, array|null $approval)

Build the run's context, letting a remembered conversation claim and record the approval decisions the run resumes.

Parameters

string $invocationId
AgentPrompt $prompt
array|null $approval

Return Value

RunContext

at line 257
protected RunContext runContextFor(string $invocationId, AgentPrompt $prompt)

Build the context that identifies this run and reports its step and tool events.

Parameters

string $invocationId
AgentPrompt $prompt

Return Value

RunContext

at line 268
protected void recordAgentFailure(string $invocationId, AgentPrompt $prompt, Throwable $exception, bool $retryable = true)

Dispatch the terminal failure event for a run, unless the caller may still retry it against another provider.

Parameters

string $invocationId
AgentPrompt $prompt
Throwable $exception
bool $retryable

Return Value

void

at line 285
protected void throwIfNotResumable(AgentPrompt $prompt)

Throw when a pause has surfaced on a prompt that cannot be resumed from persisted or replayed history.

Parameters

AgentPrompt $prompt

Return Value

void