class AgentPrompt extends Prompt

Properties

Agent $agent
Collection $attachments
null|Message> $messages

The ad-hoc message history to send ahead of the prompt.

null|Agent|ProviderTool|Tool> $tools

The tools available for this run, or null to use the tools the agent declares.

array<int, object|string> $middleware

The runtime middleware for this run, wrapping the agent's declared middleware.

int|null $timeout
string|null $invocationId
string|null $parentInvocationId
string|null $parentToolInvocationId
protected bool $isFinalAttempt
protected RunContext|null $runContext
protected bool $toolWasInvoked
protected ConversationSelection|null $conversationSelection
protected null|Message> $conversationMessages
protected bool $streaming
protected PendingConversationTitle|null $pendingConversationTitle
protected null|Closure): mixed $contextRunner

Methods

__construct(Agent $agent, string $prompt, Collection|array $attachments, TextProvider $provider, string $model, int|null $timeout = null, string|null $invocationId = null, Decisions|null $approvalDecisions = null, string|null $parentInvocationId = null, string|null $parentToolInvocationId = null, bool $isFinalAttempt = true, array|null $messages = null, array|null $tools = null, Closure|null $contextRunner = null, array $middleware = [], ConversationSelection|null $conversationSelection = null, array|null $conversationMessages = null)

Create an agent prompt.

bool
hasApprovalDecisions()

Determine whether the prompt has tool approval decisions.

from  Prompt
bool
contains(string $string)

Determine if the prompt contains the given string.

prepend(string $prompt)

Prepend to the prompt and return a new prompt instance.

append(string $prompt)

Append to the prompt and return a new prompt instance.

revise(string $prompt, Collection|array|null $attachments = null)

Revise the prompt and return a new prompt instance.

withTools(iterable $tools)

Replace the tools for this run, returning a new prompt instance.

withAttachments(Collection|array $attachments)

Add new attachment to the prompt, returning a new prompt instance.

provider()

Get the provider instance.

bool
isFinalAttempt()

Determine whether the caller has run out of providers to retry this prompt against.

void
markAsStreaming()

Mark this prompt for lazy streaming execution.

bool
isStreaming()

Determine whether provider execution is deferred until stream consumption.

void
setPendingConversationTitle(PendingConversationTitle|null $title)

Attach the title request owned by the current attempt.

pendingConversationTitle()

Get the title request owned by the current attempt.

void
captureConversation()

Capture the conversation selection and history for this invocation.

conversationSelection()

Get the conversation owned by this invocation.

array
conversationMessages()

Get the conversational history captured for this invocation.

void
setRunContext(RunContext|null $context)

Set the context the run dispatched for this prompt records its steps on.

RunContext|null
runContext()

Get the context the run dispatched for this prompt is recording its steps on.

approvalClaim()

Get the claim a conversation store must verify when settling this continuation.

Closure|null
contextRunner()

Get the captured operation context runner.

void
setContextRunner(Closure|null $runner)

Set the operation context captured by the streaming factory.

bool
willRetry(Throwable $exception)

Determine whether the caller will retry this prompt against another provider.

array
__serialize()

Prepare the prompt for serialization without its live execution state.

Details

at line 86
__construct(Agent $agent, string $prompt, Collection|array $attachments, TextProvider $provider, string $model, int|null $timeout = null, string|null $invocationId = null, Decisions|null $approvalDecisions = null, string|null $parentInvocationId = null, string|null $parentToolInvocationId = null, bool $isFinalAttempt = true, array|null $messages = null, array|null $tools = null, Closure|null $contextRunner = null, array $middleware = [], ConversationSelection|null $conversationSelection = null, array|null $conversationMessages = null)

Create an agent prompt.

Parameters

Agent $agent
string $prompt
Collection|array $attachments
TextProvider $provider
string $model
int|null $timeout
string|null $invocationId
Decisions|null $approvalDecisions
string|null $parentInvocationId
string|null $parentToolInvocationId
bool $isFinalAttempt

whether the caller has run out of providers to retry this prompt against

array|null $messages
array|null $tools
Closure|null $contextRunner
array $middleware
ConversationSelection|null $conversationSelection
array|null $conversationMessages

in Prompt at line 26
bool hasApprovalDecisions()

Determine whether the prompt has tool approval decisions.

Return Value

bool

at line 132
bool contains(string $string)

Determine if the prompt contains the given string.

Parameters

string $string

Return Value

bool

at line 140
AgentPrompt prepend(string $prompt)

Prepend to the prompt and return a new prompt instance.

Parameters

string $prompt

Return Value

AgentPrompt

at line 148
AgentPrompt append(string $prompt)

Append to the prompt and return a new prompt instance.

Parameters

string $prompt

Return Value

AgentPrompt

at line 156
AgentPrompt revise(string $prompt, Collection|array|null $attachments = null)

Revise the prompt and return a new prompt instance.

Parameters

string $prompt
Collection|array|null $attachments

Return Value

AgentPrompt

at line 196
AgentPrompt withTools(iterable $tools)

Replace the tools for this run, returning a new prompt instance.

Parameters

iterable $tools

Return Value

AgentPrompt

at line 230
AgentPrompt withAttachments(Collection|array $attachments)

Add new attachment to the prompt, returning a new prompt instance.

Parameters

Collection|array $attachments

Return Value

AgentPrompt

at line 238
TextProvider provider()

Get the provider instance.

Return Value

TextProvider

at line 248
bool isFinalAttempt()

internal  
 

Determine whether the caller has run out of providers to retry this prompt against.

Return Value

bool

at line 258
void markAsStreaming()

internal  
 

Mark this prompt for lazy streaming execution.

Return Value

void

at line 268
bool isStreaming()

internal  
 

Determine whether provider execution is deferred until stream consumption.

Return Value

bool

at line 278
void setPendingConversationTitle(PendingConversationTitle|null $title)

internal  
 

Attach the title request owned by the current attempt.

Parameters

PendingConversationTitle|null $title

Return Value

void

at line 288
PendingConversationTitle|null pendingConversationTitle()

internal  
 

Get the title request owned by the current attempt.

Return Value

PendingConversationTitle|null

at line 298
void captureConversation()

internal  
 

Capture the conversation selection and history for this invocation.

Return Value

void

at line 309
ConversationSelection|null conversationSelection()

internal  
 

Get the conversation owned by this invocation.

Return Value

ConversationSelection|null

at line 321
array conversationMessages()

internal  
 

Get the conversational history captured for this invocation.

Return Value

array

at line 331
void setRunContext(RunContext|null $context)

internal  
 

Set the context the run dispatched for this prompt records its steps on.

Parameters

RunContext|null $context

Return Value

void

at line 344
RunContext|null runContext()

internal  
 

Get the context the run dispatched for this prompt is recording its steps on.

Return Value

RunContext|null

at line 352
ApprovalClaim|null approvalClaim()

Get the claim a conversation store must verify when settling this continuation.

Return Value

ApprovalClaim|null

at line 364
Closure|null contextRunner()

internal  
 

Get the captured operation context runner.

Return Value

Closure|null

at line 376
void setContextRunner(Closure|null $runner)

internal  
 

Set the operation context captured by the streaming factory.

Parameters

Closure|null $runner

Return Value

void

at line 386
bool willRetry(Throwable $exception)

internal  
 

Determine whether the caller will retry this prompt against another provider.

Parameters

Throwable $exception

Return Value

bool

at line 396
array __serialize()

Prepare the prompt for serialization without its live execution state.

Return Value

array