pub struct AgUiEventContext {
pub message_id: String,
/* private fields */
}Expand description
Context for AG-UI event conversion.
Maintains state needed for converting internal AgentEvents to AG-UI events.
State is initialized from the first RunStart event in the stream.
Fields§
§message_id: StringCurrent message identifier.
Implementations§
Source§impl AgUiEventContext
impl AgUiEventContext
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new AG-UI context.
The context is fully initialized when the first RunStart event
arrives, which generates an independent message_id (UUID v7).
Sourcepub fn with_frontend_run_id(self, run_id: impl Into<String>) -> Self
pub fn with_frontend_run_id(self, run_id: impl Into<String>) -> Self
Set a frontend run id used in outward-facing AG-UI lifecycle events.
Sourcepub fn next_step_name(&mut self) -> String
pub fn next_step_name(&mut self) -> String
Generate the next step name.
Sourcepub fn current_step_name(&self) -> String
pub fn current_step_name(&self) -> String
Get the current step name.
Sourcepub fn start_text(&mut self) -> bool
pub fn start_text(&mut self) -> bool
Mark text stream as started.
If text was previously ended, a new message_id is generated so that
each TEXT_MESSAGE_START / TEXT_MESSAGE_END cycle uses a unique ID.
This prevents CopilotKit / AG-UI runtimes from confusing reopened
message IDs with already-ended ones (which causes “text-end for
missing text part” errors on the frontend).
Sourcepub fn is_text_open(&self) -> bool
pub fn is_text_open(&self) -> bool
Whether a text stream is currently open.
Sourcepub fn start_reasoning(&mut self) -> bool
pub fn start_reasoning(&mut self) -> bool
Mark reasoning stream as started.
Sourcepub fn end_reasoning(&mut self) -> bool
pub fn end_reasoning(&mut self) -> bool
Mark reasoning stream as ended and return whether it was active.
Sourcepub fn reset_for_step(&mut self, message_id: String)
pub fn reset_for_step(&mut self, message_id: String)
Reset text lifecycle state for a new step with a pre-generated message ID.
This ensures that the streaming message ID matches the stored Message.id
for the assistant message produced by this step.
Sourcepub fn new_message_id(&mut self) -> String
pub fn new_message_id(&mut self) -> String
Generate a new message ID.
Sourcepub fn on_agent_event(&mut self, ev: &AgentEvent) -> Vec<Event>
pub fn on_agent_event(&mut self, ev: &AgentEvent) -> Vec<Event>
Convert an AgentEvent to AG-UI protocol compatible events.
Handles full stream lifecycle: text start/end pairs, step counters, terminal event suppression (after Error), and Pending event filtering.
Trait Implementations§
Source§impl Clone for AgUiEventContext
impl Clone for AgUiEventContext
Source§fn clone(&self) -> AgUiEventContext
fn clone(&self) -> AgUiEventContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more