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: boolWhether the harness identified this request as coming from a child agent.
is_delegated_work: boolWhether 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
impl Metadata
Sourcepub fn from_headers(headers: &BTreeMap<String, String>) -> Self
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.
Sourcepub fn is_subagent_work(&self) -> bool
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).