Skip to main content

briefcase_core/models/
agent.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
5pub struct ToolCallMetadata {
6    pub tool_id: String,
7    pub tool_name: String,
8    pub arguments: String,
9    pub result: Option<String>,
10}
11
12#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
13pub struct AgentMetadata {
14    pub agent_id: String,
15    pub role: String,
16    pub handoff_from: Option<String>,
17    #[serde(default)]
18    pub tool_calls: Vec<ToolCallMetadata>,
19    #[serde(default)]
20    pub metadata: HashMap<String, serde_json::Value>,
21}
22
23impl AgentMetadata {
24    pub fn new(agent_id: impl Into<String>, role: impl Into<String>) -> Self {
25        Self {
26            agent_id: agent_id.into(),
27            role: role.into(),
28            handoff_from: None,
29            tool_calls: Vec::new(),
30            metadata: HashMap::new(),
31        }
32    }
33
34    pub fn with_handoff(mut self, from: String) -> Self {
35        self.handoff_from = Some(from);
36        self
37    }
38
39    pub fn add_tool_call(&mut self, tool_call: ToolCallMetadata) {
40        self.tool_calls.push(tool_call);
41    }
42}