pub struct SubAgentHandle {
pub id: String,
pub def: SubAgentDef,
pub task_id: String,
pub state: SubAgentState,
pub join_handle: Option<JoinHandle<Result<String, SubAgentError>>>,
pub cancel: CancellationToken,
pub status_rx: Receiver<SubAgentStatus>,
pub grants: PermissionGrants,
pub pending_secret_rx: Receiver<SecretRequest>,
pub secret_tx: Sender<Option<String>>,
pub started_at_str: String,
pub transcript_dir: Option<PathBuf>,
}Expand description
Handle to a spawned sub-agent task, owned by SubAgentManager.
Fields are public to allow test harnesses in downstream crates to construct handles
without going through the full spawn lifecycle. Production code must not mutate
grants or the cancellation state directly — use the SubAgentManager API instead.
The Drop implementation cancels the task and revokes all grants as a safety net.
Fields§
§id: StringShort display ID (same as task_id for non-resumed sessions).
def: SubAgentDefThe definition that was used to spawn this agent.
task_id: StringUUID assigned at spawn time (currently identical to id; separated for future use).
state: SubAgentStateCached state — may lag the background task by one watch broadcast.
join_handle: Option<JoinHandle<Result<String, SubAgentError>>>Tokio join handle for the background agent loop task.
cancel: CancellationTokenCancellation token; cancelled on SubAgentManager::cancel or drop.
status_rx: Receiver<SubAgentStatus>Watch receiver for live status updates from the agent loop.
grants: PermissionGrantsZero-trust TTL-bounded grants for this agent session.
pending_secret_rx: Receiver<SecretRequest>Receives secret requests from the sub-agent loop.
secret_tx: Sender<Option<String>>Delivers approval outcome to the sub-agent loop: None = denied, Some(_) = approved.
started_at_str: StringISO 8601 UTC timestamp recorded when the agent was spawned or resumed.
transcript_dir: Option<PathBuf>Resolved transcript directory at spawn time; None if transcripts were disabled.