Skip to main content

causa_runtime/executor/
options.rs

1//! Configuration fixed for the lifetime of an executor.
2
3use causa_kernel::{ArtifactStore, ToolBatchProcessor};
4use std::sync::Arc;
5use std::time::Duration;
6
7/// Fixed processing configuration received when constructing an executor.
8#[derive(Default)]
9#[non_exhaustive]
10pub struct ToolExecutorOptions {
11    /// Ordered processors invoked before tool dispatch.
12    pub before: Vec<Arc<dyn ToolBatchProcessor>>,
13    /// Ordered processors invoked after every call has a result.
14    pub after: Vec<Arc<dyn ToolBatchProcessor>>,
15    /// Optional local timeout, started when each tool call actually begins.
16    pub call_timeout: Option<Duration>,
17    /// Optional host storage passed to tools and dynamic-source bridges.
18    pub artifact_store: Option<Arc<dyn ArtifactStore>>,
19}
20
21impl ToolExecutorOptions {
22    /// Replaces the ordered processors invoked before tool dispatch.
23    pub fn with_before(mut self, before: Vec<Arc<dyn ToolBatchProcessor>>) -> Self {
24        self.before = before;
25        self
26    }
27
28    /// Replaces the ordered processors invoked after every call has a result.
29    pub fn with_after(mut self, after: Vec<Arc<dyn ToolBatchProcessor>>) -> Self {
30        self.after = after;
31        self
32    }
33
34    /// Sets the local timeout started when each tool call begins.
35    pub fn with_call_timeout(mut self, call_timeout: Duration) -> Self {
36        self.call_timeout = Some(call_timeout);
37        self
38    }
39
40    /// Sets the host storage passed to tools and dynamic-source bridges.
41    pub fn with_artifact_store(mut self, artifact_store: Arc<dyn ArtifactStore>) -> Self {
42        self.artifact_store = Some(artifact_store);
43        self
44    }
45}