AgentPrompt
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
Create an agent prompt.
Determine if the prompt contains the given string.
Prepend to the prompt and return a new prompt instance.
Append to the prompt and return a new prompt instance.
Revise the prompt and return a new prompt instance.
Replace the tools for this run, returning a new prompt instance.
Add new attachment to the prompt, returning a new prompt instance.
Get the provider instance.
Determine whether the caller has run out of providers to retry this prompt against.
Mark this prompt for lazy streaming execution.
Determine whether provider execution is deferred until stream consumption.
Attach the title request owned by the current attempt.
Get the title request owned by the current attempt.
Capture the conversation selection and history for this invocation.
Get the conversation owned by this invocation.
Get the conversational history captured for this invocation.
Set the context the run dispatched for this prompt records its steps on.
Get the context the run dispatched for this prompt is recording its steps on.
Get the claim a conversation store must verify when settling this continuation.
Get the captured operation context runner.
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.
in
Prompt at line 26
bool
hasApprovalDecisions()
Determine whether the prompt has tool approval decisions.
at line 132
bool
contains(string $string)
Determine if the prompt contains the given string.
at line 140
AgentPrompt
prepend(string $prompt)
Prepend to the prompt and return a new prompt instance.
at line 148
AgentPrompt
append(string $prompt)
Append to the prompt and return a new prompt instance.
at line 156
AgentPrompt
revise(string $prompt, Collection|array|null $attachments = null)
Revise the prompt and return a new prompt instance.
at line 196
AgentPrompt
withTools(iterable $tools)
Replace the tools for this run, returning a new prompt instance.
at line 230
AgentPrompt
withAttachments(Collection|array $attachments)
Add new attachment to the prompt, returning a new prompt instance.
at line 238
TextProvider
provider()
Get the provider instance.
at line 248
bool
isFinalAttempt()
| internal |
Determine whether the caller has run out of providers to retry this prompt against.
at line 258
void
markAsStreaming()
| internal |
Mark this prompt for lazy streaming execution.
at line 268
bool
isStreaming()
| internal |
Determine whether provider execution is deferred until stream consumption.
at line 278
void
setPendingConversationTitle(PendingConversationTitle|null $title)
| internal |
Attach the title request owned by the current attempt.
at line 288
PendingConversationTitle|null
pendingConversationTitle()
| internal |
Get the title request owned by the current attempt.
at line 298
void
captureConversation()
| internal |
Capture the conversation selection and history for this invocation.
at line 309
ConversationSelection|null
conversationSelection()
| internal |
Get the conversation owned by this invocation.
at line 321
array
conversationMessages()
| internal |
Get the conversational history captured for this invocation.
at line 331
void
setRunContext(RunContext|null $context)
| internal |
Set the context the run dispatched for this prompt records its steps on.
at line 344
RunContext|null
runContext()
| internal |
Get the context the run dispatched for this prompt is recording its steps on.
at line 352
ApprovalClaim|null
approvalClaim()
Get the claim a conversation store must verify when settling this continuation.
at line 364
Closure|null
contextRunner()
| internal |
Get the captured operation context runner.
at line 376
void
setContextRunner(Closure|null $runner)
| internal |
Set the operation context captured by the streaming factory.
at line 386
bool
willRetry(Throwable $exception)
| internal |
Determine whether the caller will retry this prompt against another provider.
at line 396
array
__serialize()
Prepare the prompt for serialization without its live execution state.