pub struct Message {
pub role: String,
pub content: String,
pub id: Option<String>,
pub source_id: Option<String>,
pub inserted_by: Option<ContextInsertion>,
}Fields§
§role: String§content: String§id: Option<String>Stable identity for this message, minted by the runtime as msg_
followed by a uuid-v7 simple form. A uuid-v7 carries its own
millisecond timestamp, so there is no separate created-at field to
keep in step with it.
This is not a content hash. An id must never repeat, even for two messages whose content is byte-identical; a content hash must repeat whenever the content does. The two answer different questions and are never interchangeable.
Stripped before the wire payload is built — see the note on
source-id. Minted once, at the message’s creation site, and
preserved everywhere after: an id on a message a hook hands back is
kept, and so is the id a message reloaded from the conversation
record carries. The runtime mints one only for a message that arrives
without one.
source_id: Option<String>Opaque join key back to whatever produced this content — a corpus
record, a compaction summary, reloaded history. Recorded verbatim and
never parsed, exactly like resource-id in tool metadata: the runtime
makes no claim about its shape and reads no meaning out of it.
Both id and source-id are stripped before the driver wire payload
is built. A uuid sitting at the head of a cached prefix is volatile
content, and would defeat provider prompt-prefix caching on every
request. A source-id a hook supplies is carried verbatim; the key is
absent when the hook supplied none.
inserted_by: Option<ContextInsertion>Which hook output put this message into the conversation. Set only by the runtime, at the moment it commits that output, and read from the conversation record wherever the message is served back.
none means no hook output inserted the message: it is a person’s or
a delegating caller’s task message, a model turn, a tool result, or a
runtime marker, and role tells those apart. The mark is independent
of role, so a summary returned as "assistant" or "user" carries
it all the same.
A message a hook hands back unchanged keeps the mark it already had:
its id names a message in the context the hook was handed, and its
role and content equal that message’s. Any other message a hook
returns is marked with the output it came in through. A value a hook
sets on a message it returns is ignored.
Stripped before the driver wire payload is built, like id and
source-id.
Trait Implementations§
impl ComponentType for Message
impl Lift for Message
impl Lower for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more