pub struct RunOptions {
pub session_id: Option<String>,
pub user_id: Option<String>,
pub trace_name: Option<String>,
pub trace_tags: Vec<String>,
pub trace_metadata: Map<String, Value>,
pub release: Option<String>,
pub environment: Option<String>,
pub trace_text_max_chars: Option<usize>,
}Expand description
Per-run trace metadata applied to every span emitted by the agent loop.
Passed to run_with_options /
run_turn_with_options /
run_persistent_with_options
so a consumer can configure session / user / Langfuse trace
metadata once and have it land on every emitted span — without
writing manual span code or pre-installing baggage on the OTel
context.
The SDK applies the contents of RunOptions at the root
invoke_agent span:
session_id/user_id— copied to W3C baggage so Langfusesession.id/user.idfilters fire on every child span (the baggage propagation path lives inagent_sdk::observability::baggage).trace_name— set aslangfuse.trace.name.trace_tags— set aslangfuse.trace.tags.trace_metadata— each entry stamped underlangfuse.trace.metadata.<key>.release— set aslangfuse.release.environment— set aslangfuse.environment.trace_text_max_chars— overrides the default ceiling (agent_sdk::observability::langfuse::DEFAULT_TRACE_TEXT_MAX_CHARS) forlangfuse.trace.input/langfuse.trace.output.
The SDK also computes langfuse.trace.input from the supplied
AgentInput (after PII redaction) and
streams langfuse.trace.output as the agent emits text, tool, and
error events.
RunOptions is Clone + Debug + Default; it carries only display
strings and opaque metadata values (no secrets) so the standard
Debug derive is safe to expose in error contexts.
§Example
use agent_sdk_foundation::types::RunOptions;
use serde_json::json;
let opts = RunOptions {
session_id: Some("thread-42".to_string()),
user_id: Some("user-7".to_string()),
trace_name: Some("myapp.assistant.mobile".to_string()),
trace_tags: vec!["mobile.android".to_string()],
trace_metadata: json!({"version": "1.2.3"})
.as_object()
.cloned()
.unwrap_or_default(),
..Default::default()
};Fields§
§session_id: Option<String>Langfuse session.id / W3C session.id baggage entry.
user_id: Option<String>Langfuse user.id / W3C user.id baggage entry.
trace_name: Option<String>Display name of the trace in the Langfuse UI.
Free-form labels attached to the trace.
trace_metadata: Map<String, Value>Trace-level metadata stamped as langfuse.trace.metadata.<key>.
release: Option<String>Release identifier for the trace’s build.
environment: Option<String>Langfuse environment slug (prod, staging, …).
trace_text_max_chars: Option<usize>Override the default character ceiling for trace-level free-text
attributes. None falls back to
agent_sdk::observability::langfuse::DEFAULT_TRACE_TEXT_MAX_CHARS.
Trait Implementations§
Source§impl Clone for RunOptions
impl Clone for RunOptions
Source§fn clone(&self) -> RunOptions
fn clone(&self) -> RunOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more