#[non_exhaustive]pub enum Composable {
Agent(AgentBuilder),
Pipeline(Pipeline),
FanOut(FanOut),
Loop(Loop),
Fallback(Fallback),
MapOver(MapOver),
Branch(Branch),
Transform(StateComposite),
}Expand description
A composable workflow node — can be sequenced, fan-out, looped, etc.
New node kinds may be added, so a match needs a _ arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Agent(AgentBuilder)
A single agent node.
Pipeline(Pipeline)
A sequential pipeline of steps.
FanOut(FanOut)
A parallel fan-out of branches.
Loop(Loop)
A loop with optional termination predicate.
Fallback(Fallback)
A fallback chain (try each until one succeeds).
MapOver(MapOver)
One agent applied to every item of a state list
(patterns::map_over).
Branch(Branch)
Run one of two workflows, chosen by a state predicate
(patterns::conditional).
Transform(StateComposite)
Reshape state between steps with an S transform chain
(agent >> S::pick(..) >> agent). The pipeline’s input passes
through unchanged.
Implementations§
Source§impl Composable
impl Composable
Sourcepub fn compile(
self,
llm: Arc<dyn BaseLlm>,
) -> Result<Arc<dyn TextAgent>, ConfigError>
pub fn compile( self, llm: Arc<dyn BaseLlm>, ) -> Result<Arc<dyn TextAgent>, ConfigError>
Compile this composable tree into an executable TextAgent.
Recursively compiles the tree: pipelines become SequentialTextAgent,
fan-outs become ParallelTextAgent, loops become LoopTextAgent,
fallbacks become FallbackTextAgent, map-overs become
MapOverTextAgent, and agents compile via AgentBuilder::build() —
whose ConfigError (an MCP toolset on a text agent) is the only way
this fails.
let pipeline = AgentBuilder::new("writer").instruction("Write a draft")
>> AgentBuilder::new("reviewer").instruction("Review and improve");
let agent = pipeline.compile(llm)?;
let state = State::new();
let result = agent.run(&state).await?;Source§impl Composable
impl Composable
Sourcepub fn middleware(self, middleware: impl Into<MiddlewareComposite>) -> Self
pub fn middleware(self, middleware: impl Into<MiddlewareComposite>) -> Self
Attach middleware to a Loop or Fallback node — the place where
combinator-level observers (M::on_loop, M::on_fallback) live.
For other node kinds (single agent, pipeline, fan-out, map-over) this
is a no-op: attach M:: middleware to the agent itself via
AgentBuilder::middleware instead.
Source§impl Composable
impl Composable
Sourcepub fn first_step(&self) -> Option<&Composable>
pub fn first_step(&self) -> Option<&Composable>
The first step of a Pipeline, or None if this is not a pipeline
(or the pipeline is empty).
Sourcepub fn last_step(&self) -> Option<&Composable>
pub fn last_step(&self) -> Option<&Composable>
The last step of a Pipeline, or None if this is not a pipeline
(or the pipeline is empty).
Sourcepub fn nth_step(&self, n: usize) -> Option<&Composable>
pub fn nth_step(&self, n: usize) -> Option<&Composable>
The nth step of a Pipeline, or None if this is not a pipeline
or the index is out of bounds.
Sourcepub fn pipeline_steps(&self) -> Option<&[Composable]>
pub fn pipeline_steps(&self) -> Option<&[Composable]>
All steps of a Pipeline, or None if this is not a pipeline.
Sourcepub fn fan_out_branches(&self) -> Option<&[Composable]>
pub fn fan_out_branches(&self) -> Option<&[Composable]>
The branches of a FanOut, or None if this is not a fan-out.
Sourcepub fn loop_predicate(&self) -> Option<&LoopPredicate>
pub fn loop_predicate(&self) -> Option<&LoopPredicate>
The termination predicate of a Loop, or None if this is not a loop
(or the loop has no predicate).
Sourcepub fn loop_body(&self) -> Option<&Composable>
pub fn loop_body(&self) -> Option<&Composable>
The body of a Loop, or None if this is not a loop.
Sourcepub fn fallback_candidates(&self) -> Option<&[Composable]>
pub fn fallback_candidates(&self) -> Option<&[Composable]>
The candidates of a Fallback chain, or None if this is not a fallback.
Trait Implementations§
Source§impl BitOr for Composable
Composable | Composable → FanOut (flattening)
impl BitOr for Composable
Composable | Composable → FanOut (flattening)
Source§type Output = Composable
type Output = Composable
| operator.Source§impl BitOr<AgentBuilder> for Composable
Composable | AgentBuilder → FanOut (flattening)
impl BitOr<AgentBuilder> for Composable
Composable | AgentBuilder → FanOut (flattening)
Source§type Output = Composable
type Output = Composable
| operator.Source§impl Clone for Composable
impl Clone for Composable
Source§fn clone(&self) -> Composable
fn clone(&self) -> Composable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Composable
impl Debug for Composable
Source§impl Div for Composable
Composable / Composable → Fallback (flattening)
impl Div for Composable
Composable / Composable → Fallback (flattening)
Source§type Output = Composable
type Output = Composable
/ operator.Source§impl Div<AgentBuilder> for Composable
Composable / AgentBuilder → Fallback (flattening)
impl Div<AgentBuilder> for Composable
Composable / AgentBuilder → Fallback (flattening)
Source§type Output = Composable
type Output = Composable
/ operator.Source§impl From<AgentBuilder> for Composable
impl From<AgentBuilder> for Composable
Source§fn from(b: AgentBuilder) -> Self
fn from(b: AgentBuilder) -> Self
Source§impl From<Branch> for Composable
impl From<Branch> for Composable
Source§impl From<Fallback> for Composable
impl From<Fallback> for Composable
Source§impl From<FanOut> for Composable
impl From<FanOut> for Composable
Source§impl From<Loop> for Composable
impl From<Loop> for Composable
Source§impl From<MapOver> for Composable
impl From<MapOver> for Composable
Source§impl From<Pipeline> for Composable
impl From<Pipeline> for Composable
Source§impl From<StateComposite> for Composable
impl From<StateComposite> for Composable
Source§fn from(transform: StateComposite) -> Self
fn from(transform: StateComposite) -> Self
Source§impl From<StateTransform> for Composable
impl From<StateTransform> for Composable
Source§fn from(transform: StateTransform) -> Self
fn from(transform: StateTransform) -> Self
Source§impl Mul<LoopPredicate> for Composable
Composable * until(pred) → conditional Loop
impl Mul<LoopPredicate> for Composable
Composable * until(pred) → conditional Loop
Source§type Output = Composable
type Output = Composable
* operator.Source§impl Mul<u32> for Composable
Composable * 3 → Loop(max=3)
impl Mul<u32> for Composable
Composable * 3 → Loop(max=3)
Source§impl Shr for Composable
Composable >> Composable → Pipeline (flattening)
impl Shr for Composable
Composable >> Composable → Pipeline (flattening)
Source§type Output = Composable
type Output = Composable
>> operator.Source§impl Shr<AgentBuilder> for Composable
Composable >> AgentBuilder → Pipeline (flattening)
impl Shr<AgentBuilder> for Composable
Composable >> AgentBuilder → Pipeline (flattening)
Source§type Output = Composable
type Output = Composable
>> operator.Source§impl Shr<Composable> for StateTransform
A state transform as a pipeline step: a >> S::pick(..) >> b.
impl Shr<Composable> for StateTransform
A state transform as a pipeline step: a >> S::pick(..) >> b.
Source§type Output = Composable
type Output = Composable
>> operator.Source§impl Shr<Composable> for StateComposite
A state transform as a pipeline step: a >> S::pick(..) >> b.
impl Shr<Composable> for StateComposite
A state transform as a pipeline step: a >> S::pick(..) >> b.
Source§type Output = Composable
type Output = Composable
>> operator.Source§impl Shr<Composable> for AgentBuilder
AgentBuilder >> Composable → Pipeline (flattening)
impl Shr<Composable> for AgentBuilder
AgentBuilder >> Composable → Pipeline (flattening)
Source§type Output = Composable
type Output = Composable
>> operator.Source§impl Shr<StateComposite> for Composable
A state transform as a pipeline step: a >> S::pick(..) >> b.
impl Shr<StateComposite> for Composable
A state transform as a pipeline step: a >> S::pick(..) >> b.
Source§type Output = Composable
type Output = Composable
>> operator.Source§impl Shr<StateTransform> for Composable
A state transform as a pipeline step: a >> S::pick(..) >> b.
impl Shr<StateTransform> for Composable
A state transform as a pipeline step: a >> S::pick(..) >> b.
Source§type Output = Composable
type Output = Composable
>> operator.Auto Trait Implementations§
impl !RefUnwindSafe for Composable
impl !UnwindSafe for Composable
impl Freeze for Composable
impl Send for Composable
impl Sync for Composable
impl Unpin for Composable
impl UnsafeUnpin for Composable
Blanket Implementations§
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
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<T> FmtForward for T
impl<T> FmtForward for T
§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.§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.§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.§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.§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.§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.§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.§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.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§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 more§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 more§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
§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
§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.§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.§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.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§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 more§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 more§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 more§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 more§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 more§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 more§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.§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.§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.§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.§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.§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.§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.