Class BetaManagedAgentsStreamSessionEvents
-
- All Implemented Interfaces:
public final class BetaManagedAgentsStreamSessionEventsServer-sent event in the session stream.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceBetaManagedAgentsStreamSessionEvents.VisitorAn interface that defines how to map each variant of BetaManagedAgentsStreamSessionEvents to a value of type T.
public final classBetaManagedAgentsStreamSessionEvents.Type
-
Method Summary
-
-
Method Detail
-
userMessage
final Optional<BetaManagedAgentsUserMessageEvent> userMessage()
A user message event in the session conversation.
-
userInterrupt
final Optional<BetaManagedAgentsUserInterruptEvent> userInterrupt()
An interrupt event that pauses agent execution and returns control to the user.
-
userToolConfirmation
final Optional<BetaManagedAgentsUserToolConfirmationEvent> userToolConfirmation()
A tool confirmation event that approves or denies a pending tool execution.
-
userCustomToolResult
final Optional<BetaManagedAgentsUserCustomToolResultEvent> userCustomToolResult()
Event sent by the client providing the result of a custom tool execution.
-
agentCustomToolUse
final Optional<BetaManagedAgentsAgentCustomToolUseEvent> agentCustomToolUse()
Event emitted when the agent calls a custom tool. The session goes idle until the client sends a
user.custom_tool_resultevent with the result. The client can send it as soon as this event arrives, without waiting forsession.status_idle.
-
agentMessage
final Optional<BetaManagedAgentsAgentMessageEvent> agentMessage()
An agent response event in the session conversation.
-
agentThinking
final Optional<BetaManagedAgentsAgentThinkingEvent> agentThinking()
Indicates the agent is making forward progress via extended thinking. A progress signal, not a content carrier.
-
agentMcpToolUse
final Optional<BetaManagedAgentsAgentMcpToolUseEvent> agentMcpToolUse()
Event emitted when the agent invokes a tool provided by an MCP server.
-
agentMcpToolResult
final Optional<BetaManagedAgentsAgentMcpToolResultEvent> agentMcpToolResult()
Event representing the result of an MCP tool execution.
-
agentToolUse
final Optional<BetaManagedAgentsAgentToolUseEvent> agentToolUse()
Event emitted when the agent invokes a built-in agent tool.
-
agentToolResult
final Optional<BetaManagedAgentsAgentToolResultEvent> agentToolResult()
Event representing the result of an agent tool execution.
-
agentThreadMessageReceived
final Optional<BetaManagedAgentsAgentThreadMessageReceivedEvent> agentThreadMessageReceived()
Delivery event written to the target thread's input stream when an agent-to-agent message arrives.
-
agentThreadMessageSent
final Optional<BetaManagedAgentsAgentThreadMessageSentEvent> agentThreadMessageSent()
Observability event emitted to the sender's output stream when an agent-to-agent message is sent.
-
agentThreadContextCompacted
final Optional<BetaManagedAgentsAgentThreadContextCompactedEvent> agentThreadContextCompacted()
Indicates that context compaction (summarization) occurred during the session.
-
sessionError
final Optional<BetaManagedAgentsSessionErrorEvent> sessionError()
An error event indicating a problem occurred during session execution.
-
sessionStatusRescheduled
final Optional<BetaManagedAgentsSessionStatusRescheduledEvent> sessionStatusRescheduled()
Indicates the session is recovering from an error state and is rescheduled for execution.
-
sessionStatusRunning
final Optional<BetaManagedAgentsSessionStatusRunningEvent> sessionStatusRunning()
Indicates the session is actively running and the agent is working.
-
sessionStatusIdle
final Optional<BetaManagedAgentsSessionStatusIdleEvent> sessionStatusIdle()
Indicates the agent has paused and is awaiting user input.
-
sessionStatusTerminated
final Optional<BetaManagedAgentsSessionStatusTerminatedEvent> sessionStatusTerminated()
Indicates the session has terminated, either due to an error or completion.
-
sessionThreadCreated
final Optional<BetaManagedAgentsSessionThreadCreatedEvent> sessionThreadCreated()
Emitted when a child thread is created. Written to the parent thread's output stream so clients observing the session see child creation.
-
spanOutcomeEvaluationStart
final Optional<BetaManagedAgentsSpanOutcomeEvaluationStartEvent> spanOutcomeEvaluationStart()
Emitted when an outcome evaluation cycle begins.
-
spanOutcomeEvaluationEnd
final Optional<BetaManagedAgentsSpanOutcomeEvaluationEndEvent> spanOutcomeEvaluationEnd()
Emitted when an outcome evaluation cycle completes. Carries the verdict and aggregate token usage. A verdict of
needs_revisionmeans another evaluation cycle follows;satisfied,max_iterations_reached,failed, orinterruptedare terminal — no further evaluation cycles follow.
-
spanModelRequestStart
final Optional<BetaManagedAgentsSpanModelRequestStartEvent> spanModelRequestStart()
Emitted when a model request is initiated by the agent.
-
spanModelRequestEnd
final Optional<BetaManagedAgentsSpanModelRequestEndEvent> spanModelRequestEnd()
Emitted when a model request completes.
-
spanOutcomeEvaluationOngoing
final Optional<BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent> spanOutcomeEvaluationOngoing()
Periodic heartbeat emitted while an outcome evaluation cycle is in progress. Distinguishes 'evaluation is actively running' from 'evaluation is stuck' between the corresponding
span.outcome_evaluation_startandspan.outcome_evaluation_endevents.
-
userDefineOutcome
final Optional<BetaManagedAgentsUserDefineOutcomeEvent> userDefineOutcome()
Echo of a
user.define_outcomeinput event. Carries the server-generatedoutcome_idthat subsequentspan.outcome_evaluation_*events reference.
-
sessionDeleted
final Optional<BetaManagedAgentsSessionDeletedEvent> sessionDeleted()
Emitted when a session has been deleted. Terminates any active event stream — no further events will be emitted for this session.
-
sessionThreadStatusRunning
final Optional<BetaManagedAgentsSessionThreadStatusRunningEvent> sessionThreadStatusRunning()
A session thread has begun executing. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.
-
sessionThreadStatusIdle
final Optional<BetaManagedAgentsSessionThreadStatusIdleEvent> sessionThreadStatusIdle()
A session thread has yielded and is awaiting input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.
-
sessionThreadStatusTerminated
final Optional<BetaManagedAgentsSessionThreadStatusTerminatedEvent> sessionThreadStatusTerminated()
A session thread has terminated and will accept no further input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.
-
userToolResult
final Optional<BetaManagedAgentsUserToolResultEvent> userToolResult()
Event sent by the client providing the result of an agent-toolset tool execution. Only valid on
self_hostedenvironments, where sandbox-routed tools are executed by the client rather than the server.
-
sessionThreadStatusRescheduled
final Optional<BetaManagedAgentsSessionThreadStatusRescheduledEvent> sessionThreadStatusRescheduled()
A session thread hit a transient error and is retrying automatically. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.
-
sessionUpdated
final Optional<BetaManagedAgentsSessionUpdatedEvent> sessionUpdated()
Emitted when an UpdateSession request changed at least one field. Carries only the fields that changed; absent fields were not part of the update. The new configuration applies from the next turn.
-
eventStart
final Optional<BetaManagedAgentsStartEvent> eventStart()
Opens a preview of a buffered event. Carries the previewed event's type and id only. Followed by zero or more event_delta events with the same event id, normally concluded by the buffered event carrying that id. If the producing model request ends without that event (an error or interrupt mid-stream), its terminal span.model_request_end closes the preview. Only sent on stream connections that opt in via event_deltas; never appears in event history.
-
eventDelta
final Optional<BetaManagedAgentsDeltaEvent> eventDelta()
An incremental update to an event that is still being streamed. Deltas are best-effort and may stop early; when the buffered event with id == event_id is produced it carries the complete content. A model request that ends early (an error or interrupt) produces no buffered event — its terminal span.model_request_end closes the preview. Only sent on stream connections that opt in via event_deltas; never appears in event history.
-
systemMessage
final Optional<BetaManagedAgentsSystemMessageEvent> systemMessage()
A mid-conversation system message event. Carries system-role content that is appended to the session as a
role: "system"turn.
-
sessionUsage
final Optional<BetaManagedAgentsSessionUsageEvent> sessionUsage()
Periodic snapshot of the session's cumulative usage and tracked list cost.
-
workflowRunCreated
final Optional<BetaManagedAgentsWorkflowRunCreatedEvent> workflowRunCreated()
A workflow run was created. A workflow run is background work that the session's agent starts. Emitted once per run, before the run's other
workflow_run.*events.
-
workflowRunStatusEnded
final Optional<BetaManagedAgentsWorkflowRunStatusEndedEvent> workflowRunStatusEnded()
A workflow run ended. Emitted once per run, as the last of the run's
workflow_run.*events.
-
workflowRunPhaseStarted
final Optional<BetaManagedAgentsWorkflowRunPhaseStartedEvent> workflowRunPhaseStarted()
A workflow run's plan entered a phase.
-
workflowRunPhaseEnded
final Optional<BetaManagedAgentsWorkflowRunPhaseEndedEvent> workflowRunPhaseEnded()
A workflow run's plan left a phase, or the run's end closed it. Emitted once for every
workflow_run.phase_startedevent, before the run'sworkflow_run.status_endedevent. The event does not say whether the plan finished the phase's work, or why it left.
-
workflowRunStatusRunning
final Optional<BetaManagedAgentsWorkflowRunStatusRunningEvent> workflowRunStatusRunning()
A workflow run is running. Emitted when the run starts to execute, and each time it resumes after being idle. A run that starts idle emits
workflow_run.status_idlefirst.
-
workflowRunStatusIdle
final Optional<BetaManagedAgentsWorkflowRunStatusIdleEvent> workflowRunStatusIdle()
A workflow run is idle. Emitted each time the run goes idle, whatever the cause. If the run ends while idle, no
workflow_run.status_runningcomes between this event and itsworkflow_run.status_ended.
-
workflowRunError
final Optional<BetaManagedAgentsWorkflowRunErrorEvent> workflowRunError()
A workflow run met an error, or an error kept a run from being created. A run that ends with a
result.typeoferroremits this event before itsworkflow_run.status_ended, with the sameerror.
-
type
final BetaManagedAgentsStreamSessionEvents.Type type()
-
processedAt
final Optional<OffsetDateTime> processedAt()
-
sessionThreadId
final Optional<String> sessionThreadId()
-
evaluatedPermission
final Optional<BetaManagedAgentsAgentEvaluatedPermission> evaluatedPermission()
-
evaluation
final Optional<BetaManagedAgentsAgentToolEvaluation> evaluation()
-
stopDetails
final Optional<BetaManagedAgentsSessionRefusalStopDetails> stopDetails()
-
workflowRunId
final Optional<String> workflowRunId()
-
description
final Optional<String> description()
-
budget
final Optional<BetaManagedAgentsBudgetLimit> budget()
-
workflowRunPhaseId
final Optional<String> workflowRunPhaseId()
-
isUserMessage
final Boolean isUserMessage()
-
isUserInterrupt
final Boolean isUserInterrupt()
-
isUserToolConfirmation
final Boolean isUserToolConfirmation()
-
isUserCustomToolResult
final Boolean isUserCustomToolResult()
-
isAgentCustomToolUse
final Boolean isAgentCustomToolUse()
-
isAgentMessage
final Boolean isAgentMessage()
-
isAgentThinking
final Boolean isAgentThinking()
-
isAgentMcpToolUse
final Boolean isAgentMcpToolUse()
-
isAgentMcpToolResult
final Boolean isAgentMcpToolResult()
-
isAgentToolUse
final Boolean isAgentToolUse()
-
isAgentToolResult
final Boolean isAgentToolResult()
-
isAgentThreadMessageReceived
final Boolean isAgentThreadMessageReceived()
-
isAgentThreadMessageSent
final Boolean isAgentThreadMessageSent()
-
isAgentThreadContextCompacted
final Boolean isAgentThreadContextCompacted()
-
isSessionError
final Boolean isSessionError()
-
isSessionStatusRescheduled
final Boolean isSessionStatusRescheduled()
-
isSessionStatusRunning
final Boolean isSessionStatusRunning()
-
isSessionStatusIdle
final Boolean isSessionStatusIdle()
-
isSessionStatusTerminated
final Boolean isSessionStatusTerminated()
-
isSessionThreadCreated
final Boolean isSessionThreadCreated()
-
isSpanOutcomeEvaluationStart
final Boolean isSpanOutcomeEvaluationStart()
-
isSpanOutcomeEvaluationEnd
final Boolean isSpanOutcomeEvaluationEnd()
-
isSpanModelRequestStart
final Boolean isSpanModelRequestStart()
-
isSpanModelRequestEnd
final Boolean isSpanModelRequestEnd()
-
isSpanOutcomeEvaluationOngoing
final Boolean isSpanOutcomeEvaluationOngoing()
-
isUserDefineOutcome
final Boolean isUserDefineOutcome()
-
isSessionDeleted
final Boolean isSessionDeleted()
-
isSessionThreadStatusRunning
final Boolean isSessionThreadStatusRunning()
-
isSessionThreadStatusIdle
final Boolean isSessionThreadStatusIdle()
-
isSessionThreadStatusTerminated
final Boolean isSessionThreadStatusTerminated()
-
isUserToolResult
final Boolean isUserToolResult()
-
isSessionThreadStatusRescheduled
final Boolean isSessionThreadStatusRescheduled()
-
isSessionUpdated
final Boolean isSessionUpdated()
-
isEventStart
final Boolean isEventStart()
-
isEventDelta
final Boolean isEventDelta()
-
isSystemMessage
final Boolean isSystemMessage()
-
isSessionUsage
final Boolean isSessionUsage()
-
isWorkflowRunCreated
final Boolean isWorkflowRunCreated()
-
isWorkflowRunStatusEnded
final Boolean isWorkflowRunStatusEnded()
-
isWorkflowRunPhaseStarted
final Boolean isWorkflowRunPhaseStarted()
-
isWorkflowRunPhaseEnded
final Boolean isWorkflowRunPhaseEnded()
-
isWorkflowRunStatusRunning
final Boolean isWorkflowRunStatusRunning()
-
isWorkflowRunStatusIdle
final Boolean isWorkflowRunStatusIdle()
-
isWorkflowRunError
final Boolean isWorkflowRunError()
-
asUserMessage
final BetaManagedAgentsUserMessageEvent asUserMessage()
A user message event in the session conversation.
-
asUserInterrupt
final BetaManagedAgentsUserInterruptEvent asUserInterrupt()
An interrupt event that pauses agent execution and returns control to the user.
-
asUserToolConfirmation
final BetaManagedAgentsUserToolConfirmationEvent asUserToolConfirmation()
A tool confirmation event that approves or denies a pending tool execution.
-
asUserCustomToolResult
final BetaManagedAgentsUserCustomToolResultEvent asUserCustomToolResult()
Event sent by the client providing the result of a custom tool execution.
-
asAgentCustomToolUse
final BetaManagedAgentsAgentCustomToolUseEvent asAgentCustomToolUse()
Event emitted when the agent calls a custom tool. The session goes idle until the client sends a
user.custom_tool_resultevent with the result. The client can send it as soon as this event arrives, without waiting forsession.status_idle.
-
asAgentMessage
final BetaManagedAgentsAgentMessageEvent asAgentMessage()
An agent response event in the session conversation.
-
asAgentThinking
final BetaManagedAgentsAgentThinkingEvent asAgentThinking()
Indicates the agent is making forward progress via extended thinking. A progress signal, not a content carrier.
-
asAgentMcpToolUse
final BetaManagedAgentsAgentMcpToolUseEvent asAgentMcpToolUse()
Event emitted when the agent invokes a tool provided by an MCP server.
-
asAgentMcpToolResult
final BetaManagedAgentsAgentMcpToolResultEvent asAgentMcpToolResult()
Event representing the result of an MCP tool execution.
-
asAgentToolUse
final BetaManagedAgentsAgentToolUseEvent asAgentToolUse()
Event emitted when the agent invokes a built-in agent tool.
-
asAgentToolResult
final BetaManagedAgentsAgentToolResultEvent asAgentToolResult()
Event representing the result of an agent tool execution.
-
asAgentThreadMessageReceived
final BetaManagedAgentsAgentThreadMessageReceivedEvent asAgentThreadMessageReceived()
Delivery event written to the target thread's input stream when an agent-to-agent message arrives.
-
asAgentThreadMessageSent
final BetaManagedAgentsAgentThreadMessageSentEvent asAgentThreadMessageSent()
Observability event emitted to the sender's output stream when an agent-to-agent message is sent.
-
asAgentThreadContextCompacted
final BetaManagedAgentsAgentThreadContextCompactedEvent asAgentThreadContextCompacted()
Indicates that context compaction (summarization) occurred during the session.
-
asSessionError
final BetaManagedAgentsSessionErrorEvent asSessionError()
An error event indicating a problem occurred during session execution.
-
asSessionStatusRescheduled
final BetaManagedAgentsSessionStatusRescheduledEvent asSessionStatusRescheduled()
Indicates the session is recovering from an error state and is rescheduled for execution.
-
asSessionStatusRunning
final BetaManagedAgentsSessionStatusRunningEvent asSessionStatusRunning()
Indicates the session is actively running and the agent is working.
-
asSessionStatusIdle
final BetaManagedAgentsSessionStatusIdleEvent asSessionStatusIdle()
Indicates the agent has paused and is awaiting user input.
-
asSessionStatusTerminated
final BetaManagedAgentsSessionStatusTerminatedEvent asSessionStatusTerminated()
Indicates the session has terminated, either due to an error or completion.
-
asSessionThreadCreated
final BetaManagedAgentsSessionThreadCreatedEvent asSessionThreadCreated()
Emitted when a child thread is created. Written to the parent thread's output stream so clients observing the session see child creation.
-
asSpanOutcomeEvaluationStart
final BetaManagedAgentsSpanOutcomeEvaluationStartEvent asSpanOutcomeEvaluationStart()
Emitted when an outcome evaluation cycle begins.
-
asSpanOutcomeEvaluationEnd
final BetaManagedAgentsSpanOutcomeEvaluationEndEvent asSpanOutcomeEvaluationEnd()
Emitted when an outcome evaluation cycle completes. Carries the verdict and aggregate token usage. A verdict of
needs_revisionmeans another evaluation cycle follows;satisfied,max_iterations_reached,failed, orinterruptedare terminal — no further evaluation cycles follow.
-
asSpanModelRequestStart
final BetaManagedAgentsSpanModelRequestStartEvent asSpanModelRequestStart()
Emitted when a model request is initiated by the agent.
-
asSpanModelRequestEnd
final BetaManagedAgentsSpanModelRequestEndEvent asSpanModelRequestEnd()
Emitted when a model request completes.
-
asSpanOutcomeEvaluationOngoing
final BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent asSpanOutcomeEvaluationOngoing()
Periodic heartbeat emitted while an outcome evaluation cycle is in progress. Distinguishes 'evaluation is actively running' from 'evaluation is stuck' between the corresponding
span.outcome_evaluation_startandspan.outcome_evaluation_endevents.
-
asUserDefineOutcome
final BetaManagedAgentsUserDefineOutcomeEvent asUserDefineOutcome()
Echo of a
user.define_outcomeinput event. Carries the server-generatedoutcome_idthat subsequentspan.outcome_evaluation_*events reference.
-
asSessionDeleted
final BetaManagedAgentsSessionDeletedEvent asSessionDeleted()
Emitted when a session has been deleted. Terminates any active event stream — no further events will be emitted for this session.
-
asSessionThreadStatusRunning
final BetaManagedAgentsSessionThreadStatusRunningEvent asSessionThreadStatusRunning()
A session thread has begun executing. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.
-
asSessionThreadStatusIdle
final BetaManagedAgentsSessionThreadStatusIdleEvent asSessionThreadStatusIdle()
A session thread has yielded and is awaiting input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.
-
asSessionThreadStatusTerminated
final BetaManagedAgentsSessionThreadStatusTerminatedEvent asSessionThreadStatusTerminated()
A session thread has terminated and will accept no further input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.
-
asUserToolResult
final BetaManagedAgentsUserToolResultEvent asUserToolResult()
Event sent by the client providing the result of an agent-toolset tool execution. Only valid on
self_hostedenvironments, where sandbox-routed tools are executed by the client rather than the server.
-
asSessionThreadStatusRescheduled
final BetaManagedAgentsSessionThreadStatusRescheduledEvent asSessionThreadStatusRescheduled()
A session thread hit a transient error and is retrying automatically. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.
-
asSessionUpdated
final BetaManagedAgentsSessionUpdatedEvent asSessionUpdated()
Emitted when an UpdateSession request changed at least one field. Carries only the fields that changed; absent fields were not part of the update. The new configuration applies from the next turn.
-
asEventStart
final BetaManagedAgentsStartEvent asEventStart()
Opens a preview of a buffered event. Carries the previewed event's type and id only. Followed by zero or more event_delta events with the same event id, normally concluded by the buffered event carrying that id. If the producing model request ends without that event (an error or interrupt mid-stream), its terminal span.model_request_end closes the preview. Only sent on stream connections that opt in via event_deltas; never appears in event history.
-
asEventDelta
final BetaManagedAgentsDeltaEvent asEventDelta()
An incremental update to an event that is still being streamed. Deltas are best-effort and may stop early; when the buffered event with id == event_id is produced it carries the complete content. A model request that ends early (an error or interrupt) produces no buffered event — its terminal span.model_request_end closes the preview. Only sent on stream connections that opt in via event_deltas; never appears in event history.
-
asSystemMessage
final BetaManagedAgentsSystemMessageEvent asSystemMessage()
A mid-conversation system message event. Carries system-role content that is appended to the session as a
role: "system"turn.
-
asSessionUsage
final BetaManagedAgentsSessionUsageEvent asSessionUsage()
Periodic snapshot of the session's cumulative usage and tracked list cost.
-
asWorkflowRunCreated
final BetaManagedAgentsWorkflowRunCreatedEvent asWorkflowRunCreated()
A workflow run was created. A workflow run is background work that the session's agent starts. Emitted once per run, before the run's other
workflow_run.*events.
-
asWorkflowRunStatusEnded
final BetaManagedAgentsWorkflowRunStatusEndedEvent asWorkflowRunStatusEnded()
A workflow run ended. Emitted once per run, as the last of the run's
workflow_run.*events.
-
asWorkflowRunPhaseStarted
final BetaManagedAgentsWorkflowRunPhaseStartedEvent asWorkflowRunPhaseStarted()
A workflow run's plan entered a phase.
-
asWorkflowRunPhaseEnded
final BetaManagedAgentsWorkflowRunPhaseEndedEvent asWorkflowRunPhaseEnded()
A workflow run's plan left a phase, or the run's end closed it. Emitted once for every
workflow_run.phase_startedevent, before the run'sworkflow_run.status_endedevent. The event does not say whether the plan finished the phase's work, or why it left.
-
asWorkflowRunStatusRunning
final BetaManagedAgentsWorkflowRunStatusRunningEvent asWorkflowRunStatusRunning()
A workflow run is running. Emitted when the run starts to execute, and each time it resumes after being idle. A run that starts idle emits
workflow_run.status_idlefirst.
-
asWorkflowRunStatusIdle
final BetaManagedAgentsWorkflowRunStatusIdleEvent asWorkflowRunStatusIdle()
A workflow run is idle. Emitted each time the run goes idle, whatever the cause. If the run ends while idle, no
workflow_run.status_runningcomes between this event and itsworkflow_run.status_ended.
-
asWorkflowRunError
final BetaManagedAgentsWorkflowRunErrorEvent asWorkflowRunError()
A workflow run met an error, or an error kept a run from being created. A run that ends with a
result.typeoferroremits this event before itsworkflow_run.status_ended, with the sameerror.
-
accept
final <T extends Any> T accept(BetaManagedAgentsStreamSessionEvents.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.anthropic.core.JsonValue; import java.util.Optional; Optional<String> result = betaManagedAgentsStreamSessionEvents.accept(new BetaManagedAgentsStreamSessionEvents.Visitor<Optional<String>>() { @Override public Optional<String> visitUserMessage(BetaManagedAgentsUserMessageEvent userMessage) { return Optional.of(userMessage.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final BetaManagedAgentsStreamSessionEvents validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofUserMessage
final static BetaManagedAgentsStreamSessionEvents ofUserMessage(BetaManagedAgentsUserMessageEvent userMessage)
A user message event in the session conversation.
-
ofUserInterrupt
final static BetaManagedAgentsStreamSessionEvents ofUserInterrupt(BetaManagedAgentsUserInterruptEvent userInterrupt)
An interrupt event that pauses agent execution and returns control to the user.
-
ofUserInterrupt
final static BetaManagedAgentsStreamSessionEvents ofUserInterrupt(String id)
Returns an immutable instance of BetaManagedAgentsStreamSessionEvents whose ofUserInterrupt variant is built from the given required id.
-
ofUserToolConfirmation
final static BetaManagedAgentsStreamSessionEvents ofUserToolConfirmation(BetaManagedAgentsUserToolConfirmationEvent userToolConfirmation)
A tool confirmation event that approves or denies a pending tool execution.
-
ofUserCustomToolResult
final static BetaManagedAgentsStreamSessionEvents ofUserCustomToolResult(BetaManagedAgentsUserCustomToolResultEvent userCustomToolResult)
Event sent by the client providing the result of a custom tool execution.
-
ofAgentCustomToolUse
final static BetaManagedAgentsStreamSessionEvents ofAgentCustomToolUse(BetaManagedAgentsAgentCustomToolUseEvent agentCustomToolUse)
Event emitted when the agent calls a custom tool. The session goes idle until the client sends a
user.custom_tool_resultevent with the result. The client can send it as soon as this event arrives, without waiting forsession.status_idle.
-
ofAgentMessage
final static BetaManagedAgentsStreamSessionEvents ofAgentMessage(BetaManagedAgentsAgentMessageEvent agentMessage)
An agent response event in the session conversation.
-
ofAgentThinking
final static BetaManagedAgentsStreamSessionEvents ofAgentThinking(BetaManagedAgentsAgentThinkingEvent agentThinking)
Indicates the agent is making forward progress via extended thinking. A progress signal, not a content carrier.
-
ofAgentMcpToolUse
final static BetaManagedAgentsStreamSessionEvents ofAgentMcpToolUse(BetaManagedAgentsAgentMcpToolUseEvent agentMcpToolUse)
Event emitted when the agent invokes a tool provided by an MCP server.
-
ofAgentMcpToolResult
final static BetaManagedAgentsStreamSessionEvents ofAgentMcpToolResult(BetaManagedAgentsAgentMcpToolResultEvent agentMcpToolResult)
Event representing the result of an MCP tool execution.
-
ofAgentToolUse
final static BetaManagedAgentsStreamSessionEvents ofAgentToolUse(BetaManagedAgentsAgentToolUseEvent agentToolUse)
Event emitted when the agent invokes a built-in agent tool.
-
ofAgentToolResult
final static BetaManagedAgentsStreamSessionEvents ofAgentToolResult(BetaManagedAgentsAgentToolResultEvent agentToolResult)
Event representing the result of an agent tool execution.
-
ofAgentThreadMessageReceived
final static BetaManagedAgentsStreamSessionEvents ofAgentThreadMessageReceived(BetaManagedAgentsAgentThreadMessageReceivedEvent agentThreadMessageReceived)
Delivery event written to the target thread's input stream when an agent-to-agent message arrives.
-
ofAgentThreadMessageSent
final static BetaManagedAgentsStreamSessionEvents ofAgentThreadMessageSent(BetaManagedAgentsAgentThreadMessageSentEvent agentThreadMessageSent)
Observability event emitted to the sender's output stream when an agent-to-agent message is sent.
-
ofAgentThreadContextCompacted
final static BetaManagedAgentsStreamSessionEvents ofAgentThreadContextCompacted(BetaManagedAgentsAgentThreadContextCompactedEvent agentThreadContextCompacted)
Indicates that context compaction (summarization) occurred during the session.
-
ofSessionError
final static BetaManagedAgentsStreamSessionEvents ofSessionError(BetaManagedAgentsSessionErrorEvent sessionError)
An error event indicating a problem occurred during session execution.
-
ofSessionStatusRescheduled
final static BetaManagedAgentsStreamSessionEvents ofSessionStatusRescheduled(BetaManagedAgentsSessionStatusRescheduledEvent sessionStatusRescheduled)
Indicates the session is recovering from an error state and is rescheduled for execution.
-
ofSessionStatusRunning
final static BetaManagedAgentsStreamSessionEvents ofSessionStatusRunning(BetaManagedAgentsSessionStatusRunningEvent sessionStatusRunning)
Indicates the session is actively running and the agent is working.
-
ofSessionStatusIdle
final static BetaManagedAgentsStreamSessionEvents ofSessionStatusIdle(BetaManagedAgentsSessionStatusIdleEvent sessionStatusIdle)
Indicates the agent has paused and is awaiting user input.
-
ofSessionStatusTerminated
final static BetaManagedAgentsStreamSessionEvents ofSessionStatusTerminated(BetaManagedAgentsSessionStatusTerminatedEvent sessionStatusTerminated)
Indicates the session has terminated, either due to an error or completion.
-
ofSessionThreadCreated
final static BetaManagedAgentsStreamSessionEvents ofSessionThreadCreated(BetaManagedAgentsSessionThreadCreatedEvent sessionThreadCreated)
Emitted when a child thread is created. Written to the parent thread's output stream so clients observing the session see child creation.
-
ofSpanOutcomeEvaluationStart
final static BetaManagedAgentsStreamSessionEvents ofSpanOutcomeEvaluationStart(BetaManagedAgentsSpanOutcomeEvaluationStartEvent spanOutcomeEvaluationStart)
Emitted when an outcome evaluation cycle begins.
-
ofSpanOutcomeEvaluationEnd
final static BetaManagedAgentsStreamSessionEvents ofSpanOutcomeEvaluationEnd(BetaManagedAgentsSpanOutcomeEvaluationEndEvent spanOutcomeEvaluationEnd)
Emitted when an outcome evaluation cycle completes. Carries the verdict and aggregate token usage. A verdict of
needs_revisionmeans another evaluation cycle follows;satisfied,max_iterations_reached,failed, orinterruptedare terminal — no further evaluation cycles follow.
-
ofSpanModelRequestStart
final static BetaManagedAgentsStreamSessionEvents ofSpanModelRequestStart(BetaManagedAgentsSpanModelRequestStartEvent spanModelRequestStart)
Emitted when a model request is initiated by the agent.
-
ofSpanModelRequestEnd
final static BetaManagedAgentsStreamSessionEvents ofSpanModelRequestEnd(BetaManagedAgentsSpanModelRequestEndEvent spanModelRequestEnd)
Emitted when a model request completes.
-
ofSpanOutcomeEvaluationOngoing
final static BetaManagedAgentsStreamSessionEvents ofSpanOutcomeEvaluationOngoing(BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent spanOutcomeEvaluationOngoing)
Periodic heartbeat emitted while an outcome evaluation cycle is in progress. Distinguishes 'evaluation is actively running' from 'evaluation is stuck' between the corresponding
span.outcome_evaluation_startandspan.outcome_evaluation_endevents.
-
ofUserDefineOutcome
final static BetaManagedAgentsStreamSessionEvents ofUserDefineOutcome(BetaManagedAgentsUserDefineOutcomeEvent userDefineOutcome)
Echo of a
user.define_outcomeinput event. Carries the server-generatedoutcome_idthat subsequentspan.outcome_evaluation_*events reference.
-
ofSessionDeleted
final static BetaManagedAgentsStreamSessionEvents ofSessionDeleted(BetaManagedAgentsSessionDeletedEvent sessionDeleted)
Emitted when a session has been deleted. Terminates any active event stream — no further events will be emitted for this session.
-
ofSessionThreadStatusRunning
final static BetaManagedAgentsStreamSessionEvents ofSessionThreadStatusRunning(BetaManagedAgentsSessionThreadStatusRunningEvent sessionThreadStatusRunning)
A session thread has begun executing. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.
-
ofSessionThreadStatusIdle
final static BetaManagedAgentsStreamSessionEvents ofSessionThreadStatusIdle(BetaManagedAgentsSessionThreadStatusIdleEvent sessionThreadStatusIdle)
A session thread has yielded and is awaiting input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.
-
ofSessionThreadStatusTerminated
final static BetaManagedAgentsStreamSessionEvents ofSessionThreadStatusTerminated(BetaManagedAgentsSessionThreadStatusTerminatedEvent sessionThreadStatusTerminated)
A session thread has terminated and will accept no further input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.
-
ofUserToolResult
final static BetaManagedAgentsStreamSessionEvents ofUserToolResult(BetaManagedAgentsUserToolResultEvent userToolResult)
Event sent by the client providing the result of an agent-toolset tool execution. Only valid on
self_hostedenvironments, where sandbox-routed tools are executed by the client rather than the server.
-
ofSessionThreadStatusRescheduled
final static BetaManagedAgentsStreamSessionEvents ofSessionThreadStatusRescheduled(BetaManagedAgentsSessionThreadStatusRescheduledEvent sessionThreadStatusRescheduled)
A session thread hit a transient error and is retrying automatically. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.
-
ofSessionUpdated
final static BetaManagedAgentsStreamSessionEvents ofSessionUpdated(BetaManagedAgentsSessionUpdatedEvent sessionUpdated)
Emitted when an UpdateSession request changed at least one field. Carries only the fields that changed; absent fields were not part of the update. The new configuration applies from the next turn.
-
ofEventStart
final static BetaManagedAgentsStreamSessionEvents ofEventStart(BetaManagedAgentsStartEvent eventStart)
Opens a preview of a buffered event. Carries the previewed event's type and id only. Followed by zero or more event_delta events with the same event id, normally concluded by the buffered event carrying that id. If the producing model request ends without that event (an error or interrupt mid-stream), its terminal span.model_request_end closes the preview. Only sent on stream connections that opt in via event_deltas; never appears in event history.
-
ofEventStart
final static BetaManagedAgentsStreamSessionEvents ofEventStart(BetaManagedAgentsStartEventPreview event)
Returns an immutable instance of BetaManagedAgentsStreamSessionEvents whose ofEventStart variant is built from the given required event.
-
ofEventStart
final static BetaManagedAgentsStreamSessionEvents ofEventStart(BetaManagedAgentsAgentMessagePreview agentMessage)
Alias for calling ofEventStart with
BetaManagedAgentsStartEventPreview.ofAgentMessage(agentMessage).
-
ofEventStart
final static BetaManagedAgentsStreamSessionEvents ofEventStart(BetaManagedAgentsAgentThinkingPreview agentThinking)
Alias for calling ofEventStart with
BetaManagedAgentsStartEventPreview.ofAgentThinking(agentThinking).
-
ofEventDelta
final static BetaManagedAgentsStreamSessionEvents ofEventDelta(BetaManagedAgentsDeltaEvent eventDelta)
An incremental update to an event that is still being streamed. Deltas are best-effort and may stop early; when the buffered event with id == event_id is produced it carries the complete content. A model request that ends early (an error or interrupt) produces no buffered event — its terminal span.model_request_end closes the preview. Only sent on stream connections that opt in via event_deltas; never appears in event history.
-
ofSystemMessage
final static BetaManagedAgentsStreamSessionEvents ofSystemMessage(BetaManagedAgentsSystemMessageEvent systemMessage)
A mid-conversation system message event. Carries system-role content that is appended to the session as a
role: "system"turn.
-
ofSessionUsage
final static BetaManagedAgentsStreamSessionEvents ofSessionUsage(BetaManagedAgentsSessionUsageEvent sessionUsage)
Periodic snapshot of the session's cumulative usage and tracked list cost.
-
ofWorkflowRunCreated
final static BetaManagedAgentsStreamSessionEvents ofWorkflowRunCreated(BetaManagedAgentsWorkflowRunCreatedEvent workflowRunCreated)
A workflow run was created. A workflow run is background work that the session's agent starts. Emitted once per run, before the run's other
workflow_run.*events.
-
ofWorkflowRunStatusEnded
final static BetaManagedAgentsStreamSessionEvents ofWorkflowRunStatusEnded(BetaManagedAgentsWorkflowRunStatusEndedEvent workflowRunStatusEnded)
A workflow run ended. Emitted once per run, as the last of the run's
workflow_run.*events.
-
ofWorkflowRunPhaseStarted
final static BetaManagedAgentsStreamSessionEvents ofWorkflowRunPhaseStarted(BetaManagedAgentsWorkflowRunPhaseStartedEvent workflowRunPhaseStarted)
A workflow run's plan entered a phase.
-
ofWorkflowRunPhaseEnded
final static BetaManagedAgentsStreamSessionEvents ofWorkflowRunPhaseEnded(BetaManagedAgentsWorkflowRunPhaseEndedEvent workflowRunPhaseEnded)
A workflow run's plan left a phase, or the run's end closed it. Emitted once for every
workflow_run.phase_startedevent, before the run'sworkflow_run.status_endedevent. The event does not say whether the plan finished the phase's work, or why it left.
-
ofWorkflowRunStatusRunning
final static BetaManagedAgentsStreamSessionEvents ofWorkflowRunStatusRunning(BetaManagedAgentsWorkflowRunStatusRunningEvent workflowRunStatusRunning)
A workflow run is running. Emitted when the run starts to execute, and each time it resumes after being idle. A run that starts idle emits
workflow_run.status_idlefirst.
-
ofWorkflowRunStatusIdle
final static BetaManagedAgentsStreamSessionEvents ofWorkflowRunStatusIdle(BetaManagedAgentsWorkflowRunStatusIdleEvent workflowRunStatusIdle)
A workflow run is idle. Emitted each time the run goes idle, whatever the cause. If the run ends while idle, no
workflow_run.status_runningcomes between this event and itsworkflow_run.status_ended.
-
ofWorkflowRunError
final static BetaManagedAgentsStreamSessionEvents ofWorkflowRunError(BetaManagedAgentsWorkflowRunErrorEvent workflowRunError)
A workflow run met an error, or an error kept a run from being created. A run that ends with a
result.typeoferroremits this event before itsworkflow_run.status_ended, with the sameerror.
-
-
-
-