Skip to main content

MessageOptions

Struct MessageOptions 

Source
#[non_exhaustive]
pub struct MessageOptions { pub prompt: String, pub mode: Option<DeliveryMode>, pub attachments: Option<Vec<Attachment>>, pub wait_timeout: Option<Duration>, pub request_headers: Option<HashMap<String, String>>, pub traceparent: Option<String>, pub tracestate: Option<String>, }
Expand description

Options for sending a user message to the agent.

Used by both Session::send and Session::send_and_wait; the wait_timeout field is honored only by send_and_wait and is ignored by send.

MessageOptions is #[non_exhaustive] and constructed via MessageOptions::new plus the with_* chain so future fields can land without breaking callers. For the trivial case, both &str and String implement Into<MessageOptions>, so:

session.send("hello").await?;

is equivalent to:

session.send(MessageOptions::new("hello")).await?;

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§prompt: String

The user prompt to send.

§mode: Option<DeliveryMode>

Optional message delivery mode for this turn.

Controls whether the prompt is queued behind in-flight work (DeliveryMode::Enqueue, default) or interrupts the session and runs immediately (DeliveryMode::Immediate).

§attachments: Option<Vec<Attachment>>

Optional attachments to include with the message.

§wait_timeout: Option<Duration>

Maximum time to wait for the session to go idle. Honored only by send_and_wait. Defaults to 60 seconds when unset.

§request_headers: Option<HashMap<String, String>>

Custom HTTP headers to include in outbound model requests for this turn. When None or empty, no requestHeaders field is sent on the wire.

§traceparent: Option<String>

W3C Trace Context traceparent header for this turn.

Per-turn override that takes precedence over ClientOptions::on_get_trace_context. When None, the SDK falls back to the provider (if configured) before omitting the field.

§tracestate: Option<String>

W3C Trace Context tracestate header for this turn.

Per-turn override paired with traceparent.

Implementations§

Source§

impl MessageOptions

Source

pub fn new(prompt: impl Into<String>) -> Self

Build a new MessageOptions with just a prompt.

Source

pub fn with_mode(self, mode: DeliveryMode) -> Self

Set the message delivery mode for this turn.

Pass DeliveryMode::Immediate to interrupt the session and run the prompt now; the default (DeliveryMode::Enqueue) queues the prompt behind in-flight work.

Source

pub fn with_attachments(self, attachments: Vec<Attachment>) -> Self

Attach files / selections / blobs to the message.

Source

pub fn with_wait_timeout(self, timeout: Duration) -> Self

Override the default 60-second wait timeout for send_and_wait.

Source

pub fn with_request_headers(self, headers: HashMap<String, String>) -> Self

Set custom HTTP headers for outbound model requests for this turn.

Source

pub fn with_trace_context(self, ctx: TraceContext) -> Self

Set both traceparent and tracestate from a TraceContext. Either field may remain None if the TraceContext has no value for it. Use with_traceparent or with_tracestate to set them individually.

Source

pub fn with_traceparent(self, traceparent: impl Into<String>) -> Self

Set the W3C traceparent header for this turn.

Source

pub fn with_tracestate(self, tracestate: impl Into<String>) -> Self

Set the W3C tracestate header for this turn.

Trait Implementations§

Source§

impl Clone for MessageOptions

Source§

fn clone(&self) -> MessageOptions

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 MessageOptions

Source§

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

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

impl From<&String> for MessageOptions

Source§

fn from(prompt: &String) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for MessageOptions

Source§

fn from(prompt: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for MessageOptions

Source§

fn from(prompt: String) -> Self

Converts to this type from the input type.

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more