Skip to main content

agnt_core/
message.rs

1//! Message types shared between backend, agent loop, and store.
2
3use serde::{Deserialize, Serialize};
4
5/// A conversation message in the OpenAI-flavored internal format.
6///
7/// Backends that use a different wire format (e.g. Anthropic's content blocks)
8/// translate to/from this type at the wire boundary.
9#[derive(Debug, Serialize, Deserialize, Clone)]
10pub struct Message {
11    pub role: String,
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub content: Option<String>,
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub tool_calls: Option<Vec<ToolCall>>,
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub tool_call_id: Option<String>,
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub name: Option<String>,
20}
21
22#[derive(Debug, Serialize, Deserialize, Clone)]
23pub struct ToolCall {
24    pub id: String,
25    #[serde(rename = "type", default = "default_tc_type")]
26    pub call_type: String,
27    pub function: FunctionCall,
28}
29
30fn default_tc_type() -> String {
31    "function".into()
32}
33
34#[derive(Debug, Serialize, Deserialize, Clone)]
35pub struct FunctionCall {
36    pub name: String,
37    pub arguments: String,
38}