pub struct Event {
pub id: String,
pub timestamp: DateTime<Utc>,
pub invocation_id: String,
pub branch: String,
pub author: String,
pub llm_response: LlmResponse,
pub actions: EventActions,
pub long_running_tool_ids: Vec<String>,
pub llm_request: Option<String>,
pub provider_metadata: HashMap<String, String>,
}Expand description
Core traits and types.
Always available regardless of feature flags. Includes:
Agent- The fundamental trait for all agentsTool/Toolset- For extending agents with capabilitiesSession/State- For managing conversation contextEvent- For streaming agent responsesAdkError/Result- Unified error handling Event represents a single interaction in a conversation. This struct embeds LlmResponse to match ADK-Go’s design pattern.
Fields§
§id: StringUnique identifier for this event.
timestamp: DateTime<Utc>When this event was created.
invocation_id: StringThe invocation that produced this event.
branch: StringThe conversation branch this event belongs to.
The agent or role that authored this event.
llm_response: LlmResponseThe LLM response containing content and metadata.
Access content via event.llm_response.content.
actions: EventActionsActions to apply (state changes, transfers, confirmations).
long_running_tool_ids: Vec<String>IDs of long-running tools associated with this event.
llm_request: Option<String>LLM request data for UI display (JSON string)
provider_metadata: HashMap<String, String>Provider-specific metadata (e.g., GCP Vertex, Azure OpenAI).
Keeps the core Event struct provider-agnostic.
Serialized as "event_metadata" to avoid collision with
LlmResponse::provider_metadata when flattened.
Implementations§
Source§impl Event
impl Event
Sourcepub fn new(invocation_id: impl Into<String>) -> Event
Available on crate feature sessions only.
pub fn new(invocation_id: impl Into<String>) -> Event
sessions only.Creates a new event with a generated UUID and current timestamp.
Sourcepub fn with_id(id: impl Into<String>, invocation_id: impl Into<String>) -> Event
Available on crate feature sessions only.
pub fn with_id(id: impl Into<String>, invocation_id: impl Into<String>) -> Event
sessions only.Create an event with a specific ID. Use this for streaming events where all chunks should share the same event ID.
Sourcepub fn tool_progress(
invocation_id: impl Into<String>,
author: impl Into<String>,
function_call_id: impl Into<String>,
stream: impl Into<String>,
chunk: impl Into<String>,
) -> Event
Available on crate feature sessions only.
pub fn tool_progress( invocation_id: impl Into<String>, author: impl Into<String>, function_call_id: impl Into<String>, stream: impl Into<String>, chunk: impl Into<String>, ) -> Event
sessions only.Creates a streaming tool-progress event.
Tools emit these via ToolContext::emit_progress
to push intermediate stdout/stderr to the client while the tool is still
running. The event carries the chunk as partial text content (role
"tool") and is tagged with TOOL_PROGRESS_STREAM_KEY /
TOOL_PROGRESS_CALL_ID_KEY so consumers can distinguish it from a
final tool result and route it to the right terminal widget.
§Example
use adk_core::Event;
let event = Event::tool_progress("inv-1", "agent", "call-7", "stdout", "compiling...\n");
assert_eq!(event.tool_progress_stream(), Some("stdout"));
assert!(event.llm_response.partial);Sourcepub fn tool_progress_stream(&self) -> Option<&str>
Available on crate feature sessions only.
pub fn tool_progress_stream(&self) -> Option<&str>
sessions only.Returns the progress stream name ("stdout", "stderr", …) if this is a
tool-progress event produced by ToolContext::emit_progress,
otherwise None.
Sourcepub fn tool_calls(&self) -> Vec<ToolCallView<'_>>
Available on crate feature sessions only.
pub fn tool_calls(&self) -> Vec<ToolCallView<'_>>
sessions only.Returns the tool calls carried by this event, as a typed, render-ready view.
A UI consuming the agent’s EventStream can call this on every event to
detect when the model requested one or more tools, without matching on
Part::FunctionCall internals. Pair it with
tool_results and tool_progress_stream
to render a complete tool lifecycle (call → live progress → result).
Returns an empty vector for events that contain no tool calls.
§Correlation
Use ToolCallView::call_id to correlate a call with its progress chunks
and final result. For providers that omit call ids (e.g. Gemini), fall
back to ToolCallView::name.
§Example
use adk_core::{Content, Event, Part};
let mut event = Event::new("inv-1");
event.llm_response.content = Some(Content {
role: "model".to_string(),
parts: vec![Part::FunctionCall {
name: "bash".to_string(),
args: serde_json::json!({ "command": "ls" }),
id: Some("call_1".to_string()),
thought_signature: None,
}],
});
let calls = event.tool_calls();
assert_eq!(calls.len(), 1);
assert_eq!(calls[0].name, "bash");
assert_eq!(calls[0].call_id, Some("call_1"));Sourcepub fn tool_results(&self) -> Vec<ToolResultView<'_>>
Available on crate feature sessions only.
pub fn tool_results(&self) -> Vec<ToolResultView<'_>>
sessions only.Returns the tool results carried by this event, as a typed, render-ready view.
After a tool executes, the agent yields its result on the same
EventStream as everything else, as a function-role event holding a
Part::FunctionResponse. This accessor
surfaces those results generically so a UI can render the output of any
tool — streaming or not — without walking part internals.
Returns an empty vector for events that contain no tool results.
§Correlation
Use ToolResultView::call_id to attach a result to the originating
tool_calls entry and its progress chunks. For
providers that omit call ids, fall back to ToolResultView::name.
§Example
use adk_core::{Content, Event, FunctionResponseData, Part};
let mut event = Event::new("inv-1");
event.llm_response.content = Some(Content {
role: "function".to_string(),
parts: vec![Part::FunctionResponse {
function_response: FunctionResponseData::new(
"bash",
serde_json::json!({ "stdout": "ok\n", "exit_code": 0 }),
),
id: Some("call_1".to_string()),
annotations: None,
}],
});
let results = event.tool_results();
assert_eq!(results.len(), 1);
assert_eq!(results[0].name, "bash");
assert_eq!(results[0].call_id, Some("call_1"));
assert_eq!(results[0].response["exit_code"], 0);Sourcepub fn content(&self) -> Option<&Content>
Available on crate feature sessions only.
pub fn content(&self) -> Option<&Content>
sessions only.Convenience method to access content directly.
Sourcepub fn set_content(&mut self, content: Content)
Available on crate feature sessions only.
pub fn set_content(&mut self, content: Content)
sessions only.Convenience method to set content directly.
Sourcepub fn interaction_id(&self) -> Option<&str>
Available on crate feature sessions only.
pub fn interaction_id(&self) -> Option<&str>
sessions only.Returns the Interactions API interaction id for this event, if present.
Reads the id from the flattened LlmResponse, mirroring ADK-Python’s
event.interaction_id. Returns None for events produced by the
generateContent transport and non-Gemini providers.
§Example
use adk_core::Event;
let mut event = Event::new("inv-123");
assert_eq!(event.interaction_id(), None);
event.llm_response.interaction_id = Some("v1_abc".to_string());
assert_eq!(event.interaction_id(), Some("v1_abc"));Sourcepub fn is_final_response(&self) -> bool
Available on crate feature sessions only.
pub fn is_final_response(&self) -> bool
sessions only.Returns whether the event is the final response of an agent.
Tool-start notifications, provider-native continuation pauses and compaction records
(EventActions::compaction) are not final.
An event is considered final if:
- It has skip_summarization set, OR
- It has long_running_tool_ids (indicating async operations), OR
- It has no function calls, no function responses, is not partial, and has no trailing code execution results.
Note: When multiple agents participate in one invocation, there could be multiple events with is_final_response() as true, for each participating agent.
Sourcepub fn function_call_ids(&self) -> Vec<String>
Available on crate feature sessions only.
pub fn function_call_ids(&self) -> Vec<String>
sessions only.Extracts function call IDs from this event’s content. Used to identify which function calls are associated with long-running tools.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Event
impl<'de> Deserialize<'de> for Event
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Event, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Event, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Event
impl Serialize for Event
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Forget for Event
impl Freeze for Eventwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
NonZero<i32>: Freeze,
Utc: Freeze,
PhantomData<Part>: Freeze,
PhantomData<Value>: Freeze,
PhantomData<usize>: Freeze,
PhantomData<Bucket<String, Value>>: Freeze,
PhantomData<BuiltinToolUse>: Freeze,
PhantomData<CitationSource>: Freeze,
PhantomData<(String, Value)>: Freeze,
PhantomData<(String, i64)>: Freeze,
*const ActingContext is !null: Freeze,
PhantomData<ActingContext>: Freeze,
PhantomData<Evidence>: Freeze,
PhantomData<String>: Freeze,
PhantomData<(String, WorkflowPosition)>: Freeze,
PhantomData<GroundingSource>: Freeze,
PhantomData<(String, String)>: Freeze,
impl Move for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin for Eventwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
NonZeroI32Inner: UnsafeUnpin,
Utc: UnsafeUnpin,
PhantomData<Part>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
PhantomData<Bucket<String, Value>>: UnsafeUnpin,
PhantomData<BuiltinToolUse>: UnsafeUnpin,
PhantomData<CitationSource>: UnsafeUnpin,
PhantomData<(String, Value)>: UnsafeUnpin,
PhantomData<(String, i64)>: UnsafeUnpin,
*const ActingContext is !null: UnsafeUnpin,
PhantomData<ActingContext>: UnsafeUnpin,
PhantomData<Evidence>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<(String, WorkflowPosition)>: UnsafeUnpin,
PhantomData<GroundingSource>: UnsafeUnpin,
PhantomData<(String, String)>: UnsafeUnpin,
impl UnwindSafe for Eventwhere
RawVecInner: UnwindSafe,
NonZero<i32>: UnwindSafe,
Utc: UnwindSafe,
NonNull<u8>: UnwindSafe,
HashMap<String, Value>: UnwindSafe,
HashMap<String, i64>: UnwindSafe,
BoxRaw<ActingContext>: UnwindSafe,
HashMap<String, WorkflowPosition>: UnwindSafe,
HashMap<String, String>: UnwindSafe,
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.