Skip to main content

Metadata

Struct Metadata 

Source
pub struct Metadata {
Show 15 fields pub session_id: Option<String>, pub agent_id: Option<String>, pub parent_agent_id: Option<String>, pub is_subagent: bool, pub is_delegated_work: bool, pub agent_kind: Option<String>, pub agent_role: Option<String>, pub task_id: Option<String>, pub task_kind: Option<String>, pub turn_id: Option<String>, pub session_final: Option<bool>, pub correlation_id: Option<String>, pub extra_metadata: Option<BTreeMap<String, String>>, pub http_headers: Option<BTreeMap<String, String>>, pub wire_format: Option<WireFormat>,
}
Expand description

Correlation and routing metadata attached to a request or response.

All fields are optional (or default-empty); algorithms and observers use whichever are present (e.g. to key per-session state or emit correlated telemetry). The agent-lineage fields (parent_agent_id, is_subagent, agent_kind, agent_role, task_kind, turn_id, session_final) are populated for requests from a coding agent. extra_metadata is a free-form escape hatch for host-specific keys.

Fields§

§session_id: Option<String>

Stable id for a multi-request session/conversation.

§agent_id: Option<String>

Id of the agent making the request.

§parent_agent_id: Option<String>

Id of the parent agent, when this request comes from a child agent.

§is_subagent: bool

Whether the harness identified this request as coming from a child agent.

§is_delegated_work: bool

Whether this request carries delegated sub-agent work and should be routed to the sub-agent target. Computed from raw harness signals only, independent of Self::agent_kind, which may be set by an unrelated operator label (x-switchyard-agent-kind).

§agent_kind: Option<String>

Harness-defined kind of agent call, such as collab_spawn or review.

§agent_role: Option<String>

Semantic agent role, such as explorer, worker, or reviewer.

§task_id: Option<String>

Id of the task the request belongs to.

§task_kind: Option<String>

Semantic task class supplied by the harness.

§turn_id: Option<String>

Id of the current agent turn.

§session_final: Option<bool>

Whether the harness signalled this is the session’s final request (e.g. the host may evict per-session state). None when the harness said nothing.

§correlation_id: Option<String>

External trace/request id for joining with the host’s telemetry.

§extra_metadata: Option<BTreeMap<String, String>>

Arbitrary host-defined key/value metadata.

§http_headers: Option<BTreeMap<String, String>>

HTTP headers to attach when forwarding the request/response, if any.

§wire_format: Option<WireFormat>

The wire format the request/response was originally encoded in, if known.

Implementations§

Source§

impl Metadata

Source

pub fn from_headers(headers: &BTreeMap<String, String>) -> Self

Normalizes harness-specific request headers into correlation metadata.

Explicit x-switchyard-* headers win. Compatible host headers can populate correlation and session metadata, but do not by themselves mark a request as delegated work. Structured turn metadata is preferred over compatibility projections. A request with a non-empty x-claude-code-agent-id is treated as a child agent (its parent inferred from the session when not stated). Sub-agent routing status is taken from an explicit x-switchyard-is-subagent header when present, and otherwise inferred from native agent lineage or structured harness signals.

Source

pub fn is_subagent_work(&self) -> bool

Whether this request should be routed to the sub-agent target.

Returns self.is_delegated_work, which is computed in parse_sub_agent from raw harness signals only — independent of agent_kind, which may be populated by an unrelated operator label (x-switchyard-agent-kind).

Trait Implementations§

Source§

impl Clone for Metadata

Source§

fn clone(&self) -> Metadata

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Metadata

Source§

fn default() -> Metadata

Returns the “default value” for a type. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.