Events
Documentation for the events used in the Agent Wire Protocol Python SDK
Events
The Agent Wire Protocol Python SDK uses a streaming event-based architecture. Events are the fundamental units of communication between agents and the frontend. This section documents the event types and their properties.
EventType Enum
from agentwire.core import EventType
The EventType
enum defines all possible event types in the system:
BaseEvent
from agentwire.core import BaseEvent
All events inherit from the BaseEvent
class, which provides common properties
shared across all event types.
Property | Type | Description |
---|---|---|
type | EventType | The type of event (discriminator field for the union) |
timestamp | Optional[int] | Timestamp when the event was created |
raw_event | Optional[Any] | Original event data if this event was transformed |
Lifecycle Events
These events represent the lifecycle of an agent run.
RunStartedEvent
from agentwire.core import RunStartedEvent
Signals the start of an agent run.
Property | Type | Description |
---|---|---|
thread_id | str | ID of the conversation thread |
run_id | str | ID of the agent run |
RunFinishedEvent
from agentwire.core import RunFinishedEvent
Signals the successful completion of an agent run.
Property | Type | Description |
---|---|---|
thread_id | str | ID of the conversation thread |
run_id | str | ID of the agent run |
RunErrorEvent
from agentwire.core import RunErrorEvent
Signals an error during an agent run.
Property | Type | Description |
---|---|---|
message | str | Error message |
code | Optional[str] | Error code |
StepStartedEvent
from agentwire.core import StepStartedEvent
Signals the start of a step within an agent run.
Property | Type | Description |
---|---|---|
step_name | str | Name of the step |
StepFinishedEvent
from agentwire.core import StepFinishedEvent
Signals the completion of a step within an agent run.
Property | Type | Description |
---|---|---|
step_name | str | Name of the step |
Text Message Events
These events represent the lifecycle of text messages in a conversation.
TextMessageStartEvent
from agentwire.core import TextMessageStartEvent
Signals the start of a text message.
Property | Type | Description |
---|---|---|
message_id | str | Unique identifier for the message |
role | Literal["assistant"] | Role is always “assistant” |
TextMessageContentEvent
from agentwire.core import TextMessageContentEvent
Represents a chunk of content in a streaming text message.
Property | Type | Description |
---|---|---|
message_id | str | Matches the ID from TextMessageStartEvent |
delta | str | Text content chunk (non-empty) |
TextMessageEndEvent
from agentwire.core import TextMessageEndEvent
Signals the end of a text message.
Property | Type | Description |
---|---|---|
message_id | str | Matches the ID from TextMessageStartEvent |
Tool Call Events
These events represent the lifecycle of tool calls made by agents.
ToolCallStartEvent
from agentwire.core import ToolCallStartEvent
Signals the start of a tool call.
Property | Type | Description |
---|---|---|
tool_call_id | str | Unique identifier for the tool call |
tool_call_name | str | Name of the tool being called |
parent_message_id | Optional[str] | ID of the parent message |
ToolCallArgsEvent
from agentwire.core import ToolCallArgsEvent
Represents a chunk of argument data for a tool call.
Property | Type | Description |
---|---|---|
tool_call_id | str | Matches the ID from ToolCallStartEvent |
delta | str | Argument data chunk |
ToolCallEndEvent
from agentwire.core import ToolCallEndEvent
Signals the end of a tool call.
Property | Type | Description |
---|---|---|
tool_call_id | str | Matches the ID from ToolCallStartEvent |
State Management Events
These events are used to manage agent state.
StateSnapshotEvent
from agentwire.core import StateSnapshotEvent
Provides a complete snapshot of an agent’s state.
Property | Type | Description |
---|---|---|
snapshot | State | Complete state snapshot |
StateDeltaEvent
from agentwire.core import StateDeltaEvent
Provides a partial update to an agent’s state using JSON Patch.
Property | Type | Description |
---|---|---|
delta | List[Any] | Array of JSON Patch operations |
MessagesSnapshotEvent
from agentwire.core import MessagesSnapshotEvent
Provides a snapshot of all messages in a conversation.
Property | Type | Description |
---|---|---|
messages | List[Message] | Array of message objects |
Special Events
RawEvent
from agentwire.core import RawEvent
Used to pass through events from external systems.
Property | Type | Description |
---|---|---|
event | Any | Original event data |
source | Optional[str] | Source of the event |
CustomEvent
from agentwire.core import CustomEvent
Used for application-specific custom events.
Property | Type | Description |
---|---|---|
name | str | Name of the custom event |
value | Any | Value associated with the event |
Event Discrimination
from agentwire.core import Event
The SDK uses Pydantic’s discriminated unions for event validation:
This allows for runtime validation of events and type checking at development time.