Expand description
§tool-side-effects-tag
Declare what an LLM agent tool actually does so the scheduler / retry layer can make the right decision per-tool.
If your scheduler does not know which tools are reads and which are
writes, it cannot run them in parallel safely. If your retry layer does
not know which tools are idempotent, it cannot retry them safely. This
crate gives you a tiny vocabulary of SideEffect tags plus inspection
helpers that classify a tool as parallel-safe, retry-safe, or
destructive.
The Python sibling uses a function decorator. Rust does not have
decorators, so the idiom here is an associated-metadata pattern: tools
implement HasSideEffects (or hold a Tag / SideEffects) and
the free functions is_parallel_safe, is_retry_safe, and
is_destructive read that set.
§Quick example
use tool_side_effects_tag::{
HasSideEffects, SideEffect, SideEffects,
is_destructive, is_parallel_safe, is_retry_safe,
};
struct SearchWeb;
impl HasSideEffects for SearchWeb {
fn side_effects(&self) -> SideEffects {
let mut s = SideEffects::new();
s.insert(SideEffect::Read);
s
}
}
let tool = SearchWeb;
assert!(is_parallel_safe(&tool.side_effects()));
assert!(is_retry_safe(&tool.side_effects()));
assert!(!is_destructive(&tool.side_effects()));§With a Tag wrapper
use tool_side_effects_tag::{SideEffect, SideEffects, Tag};
let mut effects = SideEffects::new();
effects.insert(SideEffect::Write);
effects.insert(SideEffect::Idempotent);
let upsert = Tag::new("upsert_user", effects);
assert_eq!(*upsert.value(), "upsert_user");
assert!(upsert.effects().contains(SideEffect::Write));§Feature flags
serde— derivesSerialize/DeserializeforSideEffectandSideEffects. Off by default; enable withfeatures = ["serde"].
Structs§
- Parse
Side Effect Error - Error returned by
SideEffect::from_strwhen the input does not match any known tag. - Side
Effects - An unordered set of
SideEffecttags attached to a tool. - Tag
- Pairs any value with a
SideEffectsset. Lets you tag tool handles, closures, command structs, anything.
Enums§
- Side
Effect - Standard side-effect categories for an agent tool.
Traits§
- HasSide
Effects - Implement on a tool type to declare its side-effect surface.
Functions§
- is_
destructive trueiff the set containsSideEffect::Destructive.- is_
parallel_ safe - Safe to run alongside other tools.
- is_
retry_ safe - Safe to auto-retry on transient error.