#[non_exhaustive]pub struct RunContext<'a> {
pub run_id: &'a str,
pub label: Option<&'a str>,
pub prompts: &'a [Message],
pub depth: usize,
pub delegated_by: Option<&'a str>,
pub parent_run_id: Option<&'a str>,
pub inherited: bool,
pub cancel: &'a CancellationToken,
/* private fields */
}Expand description
The run a hook belongs to.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.run_id: &'a strUnique per run, generated by the loop.
label: Option<&'a str>The host’s label for the run, set with
Agent::with_run_label (a session id,
say). yoagent does not interpret it. Delegated runs keep their
parent’s.
prompts: &'a [Message]The run’s prompts (for a delegated run: its task). Empty for a
continue_loop run.
depth: usize0 for a top-level run, 1 for a sub-agent’s run, and so on.
delegated_by: Option<&'a str>For a delegated run: the id of the tool call that started it (in the calling run).
parent_run_id: Option<&'a str>For a delegated run whose caller has extensions: the caller’s
run_id. With delegated_by, it names the delegation uniquely.
inherited: boolIn start_run: this extension came from the calling run’s tree
(Agent::with_tree_extension),
so the calling run has it too.
cancel: &'a CancellationTokenThe run’s cancellation token.
Implementations§
Source§impl<'a> RunContext<'a>
impl<'a> RunContext<'a>
Sourcepub fn new(
run_id: &'a str,
prompts: &'a [Message],
cancel: &'a CancellationToken,
) -> Self
pub fn new( run_id: &'a str, prompts: &'a [Message], cancel: &'a CancellationToken, ) -> Self
A context for a top-level run with no label, for testing extensions.
Sourcepub fn with_label(self, label: &'a str) -> Self
pub fn with_label(self, label: &'a str) -> Self
With the host’s label.
Sourcepub fn with_depth(self, depth: usize) -> Self
pub fn with_depth(self, depth: usize) -> Self
At this delegation depth.
Sourcepub fn with_delegated_by(self, parent_run_id: &'a str, call_id: &'a str) -> Self
pub fn with_delegated_by(self, parent_run_id: &'a str, call_id: &'a str) -> Self
Started by this tool call of the calling run parent_run_id.
Sourcepub fn is_delegation(&self) -> bool
pub fn is_delegation(&self) -> bool
Whether this run is a delegation (a sub-agent’s run).