Skip to main content

Info

Struct Info 

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

Static identity and capabilities snapshotted by an Agent revision.

Every Client has to return one of these, so a later capability flag would break every provider in existence if callers built it with a struct literal. Fields are therefore private: construction goes through Info::new plus the capability setters, and a capability added later defaults to “unsupported” for providers that predate it.

§The named capability set is closed

A named field is admissible here only when it states something about a reef-owned primitive: Info::supports_tools is a statement about reef’s tool mechanism, Info::supports_thinking about Segment::Thinking and ContentKind::Thinking, Info::supports_vision about non-text PartKinds, and Info::context_window is a count of reef’s own Item budget. Wire-protocol quirks, thinking formats, pricing tiers and session-affinity formats describe providers rather than reef primitives, so they travel in the Envelope extension channel and core never learns their vocabulary.

use reef_core::opaque;
use reef_core::runtime::model;

let info = model::Info::new("example-model".to_owned(), 200_000)
    .with_tools(true)
    .with_thinking(true)
    .with_extension(
        opaque::Envelope::try_new(
            "example.compat".to_owned(),
            "matrix".to_owned(),
            opaque::Payload::copy_from_slice(br#"{"thinkingFormat":"example"}"#),
        )
        .unwrap(),
    );

assert_eq!(info.id(), "example-model");
assert_eq!(info.context_window(), 200_000);
assert!(info.supports_tools() && info.supports_thinking() && !info.supports_vision());
// Provider-defined bytes; core never parsed them.
let compat = info.extension("example.compat", "matrix").unwrap();
assert_eq!(compat.as_bytes(), br#"{"thinkingFormat":"example"}"#);
assert!(info.extension("example.compat", "absent").is_none());

§Equality

Field by field, and the extension list in order. Two snapshots are equal when they name the same model, state the same context window, answer every capability the same way, and carry the same extensions in the same positions; an Envelope compares by the byte-wise rule that type documents, so equality here inherits it rather than interpreting a payload. The identifier compares exactly — no case folding, no trimming — because it is a provider-owned string core assigns no structure to.

Ordering is part of it because Info::extensions publishes insertion order. A set-like equality would let a == b hold while a.extensions() != b.extensions(), which is a value disagreeing with its own accessor; and a provider whose snapshot lists its extensions in a different order on each call is not returning the immutable snapshot this type is documented to be, so the stricter reading is also the one that catches that.

The relation is total, so this is an Eq. Growth stays additive: a capability added later has a defined “unsupported” default, so two values that were equal before it existed are still equal after.

use reef_core::opaque;
use reef_core::runtime::model;

let extension = |kind: &str| {
    opaque::Envelope::try_new(
        "example.compat".to_owned(),
        kind.to_owned(),
        opaque::Payload::copy_from_slice(b"{}"),
    )
    .unwrap()
};
let info = |first: &str, second: &str| {
    model::Info::new("example-model".to_owned(), 200_000)
        .with_extensions([extension(first), extension(second)])
};

assert_eq!(info("a", "b"), info("a", "b"));
// The same two facts, listed the other way round.
assert_ne!(info("a", "b"), info("b", "a"));

Implementations§

Source§

impl Info

Source

pub const fn new(id: String, context_window: u64) -> Self

Creates a capability snapshot that supports nothing beyond plain text.

Source

pub const fn with_tools(self, supported: bool) -> Self

Declares whether client-local tool calling is supported.

Source

pub const fn with_vision(self, supported: bool) -> Self

Declares whether image input is supported.

Source

pub const fn with_thinking(self, supported: bool) -> Self

Declares whether reasoning output is supported.

Source

pub fn with_extension(self, extension: Envelope) -> Self

Appends one provider-supplied capability fact.

Source

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

Appends provider-supplied capability facts in iteration order.

Source

pub fn id(&self) -> &str

Returns the provider model identifier.

Source

pub const fn context_window(&self) -> u64

Returns the maximum input size in tokens.

Source

pub const fn supports_tools(&self) -> bool

Reports whether client-local tool calling is supported.

Source

pub const fn supports_vision(&self) -> bool

Reports whether image input is supported.

Source

pub const fn supports_thinking(&self) -> bool

Reports whether reasoning output is supported.

Source

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

Returns every provider-supplied capability fact in insertion order.

Source

pub fn extension(&self, namespace: &str, kind: &str) -> Option<&Payload>

Returns the first capability fact matching namespace and kind.

Trait Implementations§

Source§

impl Clone for Info

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 Info

Source§

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

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

impl Eq for Info

Source§

impl PartialEq for Info

Source§

fn eq(&self, other: &Self) -> 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 Info

Auto Trait Implementations§

§

impl Freeze for Info

§

impl RefUnwindSafe for Info

§

impl Send for Info

§

impl Sync for Info

§

impl Unpin for Info

§

impl UnsafeUnpin for Info

§

impl UnwindSafe for Info

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.