Promptable
trait Promptable
Traits
Properties
| protected null|Message> | $adHocMessages | The ad-hoc message history to send ahead of the next prompt. |
|
| protected SerializableClosure|null | $runtimeTools | The runtime tool override, replacing the tools the agent declares. |
|
| protected array<int, object|string> | $runtimeMiddleware | The runtime middleware wrapping the agent's declared middleware. |
Methods
Get the property value prepared for serialization.
Get the restored property value after deserialization.
Get the query for model restoration.
Create a new instance of the agent.
Invoke the agent with a given prompt, or resume a paused run with tool approval decisions.
Invoke the agent with a given prompt and return a streamable response.
Invoke the agent in a queued job.
Invoke the agent with a given prompt and broadcast the streamed events.
Invoke the agent with a given prompt and broadcast the streamed events immediately.
Invoke the agent with a given prompt and broadcast the streamed events.
Set the ad-hoc message history to send ahead of the next prompt.
Append middleware that wraps the agent's declared middleware for this instance.
Resolve the runtime tools for the next invocation, or null when the agent's declared tools apply.
Get the providers and models array for the given initial provider and model values.
Get the timeout to use for the agent prompt.
Assert that a prompt was received matching a given truth test.
Assert that a certain number of prompts were received.
Assert that a prompt was not received matching a given truth test.
Assert that no prompts were received.
Assert that a queued prompt was received matching a given truth test.
Assert that a queued prompt was not received matching a given truth test.
Assert that no queued prompts were received.
Determine if the agent is currently faked.
Details
in
SerializesAndRestoresModelIdentifiers at line 21
protected mixed
getSerializedPropertyValue(mixed $value, bool $withRelations = true)
Get the property value prepared for serialization.
in
SerializesAndRestoresModelIdentifiers at line 64
protected mixed
getRestoredPropertyValue(mixed $value)
Get the restored property value after deserialization.
in
SerializesAndRestoresModelIdentifiers at line 78
protected Collection
restoreCollection(ModelIdentifier $value)
Restore a queueable collection instance.
in
SerializesAndRestoresModelIdentifiers at line 118
Model
restoreModel(ModelIdentifier $value)
Restore the model from the model identifier instance.
in
SerializesAndRestoresModelIdentifiers at line 137
protected Builder
getQueryForModelRestoration(Model $model, array|int|string $ids)
Get the query for model restoration.
in
SerializesModels at line 18
array
__serialize()
Prepare the instance values for serialization.
in
SerializesModels at line 69
void
__unserialize(array $values)
Restore the model after serialization.
in
SerializesModels at line 105
protected mixed
getPropertyValue(ReflectionProperty $property)
Get the property value for the given property.
Unlike Laravel, this reads the stored value without running a get hook, as native serialization does.
at line 85
static Promptable
make(mixed ...$arguments)
Create a new instance of the agent.
at line 99
AgentResponse
prompt(AgentInput|UserMessage|Decisions|string $prompt, array $attachments = [], Provider|Lab|array|string|null $provider = null, string|null $model = null, int|null $timeout = null)
Invoke the agent with a given prompt, or resume a paused run with tool approval decisions.
at line 171
StreamableAgentResponse
stream(AgentInput|UserMessage|Decisions|string $prompt, array $attachments = [], Provider|Lab|array|string|null $provider = null, string|null $model = null, int|null $timeout = null)
Invoke the agent with a given prompt and return a streamable response.
at line 320
QueuedAgentResponse
queue(AgentInput|UserMessage|Decisions|string $prompt, array $attachments = [], Provider|Lab|array|string|null $provider = null, string|null $model = null)
Invoke the agent in a queued job.
at line 370
StreamableAgentResponse
broadcast(AgentInput|UserMessage|Decisions|string $prompt, Channel|array $channels, array $attachments = [], bool $now = true, Provider|Lab|array|string|null $provider = null, string|null $model = null)
Invoke the agent with a given prompt and broadcast the streamed events.
at line 381
StreamableAgentResponse
broadcastNow(AgentInput|UserMessage|Decisions|string $prompt, Channel|array $channels, array $attachments = [], Provider|Lab|array|string|null $provider = null, string|null $model = null)
Invoke the agent with a given prompt and broadcast the streamed events immediately.
at line 389
QueuedAgentResponse
broadcastOnQueue(AgentInput|UserMessage|Decisions|string $prompt, Channel|array $channels, array $attachments = [], Provider|Lab|array|string|null $provider = null, string|null $model = null)
Invoke the agent with a given prompt and broadcast the streamed events.
at line 409
Promptable
withMessages(iterable $messages)
Set the ad-hoc message history to send ahead of the next prompt.
at line 429
Promptable
withTools(Closure|iterable $tools)
Replace the agent's declared tools for this instance.
at line 447
Promptable
withMiddleware(array $middleware)
Append middleware that wraps the agent's declared middleware for this instance.
at line 461
protected array|null
resolveAgentTools()
Resolve the runtime tools for the next invocation, or null when the agent's declared tools apply.
at line 573
protected array
getProvidersAndModels(Provider|Lab|array|string|null $provider, string|null $model)
Get the providers and models array for the given initial provider and model values.
at line 609
protected string
getDefaultModelFor(TextProvider $provider)
Get the default model to use for the given provider.
at line 627
protected int
getTimeout(int|null $timeout)
Get the timeout to use for the agent prompt.
at line 651
static FakeTextGateway
fake(Closure|array $responses = [])
Fake the responses returned by the agent.
The fake affects subsequent calls for this agent in the worker.
at line 660
static void
assertPrompted(Closure|string $callback)
Assert that a prompt was received matching a given truth test.
at line 668
static void
assertPromptedTimes(int $times = 1)
Assert that a certain number of prompts were received.
at line 676
static void
assertNotPrompted(Closure|string $callback)
Assert that a prompt was not received matching a given truth test.
at line 684
static void
assertNeverPrompted()
Assert that no prompts were received.
at line 692
static void
assertQueued(Closure|string $callback)
Assert that a queued prompt was received matching a given truth test.
at line 700
static void
assertNotQueued(Closure|string $callback)
Assert that a queued prompt was not received matching a given truth test.
at line 708
static void
assertNeverQueued()
Assert that no queued prompts were received.
at line 716
static bool
isFaked()
Determine if the agent is currently faked.