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
impl Info
Sourcepub const fn new(id: String, context_window: u64) -> Self
pub const fn new(id: String, context_window: u64) -> Self
Creates a capability snapshot that supports nothing beyond plain text.
Sourcepub const fn with_tools(self, supported: bool) -> Self
pub const fn with_tools(self, supported: bool) -> Self
Declares whether client-local tool calling is supported.
Sourcepub const fn with_vision(self, supported: bool) -> Self
pub const fn with_vision(self, supported: bool) -> Self
Declares whether image input is supported.
Sourcepub const fn with_thinking(self, supported: bool) -> Self
pub const fn with_thinking(self, supported: bool) -> Self
Declares whether reasoning output is supported.
Sourcepub fn with_extension(self, extension: Envelope) -> Self
pub fn with_extension(self, extension: Envelope) -> Self
Appends one provider-supplied capability fact.
Sourcepub fn with_extensions(
self,
extensions: impl IntoIterator<Item = Envelope>,
) -> Self
pub fn with_extensions( self, extensions: impl IntoIterator<Item = Envelope>, ) -> Self
Appends provider-supplied capability facts in iteration order.
Sourcepub const fn context_window(&self) -> u64
pub const fn context_window(&self) -> u64
Returns the maximum input size in tokens.
Sourcepub const fn supports_tools(&self) -> bool
pub const fn supports_tools(&self) -> bool
Reports whether client-local tool calling is supported.
Sourcepub const fn supports_vision(&self) -> bool
pub const fn supports_vision(&self) -> bool
Reports whether image input is supported.
Sourcepub const fn supports_thinking(&self) -> bool
pub const fn supports_thinking(&self) -> bool
Reports whether reasoning output is supported.
Sourcepub fn extensions(&self) -> &[Envelope]
pub fn extensions(&self) -> &[Envelope]
Returns every provider-supplied capability fact in insertion order.