Skip to main content

vv_agent/
context.rs

1use std::path::PathBuf;
2use std::sync::Arc;
3
4use crate::model::ModelRef;
5use crate::types::Metadata;
6
7#[derive(Clone, Default)]
8pub struct RunContext {
9    pub run_id: String,
10    pub agent_name: String,
11    pub model: Option<ModelRef>,
12    pub workspace: Option<PathBuf>,
13    pub metadata: Metadata,
14}
15
16#[derive(Clone)]
17pub struct ToolCallContext {
18    pub run: RunContext,
19    pub tool_call_id: String,
20    pub tool_name: String,
21    pub raw_arguments: serde_json::Value,
22    pub metadata: Metadata,
23    pub app_state: Option<Arc<dyn std::any::Any + Send + Sync>>,
24}
25
26impl ToolCallContext {
27    pub fn app_state<T: Send + Sync + 'static>(&self) -> Option<&T> {
28        self.app_state.as_ref()?.downcast_ref::<T>()
29    }
30}