Skip to main content

Crate tool_side_effects_tag

Crate tool_side_effects_tag 

Source
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 — derives Serialize / Deserialize for SideEffect and SideEffects. Off by default; enable with features = ["serde"].

Structs§

ParseSideEffectError
Error returned by SideEffect::from_str when the input does not match any known tag.
SideEffects
An unordered set of SideEffect tags attached to a tool.
Tag
Pairs any value with a SideEffects set. Lets you tag tool handles, closures, command structs, anything.

Enums§

SideEffect
Standard side-effect categories for an agent tool.

Traits§

HasSideEffects
Implement on a tool type to declare its side-effect surface.

Functions§

is_destructive
true iff the set contains SideEffect::Destructive.
is_parallel_safe
Safe to run alongside other tools.
is_retry_safe
Safe to auto-retry on transient error.