Skip to main content

causa_runtime/config/
options.rs

1use crate::RunObserver;
2use causa_kernel::{CacheDirective, ContextPreparer, GenerationOptions, ModelRef};
3use std::sync::Arc;
4
5/// Numeric limits for one execution.
6#[derive(Debug, Clone, Copy)]
7pub struct TurnLimits {
8    /// Maximum number of logical model invocations, including the first.
9    pub max_model_rounds: u32,
10    /// Maximum cumulative number of model tool declarations.
11    pub max_tool_calls: u32,
12}
13impl Default for TurnLimits {
14    fn default() -> Self {
15        Self {
16            max_model_rounds: 10,
17            max_tool_calls: 64,
18        }
19    }
20}
21
22/// Choices fixed for one run; the model must be supplied explicitly.
23#[derive(Clone)]
24pub struct TurnRunOptions {
25    /// Model used by every logical invocation.
26    pub model: ModelRef,
27    /// Generation parameters used by every logical invocation.
28    pub generation: GenerationOptions,
29    /// Provider cache instruction.
30    pub cache: CacheDirective,
31    /// Execution limits.
32    pub limits: TurnLimits,
33    /// Optional exclusive material preparation before each invocation.
34    pub preparer: Option<Arc<dyn ContextPreparer>>,
35    /// Optional synchronous borrowed observation callback.
36    pub observer: Option<Arc<RunObserver>>,
37}
38impl TurnRunOptions {
39    /// Select a model with default generation, limits and no preparation or observer.
40    pub fn new(model: ModelRef) -> Self {
41        Self {
42            model,
43            generation: GenerationOptions::default(),
44            cache: CacheDirective::None,
45            limits: TurnLimits::default(),
46            preparer: None,
47            observer: None,
48        }
49    }
50}