pub enum ParallelMode {
Sequential,
Parallel,
}Expand description
How independent tool calls within a single turn are dispatched.
Defaults to Sequential;
opt into Parallel
via ParallelDispatchConfig::mode.
Parallel mode runs independent, concurrency-safe calls concurrently (up to
ParallelDispatchConfig::max_concurrency). Sequential mode dispatches one
call at a time. Both modes check the cancel signal between calls.
Variants§
Sequential
Dispatch tool calls one at a time.
Each call in a turn runs to completion before the next begins.
Observers see strictly paired on_tool_pre / on_tool_post
events in call order, and the loop detector sees the classic
[pre A, post A, pre B, post B, …] interleaving.
Choose this when call ordering matters or when
concurrency is unnecessary (e.g. single-call turns, write-heavy
workloads).
Parallel
Dispatch independent, concurrency-safe calls concurrently.
Calls that are safe for concurrent execution (per
Tool::is_safe_for_concurrent_execution)
run in parallel up to
max_concurrency, while
non-safe calls and resource-conflicting calls are serialized into
separate waves. Observers see batched PRE events (all on_tool_pre
in input order) then batched POST events — see the dispatch module
docs for the ordering invariant. Choose this for read-heavy,
multi-call turns where latency is the sum of independent operations.
§Side-effects (same granularity in both modes)
Detection, observer, hook, and health side-effects all fire on every
retry attempt in both modes. A tool that fails twice then succeeds
produces 3 detection operations, 3 observer PRE+POST pairs, and 3 health
recordings regardless of ParallelMode. All four side-effect targets are
thread-safe (DetectionManager
and the observer registry use
Mutex/immutable-Vec interiors;
ToolHealthRegistry uses
atomic counters), so concurrent retry attempts in Parallel mode dispatch
side-effects safely without serialization.
The only retry-related difference between modes is interleaving, not
granularity: in Sequential the classic [pre A, post A, pre B, post B]
order is strict, while in Parallel the PRE/POST events for independent
calls in the same wave interleave as those calls progress concurrently.
Observers that pair on_tool_pre/on_tool_post should key on
tool_call_id (carried in both contexts), not on arrival order.
Trait Implementations§
Source§impl Clone for ParallelMode
impl Clone for ParallelMode
Source§fn clone(&self) -> ParallelMode
fn clone(&self) -> ParallelMode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ParallelMode
Source§impl Debug for ParallelMode
impl Debug for ParallelMode
Source§impl<'de> Deserialize<'de> for ParallelMode
impl<'de> Deserialize<'de> for ParallelMode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ParallelMode
Source§impl PartialEq for ParallelMode
impl PartialEq for ParallelMode
Source§impl Serialize for ParallelMode
impl Serialize for ParallelMode
impl StructuralPartialEq for ParallelMode
Auto Trait Implementations§
impl Freeze for ParallelMode
impl RefUnwindSafe for ParallelMode
impl Send for ParallelMode
impl Sync for ParallelMode
impl Unpin for ParallelMode
impl UnsafeUnpin for ParallelMode
impl UnwindSafe for ParallelMode
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
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.