pub enum Item {
User(User),
Assistant(Assistant),
ToolResult(ToolResult),
System(System),
}Expand description
One closed transcript record.
The variant set is closed by ADR-004. Lifecycle and audit facts are deliberately not transcript items.
use reef_core::transcript::item;
let item = item::Item::System(item::System::new(
"instruction".into(), "Be concise.".into(), item::ModelVisibility::Visible,
));
assert!(matches!(item, item::Item::System(system) if system.text() == "Be concise."));Variants§
User(User)
User-authored ordered content.
Assistant(Assistant)
Assistant-produced ordered content.
ToolResult(ToolResult)
The result of one model tool call.
System(System)
System-authored text.
Implementations§
Source§impl Item
impl Item
Sourcepub fn to_plain_text(&self) -> String
pub fn to_plain_text(&self) -> String
Renders this record’s text the way a reader would be shown it.
Reading a transcript is the first thing anyone does with an agent, and
without this it takes a four-arm match plus a walk into
Part::fields or
Segment per arm — the same twenty lines every consumer writes on
their first day.
use reef_core::transcript::item;
use reef_core::value::content;
let extensions = || content::SegmentExtensions::new(String::new(), None, None);
let answer = item::Item::Assistant(item::Assistant::new(
vec![
content::Segment::Thinking { text: "the user wants a greeting".into(), extensions: extensions() },
content::Segment::Text { text: "Hello.".into(), extensions: extensions() },
],
None,
));
assert_eq!(answer.to_plain_text(), "Hello.");
let question = item::Item::User(item::User::new(
vec![content::Part::text("Greet me.".into())],
item::ModelVisibility::Visible,
));
assert_eq!(question.to_plain_text(), "Greet me.");§What each record renders as
User: the text of every part, in order. A part carrying an image or opaque data has no text and contributes nothing.Assistant: the text of everySegment::Text. Reasoning and tool calls are not text the reader is being shown;Assistant::contenthas them, in provider order, and always did.ToolResult: exactly whattool_call::ToolResult::to_plain_textrenders, which this arm calls rather than restates. That rule prefers the output’suser_viewover its model content, and it belongs to the closed result value rather than to this record: a record adds a call identity, a tool name, a visibility and item metadata, none of which the rendering reads.System: its text.
Two blocks are separated by a single \n and nothing else is added, so a
record with one block renders exactly that block.
§This is not a way around redaction
It is an accessor, and every byte it returns is already reachable through
the typed accessor that owns it — which is precisely why ADR-018 refused
an unredacted Debug: there is nothing here to hide from, only
something to make convenient. What that ADR protects against is
accidental disclosure, so this stays explicit at the call site. There
is deliberately no Display for an Item: a
Display can be interpolated into a log message by someone who never
decided to print a transcript, and {item} would look like nothing at
all. item.to_plain_text() cannot be written by accident.