pub trait RunCommands {
type Despawned;
// Required methods
fn spawn_run(
&mut self,
agent: Entity,
history: &[MessageParts],
prompt: impl Into<Prompt>,
streamed: bool,
max_turns: Option<usize>,
) -> Entity;
fn cancel_run(&mut self, run: Entity, reason: impl Into<String>);
fn despawn_run(&mut self, run: Entity) -> Self::Despawned;
}Expand description
Spawn, cancel, and remove runs through a world or deferred commands. World operations apply immediately; commands reserve spawn IDs immediately but populate runs only when flushed. Ordered commands preserve dependencies between spawning, cancelling, and removing a run.
Required Associated Types§
Sourcetype Despawned
type Despawned
What despawn_run reports: the refusal, on World; nothing on
Commands, which triggers RunDespawnRefused on the run instead.
Required Methods§
Sourcefn spawn_run(
&mut self,
agent: Entity,
history: &[MessageParts],
prompt: impl Into<Prompt>,
streamed: bool,
max_turns: Option<usize>,
) -> Entity
fn spawn_run( &mut self, agent: Entity, history: &[MessageParts], prompt: impl Into<Prompt>, streamed: bool, max_turns: Option<usize>, ) -> Entity
Spawn a run of agent with prompt as its first utterance, after
history: the host’s one entry point. The prompt is a user
message’s parts (&str text, or text and images kept in their
given order, Prompt). Returns the run entity. On Commands
the entity is reserved at once and populated when the command
applies; a run despawned before or while it is populated (a host
Add<Run> observer that refuses it, say) is simply gone.
Sourcefn cancel_run(&mut self, run: Entity, reason: impl Into<String>)
fn cancel_run(&mut self, run: Entity, reason: impl Into<String>)
Stop run with reason (CONTRACT §9.1): Cancelled(reason) on the
run. A run that ended keeps its ending; an entity that is not a run
is left alone. A run cancelled before it opened (Ready written by
hand, not yet seen by Advance) fails with its unread Prompt
still on it, and a scene saves the prompt with the failed run.
Sourcefn despawn_run(&mut self, run: Entity) -> Self::Despawned
fn despawn_run(&mut self, run: Entity) -> Self::Despawned
Despawn an ended run and its linked descendants, including stream folds. Refuses without mutation if the entity is not a run, has not ended, or has pending or in-flight effects. Hosts must remove finished runs to reclaim their graphs; the runtime does not remove them automatically.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".