RunContext
class RunContext
Properties
| protected Step> | $steps | ||
| protected ClaimsPendingApprovals|null | $approvalStore | ||
| protected string|null | $conversationId | ||
| protected ApprovalClaim|null | $approvalClaim | ||
| protected bool | $toolWasInvoked |
Methods
Create the context for a generation run.
Get the captured operation context runner.
Claim and record the approvals this run resumes through the given conversation's store.
Claim the stored pause before any of its tools execute.
Determine whether a stored continuation failed before obtaining ownership.
Get the claim that owns this continuation.
Persist a completed approval result before another tool can execute.
Keep the step the model just produced, so a run that dies later can still be recorded as far as it got.
Answer the step being worked on, one tool at a time, so a step that dies partway keeps the tools that ran.
Get the response the run had built by the time it ended, however it ended.
Report that a generation step is about to start.
Report that a generation step returned a response.
Report that a generation step ended without producing a response.
Report that a tool is about to be invoked.
Determine whether any tool has started executing in this run.
Report that a tool returned a result.
Report that a tool's handler threw.
Details
at line 48
__construct(string $invocationId, Agent $agent, TextProvider $provider, string $model, Dispatcher $events, Closure|null $contextRunner = null)
Create the context for a generation run.
at line 65
Closure|null
contextRunner()
| internal |
Get the captured operation context runner.
at line 73
RunContext
withApprovalStore(ClaimsPendingApprovals $store, string $conversationId)
Claim and record the approvals this run resumes through the given conversation's store.
at line 86
void
claimPendingApprovals(array $toolCallIds)
Claim the stored pause before any of its tools execute.
at line 102
bool
hasUnclaimedApprovals()
Determine whether a stored continuation failed before obtaining ownership.
at line 110
ApprovalClaim|null
approvalClaim()
Get the claim that owns this continuation.
at line 118
void
recordApprovalResult(ToolResult $result)
Persist a completed approval result before another tool can execute.
at line 128
void
recordStep(Step $step)
Keep the step the model just produced, so a run that dies later can still be recorded as far as it got.
at line 136
void
recordToolResult(ToolResult $result)
Answer the step being worked on, one tool at a time, so a step that dies partway keeps the tools that ran.
at line 148
AgentResponse
recordedResponse()
Get the response the run had built by the time it ended, however it ended.
at line 166
void
startingStep(StepContext $step, array $messages, TextGenerationOptions|null $options, string|null $model = null, string|null $instructions = null, array $tools = [])
Report that a generation step is about to start.
at line 190
void
stepCompleted(StepContext|null $step, StepResponse $response, float $time, string|null $model = null)
Report that a generation step returned a response.
at line 211
void
stepFailed(StepContext|null $step, Throwable $exception, float $time, string|null $model = null)
Report that a generation step ended without producing a response.
at line 234
void
invokingTool(Tool $tool, array $arguments, string $toolInvocationId)
Report that a tool is about to be invoked.
at line 255
bool
hasInvokedTool()
Determine whether any tool has started executing in this run.
at line 265
void
toolInvoked(Tool $tool, array $arguments, mixed $result, string $toolInvocationId, float $time)
Report that a tool returned a result.