Skip to main content

Effect

Enum Effect 

Source
#[non_exhaustive]
pub enum Effect { Llm(LlmRequest), Tool { name: String, args: Value, }, Graph { graph: Box<Graph>, input: Value, mode: GraphEffectMode, }, Sleep(Duration), Custom { kind: String, payload: Value, }, }
Expand description

Something the runtime does on a step’s behalf.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Llm(LlmRequest)

Call a language model.

§

Tool

Invoke a registered tool.

Fields

§name: String

The name the tool was registered under — a ToolSpec::name.

§args: Value

Arguments, as JSON shaped by the tool’s ToolSpec::input_schema.

§

Graph

Run a Soma graph and hand back its output.

This is the bridge that makes a computational pipeline a first-class tool for an agent: it runs through the ordinary compiler and executor, with the ordinary cache, and the agent just sees a result.

Fields

§graph: Box<Graph>

The graph to run. Structure travels in the effect itself, so the handler needs no registry lookup to know what it is performing — only the node implementations are resolved on the other side.

§input: Value

The input handed to the sub-graph’s root nodes.

§mode: GraphEffectMode

Forward with the states already fitted, or fit first.

§

Sleep(Duration)

Wait. Journaled like anything else, so a replay does not sleep again.

§

Custom

An effect this runtime doesn’t know about, for host-supplied handlers.

Fields

§kind: String

Which handler this is meant for — the string EffectHandler::handles implementations match on.

§payload: Value

Whatever that handler expects.

Implementations§

Source§

impl Effect

Source

pub fn label(&self) -> String

A short label for events and logs. Never includes the payload — a prompt is not something to leak into a log line.

Source

pub fn is_pure(&self) -> bool

Is this effect safe to memoize by content?

Pure effects are cached like any filter output: same input, same result, reused forever. Impure ones are still journaled — recorded once per (node, turn) so a replay is faithful — but never reused across runs, because “the same question asked twice” is genuinely a different event for a model call or a clock read.

Source

pub fn cache_key(&self) -> Result<CacheKey>

Content hash, used as the journal key for this effect.

Canonical CBOR, not raw serializer output: an effect carries user-supplied JSON (Tool { args }, Custom { payload }), and two encodings of the same object must not produce two journal keys.

Fallible on purpose. The previous encoding fell back to empty bytes, which gave every unserializable effect the same key — a replay would then serve one effect’s recorded result to another. A key that cannot be computed has to mean “not journalable”, never a guess.

Trait Implementations§

Source§

impl Clone for Effect

Source§

fn clone(&self) -> Effect

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Effect

Source§

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

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

impl<'de> Deserialize<'de> for Effect

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 Effect

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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

The receiver as &dyn Any, ready for downcast_ref.
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.
Source§

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