AnonymousAgent
class AnonymousAgent implements Agent, Conversational, HasTools
Traits
Properties
| protected null|Message> | $adHocMessages | The ad-hoc message history to send ahead of the next prompt. |
from Promptable |
| protected SerializableClosure|null | $runtimeTools | The runtime tool override, replacing the tools the agent declares. |
from Promptable |
| protected array<int, object|string> | $runtimeMiddleware | The runtime middleware wrapping the agent's declared middleware. |
from Promptable |
Methods
Get the property value prepared for serialization.
Get the restored property value after deserialization.
Get the query for model restoration.
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.
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 a queued prompt was received matching a given truth test.
Assert that a queued prompt was not received matching a given truth test.
Create an ad-hoc agent with instructions, messages and tools.
Get the agent instructions.
Get the conversation messages.
Get the available tools.
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.
in
Promptable at line 85
static Promptable
make(mixed ...$arguments)
Create a new instance of the agent.
in
Promptable 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.
in
Promptable 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.
in
Promptable 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.
in
Promptable 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.
in
Promptable 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.
in
Promptable 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.
in
Promptable at line 409
Promptable
withMessages(iterable $messages)
Set the ad-hoc message history to send ahead of the next prompt.
in
Promptable at line 429
Promptable
withTools(Closure|iterable $tools)
Replace the agent's declared tools for this instance.
in
Promptable at line 447
Promptable
withMiddleware(array $middleware)
Append middleware that wraps the agent's declared middleware for this instance.
in
Promptable at line 461
protected array|null
resolveAgentTools()
Resolve the runtime tools for the next invocation, or null when the agent's declared tools apply.
in
Promptable 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.
in
Promptable at line 609
protected string
getDefaultModelFor(TextProvider $provider)
Get the default model to use for the given provider.
in
Promptable at line 627
protected int
getTimeout(int|null $timeout)
Get the timeout to use for the agent prompt.
in
Promptable 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.
in
Promptable at line 660
static void
assertPrompted(Closure|string $callback)
Assert that a prompt was received matching a given truth test.
in
Promptable at line 668
static void
assertPromptedTimes(int $times = 1)
Assert that a certain number of prompts were received.
in
Promptable at line 676
static void
assertNotPrompted(Closure|string $callback)
Assert that a prompt was not received matching a given truth test.
in
Promptable at line 684
static void
assertNeverPrompted()
Assert that no prompts were received.
in
Promptable at line 692
static void
assertQueued(Closure|string $callback)
Assert that a queued prompt was received matching a given truth test.
in
Promptable at line 700
static void
assertNotQueued(Closure|string $callback)
Assert that a queued prompt was not received matching a given truth test.
in
Promptable at line 708
static void
assertNeverQueued()
Assert that no queued prompts were received.
in
Promptable at line 716
static bool
isFaked()
Determine if the agent is currently faked.
at line 21
__construct(string $instructions, iterable $messages, iterable $tools)
Create an ad-hoc agent with instructions, messages and tools.
at line 30
Stringable|string
instructions()
Get the agent instructions.
at line 38
iterable
messages()
Get the conversation messages.
at line 46
iterable
tools()
Get the available tools.