codetether_agent/telemetry/a2a.rs
1//! A2A (Agent-to-Agent) protocol message telemetry records.
2
3use chrono::{DateTime, Utc};
4use serde::{Deserialize, Serialize};
5
6/// One A2A message exchange between the worker and a remote agent.
7///
8/// `blocking` indicates whether the caller awaited a response. `output` and
9/// `error` are mutually exclusive based on `success`.
10///
11/// # Examples
12///
13/// ```rust
14/// use codetether_agent::telemetry::A2AMessageRecord;
15/// use chrono::Utc;
16///
17/// let r = A2AMessageRecord {
18/// tool_name: "delegate".into(),
19/// task_id: "task-1".into(),
20/// blocking: true,
21/// prompt: "hello".into(),
22/// duration_ms: 120,
23/// success: true,
24/// output: Some("hi".into()),
25/// error: None,
26/// timestamp: Utc::now(),
27/// };
28/// assert!(r.success);
29/// ```
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct A2AMessageRecord {
32 /// Tool name that produced the message (e.g. `"delegate"`).
33 pub tool_name: String,
34 /// A2A task id the message belongs to.
35 pub task_id: String,
36 /// `true` if the caller awaited a synchronous response.
37 pub blocking: bool,
38 /// Prompt / request body sent to the remote agent.
39 pub prompt: String,
40 /// Round-trip duration in milliseconds.
41 pub duration_ms: u64,
42 /// `true` iff the remote agent returned a non-error response.
43 pub success: bool,
44 /// Response body, when `success` is `true`.
45 pub output: Option<String>,
46 /// Error message, when `success` is `false`.
47 pub error: Option<String>,
48 /// When the exchange completed.
49 pub timestamp: DateTime<Utc>,
50}