EventActions

Struct EventActions 

Source
pub struct EventActions {
    pub escalate: bool,
    pub skip_summarization: bool,
    pub transfer_to_agent: Option<String>,
    pub state_delta: HashMap<String, Value>,
}
Expand description

Actions triggered by an event — control flow and state mutations.

Fields§

§escalate: bool

If true, escalate to a human or parent agent.

§skip_summarization: bool

If true, skip summarization of this event’s content.

§transfer_to_agent: Option<String>

Transfer control to another agent by name.

§state_delta: HashMap<String, Value>

State mutations (delta key → new value).

Deletions travel in here too, under the reserved Self::REMOVED_KEYS entry — see that constant for why they are not spelled as null. State keys are written through Self::encode_key and read back through Self::decode_key, so a state key that collides with a reserved name is carried rather than lost, and Self::FORMAT marks a delta that went through that encoding so a pre-1.0.1 one is read literally.

Implementations§

Source§

impl EventActions

Source

pub const REMOVED_KEYS: &'static str = "adk:removed"

Reserved state_delta entry carrying the keys an event deleted, as a JSON array of strings.

Deletion needs its own channel because null is a perfectly ordinary value an agent may store deliberately: using it as the tombstone made replay drop a real null, so persistence was not round-trip lossless for valid State. It rides inside state_delta rather than as a sibling field so that EventActions stays constructible by downstream code that already names every field.

State accepts arbitrary keys, so this name is not reserved from applications — it is escaped around them by Self::encode_key. It is only read as a removal list on an event that carries Self::FORMAT.

Source

pub const FORMAT: &'static str = "adk:format"

Reserved state_delta entry marking an event whose keys went through Self::encode_key and whose removals live at Self::REMOVED_KEYS.

Events written before 1.0.1 have no such marker and no escaping: every entry in them is a literal state key, including one that happens to be named adk:removed or to end in :literal. Without this discriminator there is nothing in the delta itself to tell the two eras apart, and decoding a legacy event would shift those keys or read a stored array as a deletion list. Replay therefore decodes only marked events.

A residue is structural: the marker shares the arbitrary key/value space of the deltas it discriminates, so a legacy event that stored exactly Self::FORMAT_VERSION at exactly this key would still be misread. Closing that completely takes a field outside state_delta, which EventActions cannot grow without breaking source compatibility — so the marker value is chosen to make the collision unreachable in practice rather than merely unlikely.

Source

pub const FORMAT_VERSION: &'static str = "gemini-adk/state-delta/1"

Value written at Self::FORMAT by this version.

A sentinel string rather than a version number: a plain 1 is a value an application could conceivably have stored under its own key, whereas this one only appears if someone wrote this crate’s marker by hand.

Source

pub fn transfer(agent_name: impl Into<String>) -> Self

Create actions that transfer to another agent.

Source

pub fn escalate() -> Self

Create actions that escalate.

Source

pub fn state_delta(delta: HashMap<String, Value>) -> Self

Create actions with a state delta.

Source

pub fn state_removed(keys: impl IntoIterator<Item = String>) -> Self

Create actions that remove keys from state.

Source

pub fn mark_format(&mut self)

Stamp Self::FORMAT on this delta, declaring its keys encoded and its Self::REMOVED_KEYS entry a removal list.

Source

pub fn is_format_marked(&self) -> bool

True when this delta carries a Self::FORMAT marker this build understands — i.e. it was written by 1.0.1 or later.

An unmarked delta is a legacy one: every entry in it is a literal state key and it has no removal channel. A marker from a newer format than this build knows also reads as unmarked, so a forward-dated event is replayed literally rather than decoded under the wrong rules.

Source

pub fn removed_keys(&self) -> impl Iterator<Item = &str>

The state keys this event deletes, drawn from Self::REMOVED_KEYS.

Always empty on a delta without Self::FORMAT: a legacy event that happens to hold an array of strings at that key stored it as a value, and replaying it as a deletion list would delete every key it names.

Source

pub fn encode_key(key: &str) -> Cow<'_, str>

Map a state key to the state_delta key that carries it.

Ordinary keys pass through. A key that would land on a reserved entry — adk:removed or adk:format, or an already-escaped form of either followed by any number of :literal suffixes — gains one more :literal. That ladder is injective and never produces a bare reserved name, so both channels stay free without any state key being dropped or overwritten.

Source

pub fn decode_key(key: &str) -> Cow<'_, str>

Inverse of Self::encode_key: recover the state key a state_delta entry carries.

Apply this only to a delta where Self::is_format_marked holds. On a legacy delta every key is already literal, and stripping a :literal suffix there would rename a state key the application chose.

Trait Implementations§

Source§

impl Clone for EventActions

Source§

fn clone(&self) -> EventActions

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EventActions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EventActions

Source§

fn default() -> EventActions

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for EventActions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for EventActions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,