Skip to main content

ToolValueModel

Struct ToolValueModel 

Source
pub struct ToolValueModel {
    pub value_class: ValueClass,
    pub field_groups: BTreeMap<String, FieldGroup>,
    pub cost_model: CostModel,
    pub follow_up: Vec<FollowUpLink>,
    pub invalidates: Vec<String>,
    pub fail_fast_after_n: Option<u32>,
    pub side_effect_class: SideEffectClass,
    pub rate_limit_host: Option<String>,
    pub speculate: Option<bool>,
}
Expand description

Provider-shipped, user-overridable description of how a tool fits into the enrichment knapsack.

Naming contract. Keys in AdaptiveConfig.tools and in the [tools.<name>] TOML section are runtime tool names — exactly what the LLM sends in tool_use.name (Read, Bash, mcp__gitlab__get_issue, …). Do not anonymize them. The mcp__p<hash6>__verb form only appears in the public corpus aggregates under docs/research/data/paper3_*.csv; resolution (AdaptiveConfig::effective_tool_value_model), cross-tool invalidation (invalidates = […]) and the dedup cache all match on the live runtime name, so an anonymized key would never resolve.

Fields§

§value_class: ValueClass

First-pass importance class.

§field_groups: BTreeMap<String, FieldGroup>

Named subsets of the response — must_have, nice_to_have, debug, and any provider-specific groups.

§cost_model: CostModel

Token / latency / freshness model.

§follow_up: Vec<FollowUpLink>

Empirically observed next tools — drives speculative prefetch.

§invalidates: Vec<String>

Tools whose cached responses become stale when this tool runs. Mirrors the existing file-mutation hook in DedupCache: e.g. update_issue.invalidates = ["get_issue", "get_issues"].

§fail_fast_after_n: Option<u32>

After how many consecutive empty (or no-change) calls the planner should stop re-issuing this tool. None = never bail. Set to Some(2) for ToolSearch per the corpus finding that 50%+ of repeated ToolSearch calls return zero results.

§side_effect_class: SideEffectClass

Side-effect classification — gates speculative pre-fetch. Default Indeterminate keeps unannotated tools off the speculation path; only Pure / ReadOnly are eligible.

§rate_limit_host: Option<String>

Optional default host for rate-limit grouping (e.g. "github.com", "api.openai.com", "gitlab.example.com"). The host’s speculative dispatcher caps in-flight prefetches per rate_limit_host; None means no rate budget tracked for this tool.

Static vs runtime. This is the static default. For tools whose target host depends on runtime arguments (e.g. WebFetch where the URL is per-call), the provider’s crate::ToolEnricher::rate_limit_host override returns the runtime value; the static field is only consulted as a fallback.

§speculate: Option<bool>

Per-tool speculation override. When Some(false), the planner is forbidden from speculating this tool even if side_effect_class.is_speculatable(). Set automatically by tune analyze’s R7 rule when the observed prefetch_hit_rate for this tool falls below the floor — i.e. the planner was guessing wrong too often. None = honour side_effect_class.

Implementations§

Source§

impl ToolValueModel

Source

pub fn critical_with_size(typical_kb: f32) -> Self

Ergonomic constructor for the most common case: a critical tool with a known typical size and one likely follow-up.

Source

pub fn audit_only() -> Self

Ergonomic constructor for an audit_only tool (TaskUpdate, TodoWrite). Such tools never enter the knapsack budget.

Source

pub fn excluded_from_budget(&self) -> bool

True iff this tool’s responses should be excluded from the per-turn budget. Used by the planner’s first-pass filter.

Source

pub fn is_speculatable(&self) -> bool

True iff the planner is allowed to issue this tool ahead of the LLM’s next message. Combines side_effect_class with the per-tool speculate override — Some(false) always wins, so tune analyze’s auto-disable rule cannot be bypassed by a stale Pure annotation.

Trait Implementations§

Source§

impl Clone for ToolValueModel

Source§

fn clone(&self) -> ToolValueModel

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 ToolValueModel

Source§

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

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

impl Default for ToolValueModel

Source§

fn default() -> ToolValueModel

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ToolValueModel

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 ToolValueModel

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> 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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