Phase

Struct Phase 

Source
pub struct Phase {
Show 16 fields pub name: String, pub instruction: PhaseInstruction, pub tools_enabled: Option<Vec<String>>, pub guard: Option<Arc<dyn Fn(&State) -> bool + Send + Sync>>, pub on_enter: Option<Arc<dyn Fn(State, Arc<dyn SessionWriter>) -> BoxFuture<()> + Send + Sync>>, pub on_exit: Option<Arc<dyn Fn(State, Arc<dyn SessionWriter>) -> BoxFuture<()> + Send + Sync>>, pub transitions: Vec<Transition>, pub terminal: bool, pub modifiers: Vec<InstructionModifier>, pub prompt_on_enter: bool, pub on_enter_context: Option<Arc<dyn Fn(&State, &TranscriptWindow) -> Option<Vec<Content>> + Send + Sync>>, pub needs: Vec<String>, pub requires: Vec<String>, pub preparations: Vec<PhasePreparation>, pub presents: Vec<String>, pub clear_on_enter: Vec<String>,
}
Expand description

A conversation phase with instruction, tools, and transitions.

Fields§

§name: String

Unique name identifying this phase.

§instruction: PhaseInstruction

The instruction (system prompt fragment) for this phase.

§tools_enabled: Option<Vec<String>>

Tool filter — None means all tools are allowed.

§guard: Option<Arc<dyn Fn(&State) -> bool + Send + Sync>>

Optional guard: phase can only be entered when this returns true.

§on_enter: Option<Arc<dyn Fn(State, Arc<dyn SessionWriter>) -> BoxFuture<()> + Send + Sync>>

Async callback executed when entering this phase.

§on_exit: Option<Arc<dyn Fn(State, Arc<dyn SessionWriter>) -> BoxFuture<()> + Send + Sync>>

Async callback executed when leaving this phase.

§transitions: Vec<Transition>

Ordered list of outbound transitions evaluated by the machine.

§terminal: bool

If true, evaluate() always returns None — no transitions out.

§modifiers: Vec<InstructionModifier>

Instruction modifiers applied during instruction composition. Evaluated in order, each appends to the resolved instruction.

§prompt_on_enter: bool

If true, send turnComplete: true after instruction + context on phase entry, causing the model to generate a response immediately.

§on_enter_context: Option<Arc<dyn Fn(&State, &TranscriptWindow) -> Option<Vec<Content>> + Send + Sync>>

Optional context injection on phase entry. Returns Content to send as client_content (turnComplete: false). Gives the model conversational continuity across phase transitions.

§needs: Vec<String>

State keys this phase is responsible for gathering.

Purely informational — does not affect transitions or enforcement. The ContextBuilder reads these from session:phase_needs to append a “[Gathering] key1, key2” line to the instruction, so the model knows what to focus on.

§requires: Vec<String>

State keys that must exist before this phase can be entered.

Unlike needs, these are enforced by the phase machine. A transition targeting this phase is skipped until every required key is present in state. Use this for authoritative facts that must be materialized before the model is allowed to operate in the phase.

§preparations: Vec<PhasePreparation>

Effects that can run before this phase is entered to satisfy requires.

§presents: Vec<String>

Semantic concepts this phase presents to the user.

On phase entry the machine writes presented:<concept> = true to state. This lets flows distinguish “the model has collected a yes” from “the user acknowledged this specific concept after it was presented”.

§clear_on_enter: Vec<String>

State keys to clear when this phase is entered.

Useful for removing stale acknowledgements or intents gathered before the phase’s presented concepts are valid.

Implementations§

Source§

impl Phase

Source

pub fn new(name: &str, instruction: &str) -> Self

Create a minimal non-terminal phase with a static instruction and defaults.

Source

pub fn presented_key(concept: &str) -> String

State key used to mark that a concept has been presented.

Source

pub fn is_presented(state: &State, concept: &str) -> bool

Whether a semantic concept has been presented in this conversation.

Source

pub fn missing_requirements(&self, state: &State) -> Vec<String>

Required state keys that are not currently present.

Auto Trait Implementations§

§

impl Freeze for Phase

§

impl !RefUnwindSafe for Phase

§

impl Send for Phase

§

impl Sync for Phase

§

impl Unpin for Phase

§

impl !UnwindSafe for Phase

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

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
§

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> 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 = 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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