Skip to main content

RunSpec

Struct RunSpec 

Source
pub struct RunSpec {
    pub prompt: String,
    pub session_name: String,
    pub effort: Option<Effort>,
    pub deadline: Option<Duration>,
    pub tool_budget: Option<usize>,
    pub token_budget: Option<u64>,
    pub budget: Option<BudgetPool>,
}
Expand description

One run’s worth of intent, to be minted against a Workspace.

Built the way every other config in basis is built — new plus with_* methods that return new values — so a caller can keep one spec as a template and derive each run’s from it without the derivations interfering.

A bare prompt converts, because that is the common case:

let run = workspace.prepare("what does this repo do?")?;

Fields§

§prompt: String

What to ask. May be empty: a conversation opened before anything is typed is a real state, and the check happens where a prompt is actually sent — see Workspace::prepare.

§session_name: String§effort: Option<Effort>

How hard the model should think. None leaves the provider’s default; unsupported provider/model levels fail instead of being downgraded.

§deadline: Option<Duration>

Gives up on the run after this long.

Unset by default, and unset for an unattended caller too. An attended run has a person watching, who can tell “thinking hard” from “stuck” in a way no timer can; a caller nobody is watching has to write the bound down in advance, and with no scheduler shipped there is no period for basis to guess one from (ADR-0014).

§tool_budget: Option<usize>

Caps how many tool calls the run may make.

§token_budget: Option<u64>

Caps the tokens the run may report using, input plus output.

Soft by construction: usage is only known once a round has streamed in full, so the round that crosses the line always finishes. This is the bound that maps to money.

§budget: Option<BudgetPool>

An allowance this run shares with the others drawing on it.

Where token_budget is this run’s own ceiling, a BudgetPool is the job’s — the one figure a fan-out spends from together. A spec carrying both stops at whichever binds first.

The one field here that is shared rather than copied: deriving a second spec from this one gives it a handle on the same pool, which is the point. See BudgetPool for why that exception exists and what it costs.

Implementations§

Source§

impl RunSpec

Source

pub fn new(prompt: impl Into<String>) -> Self

Source

pub fn with_prompt(self, prompt: impl Into<String>) -> Self

Source

pub fn with_session_name(self, session_name: impl Into<String>) -> Self

Source

pub fn with_effort(self, effort: Effort) -> Self

Asks the model to think harder, where the provider supports it.

Source

pub fn with_deadline(self, deadline: Duration) -> Self

Gives up on the run after deadline.

Every bound here is a graceful end rather than a discarded run: the event stream closes the way it always does, and whatever the model committed before the bound tripped is kept. That is what makes bounding an unattended run safe to do — the alternative, throwing the work away for being one round too long, would make callers reluctant to set one.

Source

pub fn with_tool_budget(self, tool_budget: usize) -> Self

Caps how many tool calls the run may make.

Source

pub fn with_token_budget(self, token_budget: u64) -> Self

Caps the tokens the run may report using, input plus output.

Soft: the round that crosses the line is allowed to finish, because usage is only known once a round has streamed in full.

Source

pub fn with_budget(self, budget: BudgetPool) -> Self

Draws this run’s tokens from an allowance shared with other runs.

The line a fan-out is written on — BudgetPool::spec is this call with the prompt folded in:

let pool = BudgetPool::new(500_000);
let run = workspace.prepare(RunSpec::new("review the tests").with_budget(pool.clone()))?;

Every turn the minted run performs draws here, not just the first, so a conversation and a one-shot are bounded the same way.

Source

pub fn turn_options(&self) -> TurnOptions

The bounds this spec puts on every turn the run performs.

Limits only. Cancellation and the graceful stop signal are per-call things a caller holds a token for, not configuration, so they stay at their defaults here and arrive through send_with_options.

Trait Implementations§

Source§

impl Clone for RunSpec

Source§

fn clone(&self) -> RunSpec

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 RunSpec

Source§

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

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

impl Default for RunSpec

A run with nothing said yet — what a protocol server opens on session/new.

Source§

fn default() -> Self

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

impl Eq for RunSpec

Source§

impl From<&str> for RunSpec

Source§

fn from(prompt: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for RunSpec

Source§

fn from(prompt: String) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for RunSpec

Source§

fn eq(&self, other: &RunSpec) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RunSpec

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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