Skip to main content

GoalRuntimeHandle

Struct GoalRuntimeHandle 

Source
pub struct GoalRuntimeHandle { /* private fields */ }
Expand description

Per-session goal lifecycle manager.

Drives auto-continuation, status transitions, and steering prompt injection. All mutations go through with_goal_state which serializes access via a dedicated state lock, preventing external set/clear calls from interfering with continue_if_idle.

Implementations§

Source§

impl GoalRuntimeHandle

Source

pub fn new(initial_goal: Option<SessionGoal>) -> Self

Creates a new runtime handle with an optional initial goal.

Source

pub fn get_goal(&self) -> Option<SessionGoal>

Returns the current goal, if any.

Source

pub fn set_session_id(&self, session_id: impl Into<String>)

Binds this runtime to a session id and rewrites any loaded goal to match.

Source

pub fn set_objective( &self, objective: String, token_budget: Option<i64>, ) -> SessionGoal

Sets or replaces the goal.

Source

pub fn set_objective_with_short_description( &self, objective: String, short_description: Option<String>, token_budget: Option<i64>, ) -> SessionGoal

Sets or replaces the goal with an optional compact UI label.

When a goal already exists, mutates it in place (same goal_id) and re-activates it — used by host/SDK set_goal. Model create_goal must call [create_new_goal] so terminal goals get a fresh id.

Source

pub fn create_new_goal( &self, objective: String, short_description: Option<String>, token_budget: Option<i64>, ) -> SessionGoal

Creates a brand-new active goal (new goal_id), replacing any prior goal.

Caller must ensure there is no unfinished goal when this is used from the model-facing create_goal tool.

Source

pub fn update_goal(&self, goal: SessionGoal)

Updates the stored goal (used after status transitions).

Source

pub fn clear_goal(&self)

Clears the current goal.

Source

pub fn update_checklist(&self, tasks: Vec<GoalTask>) -> Option<SessionGoal>

Updates the checklist on the current goal. Returns the updated goal if successful.

Source

pub fn update_task_status( &self, task_id: usize, status: TaskStatus, ) -> Option<SessionGoal>

Updates a single task’s status in the goal checklist.

Source

pub fn start_turn(&self)

Starts turn accounting for the active goal.

Source

pub fn record_tokens(&self, delta: i64) -> bool

Records token usage during a turn.

Source

pub fn finish_turn(&self)

Finishes turn accounting and updates the stored goal.

Source

pub fn record_blocked_turn(&self, reason: &str) -> bool

Transitions the goal to Blocked after consecutive blocked turns.

Source

pub fn mark_usage_limited(&self)

Transitions the goal to UsageLimited.

Source

pub fn continue_if_idle(&self) -> Option<String>

If the goal is active and should auto-continue, returns a steering continuation prompt to inject into the conversation. Acquires the state lock to prevent race conditions with concurrent set/clear operations.

Source

pub fn budget_limit_prompt(&self) -> Option<String>

Returns a budget-limit steering prompt if the budget is exceeded.

Source

pub fn objective_updated_prompt(&self) -> Option<String>

Returns an objective-updated steering prompt.

Source

pub fn set_auto_continue(&self, enabled: bool)

Enables or disables auto-continuation.

Source

pub fn is_terminal(&self) -> bool

Returns true if the goal is in a terminal state.

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T

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

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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<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