#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.prompt: StringThe 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
impl MessageOptions
Sourcepub fn with_mode(self, mode: DeliveryMode) -> Self
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.
Sourcepub fn with_attachments(self, attachments: Vec<Attachment>) -> Self
pub fn with_attachments(self, attachments: Vec<Attachment>) -> Self
Attach files / selections / blobs to the message.
Sourcepub fn with_wait_timeout(self, timeout: Duration) -> Self
pub fn with_wait_timeout(self, timeout: Duration) -> Self
Override the default 60-second wait timeout for send_and_wait.
Sourcepub fn with_request_headers(self, headers: HashMap<String, String>) -> Self
pub fn with_request_headers(self, headers: HashMap<String, String>) -> Self
Set custom HTTP headers for outbound model requests for this turn.
Sourcepub fn with_trace_context(self, ctx: TraceContext) -> Self
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.
Sourcepub fn with_traceparent(self, traceparent: impl Into<String>) -> Self
pub fn with_traceparent(self, traceparent: impl Into<String>) -> Self
Set the W3C traceparent header for this turn.
Sourcepub fn with_tracestate(self, tracestate: impl Into<String>) -> Self
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
impl Clone for MessageOptions
Source§fn clone(&self) -> MessageOptions
fn clone(&self) -> MessageOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more