Skip to main content

RequestPlan

Struct RequestPlan 

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

Mutable preparation for exactly one model request.

ⓘ
use reef_core::runtime::model;
let plan = model::RequestPlan::new();
let request = plan.try_into_request(vec![]).unwrap();
plan.sampling_mut(); // freezing consumes the only mutable preparation value

Implementations§

Source§

impl RequestPlan

Source

pub fn new() -> Self

Creates an empty per-Step preparation value.

Source

pub fn system_instruction(&self) -> &[Part]

Returns the ordered system instruction.

Source

pub fn push_system_instruction(&mut self, part: Part) -> &mut Self

Appends one system-instruction block.

Source

pub fn extend_system_instruction( &mut self, parts: impl IntoIterator<Item = Part>, ) -> &mut Self

Appends system-instruction blocks in iteration order.

Source

pub fn clear_system_instruction(&mut self) -> &mut Self

Removes every system-instruction block.

Source

pub fn tools(&self) -> &[ClientTool]

Returns the client-local tool lane.

Source

pub fn push_tool(&mut self, tool: ClientTool) -> &mut Self

Appends one client-local tool descriptor.

Source

pub fn extend_tools( &mut self, tools: impl IntoIterator<Item = ClientTool>, ) -> &mut Self

Appends client-local tool descriptors in iteration order.

Source

pub fn clear_tools(&mut self) -> &mut Self

Removes every client-local tool descriptor.

Source

pub const fn sampling_mut(&mut self) -> &mut SamplingParams

Returns the sampling controls for mutation.

Source

pub fn extensions(&self) -> &[Envelope]

Returns the provider-hosted extension lane.

Source

pub fn push_extension(&mut self, extension: Envelope) -> &mut Self

Appends one provider-hosted extension.

Source

pub fn extend_extensions( &mut self, extensions: impl IntoIterator<Item = Envelope>, ) -> &mut Self

Appends provider-hosted extensions in iteration order.

Source

pub fn clear_extensions(&mut self) -> &mut Self

Removes every provider-hosted extension.

Source

pub fn ephemeral(&self) -> &[Part]

Returns volatile per-Step content.

Source

pub fn push_ephemeral(&mut self, part: Part) -> &mut Self

Appends one volatile per-Step block.

Source

pub fn extend_ephemeral( &mut self, parts: impl IntoIterator<Item = Part>, ) -> &mut Self

Appends volatile per-Step blocks in iteration order.

Source

pub fn clear_ephemeral(&mut self) -> &mut Self

Removes every volatile per-Step block.

Source

pub fn try_into_request( self, messages: Vec<Item>, ) -> Result<Request, RequestError>

Consumes the writable window and freezes a validated, model-visible request.

§This is the item-to-message projection

It is the crate’s only one, and there is no second message vocabulary to project into: the projected value is the same closed Item history minus everything the model must not see. Two rules apply, in this order.

  1. ModelVisibility. Every ModelVisibility::Hidden record is omitted, whatever its variant. A provider therefore never has to consult Item visibility itself: by construction every item in Request::messages is ModelVisibility::Visible.
  2. The exchange grammar, checked over what survives rule 1. Hiding an assistant record hides the calls it carries, so a result that is still visible has become an orphan and is refused rather than sent; hiding a result whose call is visible leaves that call unanswered and is refused too. Reef’s own commits cannot produce either, because a committed result takes the visibility of the record carrying its call.

What this projection deliberately does not do is normalise segments across providers. Deciding that one provider’s Segment::Thinking is unusable by another requires knowing both providers’ rules, which core does not and must not learn. A composition layer that changes model mid-session performs that rewrite in a ModelHooks::before_model registration, returning BeforeModelDecision::Modify with a request re-frozen through this same boundary.

This is the only Request construction boundary: it validates system instructions, applies visibility projection, closes tool-call/result exchanges, owns both tool lanes, and rejects invalid input before Client::generate can be invoked.

§Errors

Freezing refuses a request no provider should be asked to answer. Nothing is validated lazily and no partial Request escapes, so a caller that gets an error has changed nothing.

The system instruction is checked first, block by block, and each variant carries the offending block’s index: EmptySystemInstructionText for a text block with no text, NonTextSystemInstruction for a block whose kind is known but is not text, and UnknownSystemInstruction for one whose numeric kind has no portable interpretation. A system instruction of zero blocks is valid; a present block that says nothing is not.

The rest is the exchange grammar, applied to what survives the visibility rule above. It fails when the history is not a closed sequence of call-and-answer:

The last two are also how a half-hidden exchange is refused, and the reason is the projection above rather than provider etiquette: hiding an assistant record hides the calls it carries, so a still-visible result has become an orphan, and hiding only the result leaves its call unanswered. Reef’s own commits cannot produce either, because a committed result takes the visibility of the record carrying its call — so seeing one of these from a rewritten history means the rewrite split an exchange in half.

Trait Implementations§

Source§

impl Clone for RequestPlan

Source§

fn clone(&self) -> Self

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 RequestPlan

Source§

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

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

impl Default for RequestPlan

Source§

fn default() -> Self

Returns the “default value” for a type. 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, 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> 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 = !

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.