Class AbstractSessionEvent

java.lang.Object
com.github.copilot.sdk.events.AbstractSessionEvent
Direct Known Subclasses:
AbortEvent, AssistantIntentEvent, AssistantMessageDeltaEvent, AssistantMessageEvent, AssistantReasoningDeltaEvent, AssistantReasoningEvent, AssistantTurnEndEvent, AssistantTurnStartEvent, AssistantUsageEvent, HookEndEvent, HookStartEvent, PendingMessagesModifiedEvent, SessionCompactionCompleteEvent, SessionCompactionStartEvent, SessionErrorEvent, SessionHandoffEvent, SessionIdleEvent, SessionInfoEvent, SessionModelChangeEvent, SessionResumeEvent, SessionStartEvent, SessionTruncationEvent, SessionUsageInfoEvent, SubagentCompletedEvent, SubagentFailedEvent, SubagentSelectedEvent, SubagentStartedEvent, SystemMessageEvent, ToolExecutionCompleteEvent, ToolExecutionPartialResultEvent, ToolExecutionProgressEvent, ToolExecutionStartEvent, ToolUserRequestedEvent, UserMessageEvent

Base class for all session events in the Copilot SDK.

Session events represent all activities that occur during a Copilot conversation, including messages from the user and assistant, tool executions, and session state changes. Events are delivered to handlers registered via CopilotSession.on(java.util.function.Consumer).

Event Categories

Example Usage


 session.on(event -> {
 	if (event instanceof AssistantMessageEvent msg) {
 		System.out.println("Assistant: " + msg.getData().getContent());
 	} else if (event instanceof SessionIdleEvent) {
 		System.out.println("Session is idle");
 	}
 });
 
See Also:
  • Constructor Details

    • AbstractSessionEvent

      public AbstractSessionEvent()
  • Method Details

    • getType

      public abstract String getType()
      Gets the event type discriminator string.

      This corresponds to the event type in the JSON protocol (e.g., "assistant.message", "session.idle").

      Returns:
      the event type string
    • getId

      public UUID getId()
      Gets the unique identifier for this event.
      Returns:
      the event UUID
    • setId

      public void setId(UUID id)
      Sets the event identifier.
      Parameters:
      id - the event UUID
    • getTimestamp

      public OffsetDateTime getTimestamp()
      Gets the timestamp when this event occurred.
      Returns:
      the event timestamp
    • setTimestamp

      public void setTimestamp(OffsetDateTime timestamp)
      Sets the event timestamp.
      Parameters:
      timestamp - the event timestamp
    • getParentId

      public UUID getParentId()
      Gets the parent event ID, if this event is a child of another.
      Returns:
      the parent event UUID, or null
    • setParentId

      public void setParentId(UUID parentId)
      Sets the parent event ID.
      Parameters:
      parentId - the parent event UUID
    • getEphemeral

      public Boolean getEphemeral()
      Returns whether this is an ephemeral event.

      Ephemeral events are not persisted in session history.

      Returns:
      true if ephemeral, false otherwise
    • setEphemeral

      public void setEphemeral(Boolean ephemeral)
      Sets whether this is an ephemeral event.
      Parameters:
      ephemeral - true if ephemeral