pub struct SpawnContext {
pub parent_messages: Vec<Message>,
pub parent_cancel: Option<CancellationToken>,
pub parent_provider_name: Option<String>,
pub spawn_depth: u32,
pub mcp_tool_names: Vec<String>,
pub seed_trajectory_score: Option<f32>,
pub content_isolation: ContentIsolationConfig,
pub orchestrator_name: Option<String>,
pub orchestrator_role: Option<String>,
pub session_mcp_servers: Vec<McpServerConfig>,
}Expand description
Parent-derived state propagated to a spawned sub-agent at spawn time.
All fields default to empty/None, preserving existing behavior when callers
pass SpawnContext::default().
§Examples
use zeph_subagent::manager::SpawnContext;
// Minimal context — all fields use their defaults.
let ctx = SpawnContext::default();
assert!(ctx.parent_messages.is_empty());
assert_eq!(ctx.spawn_depth, 0);Fields§
§parent_messages: Vec<Message>Recent parent conversation messages (last N turns).
parent_cancel: Option<CancellationToken>Parent’s cancellation token for linked cancellation (foreground spawns).
parent_provider_name: Option<String>Parent’s active provider name (for context propagation).
spawn_depth: u32Current spawn depth (0 = top-level agent).
mcp_tool_names: Vec<String>MCP tool names available in the parent’s tool executor (for diagnostics).
seed_trajectory_score: Option<f32>Seeded trajectory risk score from the parent sentinel (spec 050 §4).
When Some, the subagent’s TrajectorySentinel starts with this pre-seeded score
rather than 0.0, preventing a subagent spawn from acting as a free risk reset.
The subagent loop applies this via TrajectorySentinel::seed_score after build.
content_isolation: ContentIsolationConfigParent’s content isolation config, propagated so the subagent loop can run the same sanitizer settings on hook-replaced tool output.
orchestrator_name: Option<String>Name of the orchestrator that spawned this subagent.
When set, the subagent’s system prompt includes an identity header naming the orchestrator, so the subagent can validate that instructions are consistent with the expected authority.
orchestrator_role: Option<String>Role or task label of the orchestrating agent (e.g., "planner", "tool-router").
Injected alongside orchestrator_name when both are set.
Omitted from the identity header when only orchestrator_name is provided.
session_mcp_servers: Vec<McpServerConfig>Per-session MCP servers to inject into this subagent’s tool name annotations.
The parent is responsible for connecting these servers and including them in the
tool_executor passed to SubAgentManager::spawn. This field only carries the
server metadata so the subagent’s system prompt lists the additional tool names.
Trait Implementations§
Source§impl Default for SpawnContext
impl Default for SpawnContext
Source§fn default() -> SpawnContext
fn default() -> SpawnContext
Auto Trait Implementations§
impl Freeze for SpawnContext
impl RefUnwindSafe for SpawnContext
impl Send for SpawnContext
impl Sync for SpawnContext
impl Unpin for SpawnContext
impl UnsafeUnpin for SpawnContext
impl UnwindSafe for SpawnContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request