Struct BackgroundAgentDispatcher
pub struct BackgroundAgentDispatcher { /* private fields */ }Expand description
Dispatcher for running TextAgent pipelines as background tasks.
§Example
ⓘ
let dispatcher = BackgroundAgentDispatcher::new(5); // max 5 concurrent
// From an on_turn_complete callback:
dispatcher.dispatch("compliance_check", compliance_agent.clone(), state.clone());
// Results appear in state:
// "compliance_check:result" = "No violations detected"
// OR
// "compliance_check:error" = "Agent failed: ..."Implementations§
§impl BackgroundAgentDispatcher
impl BackgroundAgentDispatcher
pub fn new(max_concurrent: usize) -> BackgroundAgentDispatcher
pub fn new(max_concurrent: usize) -> BackgroundAgentDispatcher
Create a new dispatcher with the given concurrency budget.
pub fn max_concurrent(&self) -> usize
pub fn max_concurrent(&self) -> usize
Maximum concurrent background agents.
pub fn available_permits(&self) -> usize
pub fn available_permits(&self) -> usize
Number of currently available permits.
pub fn dispatch(
&self,
task_name: impl Into<String>,
agent: Arc<dyn TextAgent>,
state: State,
)
pub fn dispatch( &self, task_name: impl Into<String>, agent: Arc<dyn TextAgent>, state: State, )
Dispatch a text agent to run in the background.
Results are written to state under {task_name}:result.
Errors are written to {task_name}:error.
If the budget is exhausted, the task will wait for a permit.
pub async fn is_running(&self, name: &str) -> bool
pub async fn is_running(&self, name: &str) -> bool
Check if a named task is still running.
pub async fn cancel_all(&self)
pub async fn cancel_all(&self)
Cancel all running background agents.
pub async fn active_count(&self) -> usize
pub async fn active_count(&self) -> usize
Number of tasks currently tracked (running or recently completed).
Auto Trait Implementations§
impl Freeze for BackgroundAgentDispatcher
impl !RefUnwindSafe for BackgroundAgentDispatcher
impl Send for BackgroundAgentDispatcher
impl Sync for BackgroundAgentDispatcher
impl Unpin for BackgroundAgentDispatcher
impl !UnwindSafe for BackgroundAgentDispatcher
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
Mutably borrows from an owned value. Read more