Skip to main content

claude_codes/io/
result.rs

1use serde::{Deserialize, Deserializer, Serialize, Serializer};
2use serde_json::Value;
3use std::fmt;
4
5/// Result message for completed queries
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct ResultMessage {
8    pub subtype: ResultSubtype,
9    pub is_error: bool,
10    pub duration_ms: u64,
11    pub duration_api_ms: u64,
12
13    /// Time to first token, in milliseconds.
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub ttft_ms: Option<u64>,
16
17    /// Time to first streamed token, in milliseconds.
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub ttft_stream_ms: Option<u64>,
20
21    /// Time from session start until the first request was issued, in milliseconds.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub time_to_request_ms: Option<u64>,
24
25    /// Time from spawning a worker/spare until the first request was issued, in milliseconds.
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub time_to_request_from_spawn_ms: Option<u64>,
28
29    /// Whether a warm spare process was claimed for this request.
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub warm_spare_claimed: Option<bool>,
32
33    /// Epoch-ish timestamp origin used by CLI timing instrumentation.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub time_origin_ms: Option<u64>,
36
37    /// Wall-clock epoch milliseconds when the API request was sent
38    /// (fractional; from CLI timing instrumentation).
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub request_sent_wall_ms: Option<f64>,
41
42    /// Wire uuid of the user message this result answers.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub user_message_uuid: Option<String>,
45
46    pub num_turns: i32,
47
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub result: Option<String>,
50
51    #[serde(alias = "sessionId")]
52    pub session_id: String,
53    pub total_cost_usd: f64,
54
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub usage: Option<UsageInfo>,
57
58    /// Tools that were blocked due to permission denials during the session
59    #[serde(default)]
60    pub permission_denials: Vec<PermissionDenial>,
61
62    /// Error messages when `is_error` is true.
63    ///
64    /// Contains human-readable error strings (e.g., "No conversation found with session ID: ...").
65    /// This allows typed access to error conditions without needing to serialize to JSON and search.
66    #[serde(default)]
67    pub errors: Vec<String>,
68
69    #[serde(skip_serializing_if = "Option::is_none")]
70    pub uuid: Option<String>,
71
72    /// HTTP status code when the result is an API error (e.g., 429, 500, 529)
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub api_error_status: Option<u16>,
75
76    /// Why generation stopped (e.g., end_turn, max_tokens)
77    #[serde(skip_serializing_if = "Option::is_none")]
78    pub stop_reason: Option<String>,
79
80    /// Why the session ended (e.g., "completed")
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub terminal_reason: Option<String>,
83
84    /// Fast mode toggle state (e.g., "off")
85    #[serde(skip_serializing_if = "Option::is_none")]
86    pub fast_mode_state: Option<String>,
87
88    /// Why fast mode can't serve right now. Absent when nothing blocks it.
89    /// A paused-after-rate-limit run is not reported here; it rides
90    /// `fast_mode_state` as `"cooldown"`.
91    #[serde(skip_serializing_if = "Option::is_none")]
92    pub fast_mode_disabled_reason: Option<FastModeDisabledReason>,
93
94    /// Per-model cost breakdown, keyed by model name (e.g. `"claude-opus-4-8"`).
95    #[serde(skip_serializing_if = "Option::is_none", rename = "modelUsage")]
96    pub model_usage: Option<std::collections::BTreeMap<String, ModelUsageEntry>>,
97
98    /// Structured-output payload returned by the model, when enabled.
99    #[serde(skip_serializing_if = "Option::is_none")]
100    pub structured_output: Option<Value>,
101
102    /// Deferred tool-use termination payload.
103    #[serde(skip_serializing_if = "Option::is_none")]
104    pub deferred_tool_use: Option<DeferredToolUse>,
105
106    /// Provenance of the message/run.
107    #[serde(skip_serializing_if = "Option::is_none")]
108    pub origin: Option<super::message_types::MessageOrigin>,
109}
110
111/// Usage and cost for a single model within a session, as found in
112/// [`ResultMessage::model_usage`].
113///
114/// The `extra` field captures any keys the CLI adds that aren't modeled here,
115/// so new wire fields deserialize without error.
116#[derive(Debug, Clone, Default, Serialize, Deserialize)]
117#[serde(rename_all = "camelCase")]
118pub struct ModelUsageEntry {
119    #[serde(default)]
120    pub input_tokens: u64,
121    #[serde(default)]
122    pub output_tokens: u64,
123    #[serde(default)]
124    pub cache_read_input_tokens: u64,
125    #[serde(default)]
126    pub cache_creation_input_tokens: u64,
127    #[serde(default, rename = "costUSD")]
128    pub cost_usd: f64,
129    #[serde(default)]
130    pub web_search_requests: u32,
131    #[serde(default)]
132    pub context_window: u64,
133    #[serde(default)]
134    pub max_output_tokens: u64,
135    #[serde(flatten)]
136    pub extra: serde_json::Map<String, serde_json::Value>,
137}
138
139/// Tool use deferred by a terminal result.
140#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
141pub struct DeferredToolUse {
142    pub id: String,
143    pub name: String,
144    pub input: Value,
145}
146
147/// A record of a tool permission that was denied during the session.
148///
149/// This is included in `ResultMessage.permission_denials` to provide a summary
150/// of all permission denials that occurred.
151#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
152pub struct PermissionDenial {
153    /// The name of the tool that was blocked (e.g., "Bash", "Write")
154    pub tool_name: String,
155
156    /// The input that was passed to the tool
157    pub tool_input: Value,
158
159    /// The unique identifier for this tool use request
160    pub tool_use_id: String,
161}
162
163/// Why fast mode can't serve right now, carried on `result` frames and
164/// `system/init` (CLI 2.1.219+). Absent when nothing blocks fast mode.
165#[derive(Debug, Clone, PartialEq, Eq, Hash)]
166pub enum FastModeDisabledReason {
167    /// Free-tier account.
168    Free,
169    /// Disabled by user preference.
170    Preference,
171    /// Extra-usage purchases are disabled for the account.
172    ExtraUsageDisabled,
173    /// A network error prevented fast-mode eligibility from resolving.
174    NetworkError,
175    /// The CLI could not determine the reason.
176    UnknownReason,
177    /// Not a first-party API session (e.g. Bedrock/Vertex).
178    NotFirstParty,
179    /// Disabled via environment variable.
180    DisabledByEnv,
181    /// The active model does not support fast mode.
182    ModelNotAllowed,
183    /// SDK sessions must opt in to fast mode.
184    SdkOptInRequired,
185    /// Eligibility is still being determined.
186    Pending,
187    /// A reason not yet known to this version of the crate.
188    Unknown(String),
189}
190
191impl FastModeDisabledReason {
192    pub fn as_str(&self) -> &str {
193        match self {
194            Self::Free => "free",
195            Self::Preference => "preference",
196            Self::ExtraUsageDisabled => "extra_usage_disabled",
197            Self::NetworkError => "network_error",
198            Self::UnknownReason => "unknown",
199            Self::NotFirstParty => "not_first_party",
200            Self::DisabledByEnv => "disabled_by_env",
201            Self::ModelNotAllowed => "model_not_allowed",
202            Self::SdkOptInRequired => "sdk_opt_in_required",
203            Self::Pending => "pending",
204            Self::Unknown(s) => s.as_str(),
205        }
206    }
207}
208
209impl fmt::Display for FastModeDisabledReason {
210    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
211        f.write_str(self.as_str())
212    }
213}
214
215impl From<&str> for FastModeDisabledReason {
216    fn from(s: &str) -> Self {
217        match s {
218            "free" => Self::Free,
219            "preference" => Self::Preference,
220            "extra_usage_disabled" => Self::ExtraUsageDisabled,
221            "network_error" => Self::NetworkError,
222            "unknown" => Self::UnknownReason,
223            "not_first_party" => Self::NotFirstParty,
224            "disabled_by_env" => Self::DisabledByEnv,
225            "model_not_allowed" => Self::ModelNotAllowed,
226            "sdk_opt_in_required" => Self::SdkOptInRequired,
227            "pending" => Self::Pending,
228            other => Self::Unknown(other.to_string()),
229        }
230    }
231}
232
233impl Serialize for FastModeDisabledReason {
234    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
235        serializer.serialize_str(self.as_str())
236    }
237}
238
239impl<'de> Deserialize<'de> for FastModeDisabledReason {
240    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
241        let s = String::deserialize(deserializer)?;
242        Ok(Self::from(s.as_str()))
243    }
244}
245
246/// Result subtypes
247#[derive(Debug, Clone, PartialEq, Eq, Hash)]
248pub enum ResultSubtype {
249    Success,
250    ErrorMaxTurns,
251    ErrorDuringExecution,
252    ErrorMaxBudgetUsd,
253    ErrorMaxStructuredOutputRetries,
254    Unknown(String),
255}
256
257impl ResultSubtype {
258    pub fn as_str(&self) -> &str {
259        match self {
260            Self::Success => "success",
261            Self::ErrorMaxTurns => "error_max_turns",
262            Self::ErrorDuringExecution => "error_during_execution",
263            Self::ErrorMaxBudgetUsd => "error_max_budget_usd",
264            Self::ErrorMaxStructuredOutputRetries => "error_max_structured_output_retries",
265            Self::Unknown(s) => s.as_str(),
266        }
267    }
268}
269
270impl fmt::Display for ResultSubtype {
271    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
272        f.write_str(self.as_str())
273    }
274}
275
276impl From<&str> for ResultSubtype {
277    fn from(s: &str) -> Self {
278        match s {
279            "success" => Self::Success,
280            "error_max_turns" => Self::ErrorMaxTurns,
281            "error_during_execution" => Self::ErrorDuringExecution,
282            "error_max_budget_usd" => Self::ErrorMaxBudgetUsd,
283            "error_max_structured_output_retries" => Self::ErrorMaxStructuredOutputRetries,
284            other => Self::Unknown(other.to_string()),
285        }
286    }
287}
288
289impl Serialize for ResultSubtype {
290    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
291        serializer.serialize_str(self.as_str())
292    }
293}
294
295impl<'de> Deserialize<'de> for ResultSubtype {
296    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
297        let s = String::deserialize(deserializer)?;
298        Ok(Self::from(s.as_str()))
299    }
300}
301
302/// Usage information for the request
303///
304/// Note: the `result` frame's usage covers the **main agent only** — the
305/// subagent (`Task` / sidechain) token rollup the CLI renders as
306/// `<subagent_tokens>` / `<agent_count>` is not carried here or anywhere
307/// else on the wire. Accumulate it from `Task` tool results with
308/// [`SubagentUsageRollup`](crate::SubagentUsageRollup).
309#[derive(Debug, Clone, Serialize, Deserialize)]
310pub struct UsageInfo {
311    #[serde(default)]
312    pub input_tokens: u32,
313    #[serde(default)]
314    pub cache_creation_input_tokens: u32,
315    #[serde(default)]
316    pub cache_read_input_tokens: u32,
317    #[serde(default)]
318    pub output_tokens: u32,
319    #[serde(default)]
320    pub server_tool_use: ServerToolUse,
321    #[serde(default)]
322    pub service_tier: String,
323
324    /// Cache creation breakdown
325    #[serde(skip_serializing_if = "Option::is_none")]
326    pub cache_creation: Option<super::message_types::CacheCreationDetails>,
327
328    /// Inference geography (e.g., "not_available")
329    #[serde(skip_serializing_if = "Option::is_none")]
330    pub inference_geo: Option<String>,
331
332    /// Per-turn usage breakdown
333    #[serde(default, skip_serializing_if = "Vec::is_empty")]
334    pub iterations: Vec<Value>,
335
336    /// Speed tier (e.g., "standard")
337    #[serde(skip_serializing_if = "Option::is_none")]
338    pub speed: Option<String>,
339}
340
341/// Server tool usage information
342#[derive(Debug, Clone, Default, Serialize, Deserialize)]
343pub struct ServerToolUse {
344    #[serde(default)]
345    pub web_search_requests: u32,
346    /// Number of web fetch requests made
347    #[serde(default)]
348    pub web_fetch_requests: u32,
349}
350
351#[cfg(test)]
352mod tests {
353    use super::*;
354    use crate::io::ClaudeOutput;
355
356    #[test]
357    fn test_deserialize_result_message() {
358        let json = r#"{
359            "type": "result",
360            "subtype": "success",
361            "is_error": false,
362            "duration_ms": 100,
363            "duration_api_ms": 200,
364            "num_turns": 1,
365            "result": "Done",
366            "session_id": "123",
367            "total_cost_usd": 0.01,
368            "permission_denials": []
369        }"#;
370
371        let output: ClaudeOutput = serde_json::from_str(json).unwrap();
372        assert!(!output.is_error());
373    }
374
375    #[test]
376    fn test_result_subtype_new_and_unknown_values_do_not_fail() {
377        let json = r#"{
378            "type": "result",
379            "subtype": "error_max_budget_usd",
380            "is_error": true,
381            "duration_ms": 100,
382            "duration_api_ms": 200,
383            "num_turns": 1,
384            "session_id": "123",
385            "total_cost_usd": 0.01
386        }"#;
387
388        let output: ClaudeOutput = serde_json::from_str(json).unwrap();
389        let ClaudeOutput::Result(result) = output else {
390            panic!("Expected Result");
391        };
392        assert_eq!(result.subtype, ResultSubtype::ErrorMaxBudgetUsd);
393
394        let json = r#"{
395            "type": "result",
396            "subtype": "future_result_subtype",
397            "is_error": true,
398            "duration_ms": 100,
399            "duration_api_ms": 200,
400            "num_turns": 1,
401            "session_id": "123",
402            "total_cost_usd": 0.01
403        }"#;
404
405        let output: ClaudeOutput = serde_json::from_str(json).unwrap();
406        let ClaudeOutput::Result(result) = output else {
407            panic!("Expected Result");
408        };
409        assert_eq!(
410            result.subtype,
411            ResultSubtype::Unknown("future_result_subtype".to_string())
412        );
413    }
414
415    #[test]
416    fn test_deserialize_result_with_permission_denials() {
417        let json = r#"{
418            "type": "result",
419            "subtype": "success",
420            "is_error": false,
421            "duration_ms": 100,
422            "duration_api_ms": 200,
423            "num_turns": 2,
424            "result": "Done",
425            "session_id": "123",
426            "total_cost_usd": 0.01,
427            "permission_denials": [
428                {
429                    "tool_name": "Bash",
430                    "tool_input": {"command": "rm -rf /", "description": "Delete everything"},
431                    "tool_use_id": "toolu_123"
432                }
433            ]
434        }"#;
435
436        let output: ClaudeOutput = serde_json::from_str(json).unwrap();
437        if let ClaudeOutput::Result(result) = output {
438            assert_eq!(result.permission_denials.len(), 1);
439            assert_eq!(result.permission_denials[0].tool_name, "Bash");
440            assert_eq!(result.permission_denials[0].tool_use_id, "toolu_123");
441            assert_eq!(
442                result.permission_denials[0]
443                    .tool_input
444                    .get("command")
445                    .unwrap(),
446                "rm -rf /"
447            );
448        } else {
449            panic!("Expected Result");
450        }
451    }
452
453    #[test]
454    fn test_permission_denial_roundtrip() {
455        let denial = PermissionDenial {
456            tool_name: "Write".to_string(),
457            tool_input: serde_json::json!({"file_path": "/etc/passwd", "content": "bad"}),
458            tool_use_id: "toolu_456".to_string(),
459        };
460
461        let json = serde_json::to_string(&denial).unwrap();
462        assert!(json.contains("\"tool_name\":\"Write\""));
463        assert!(json.contains("\"tool_use_id\":\"toolu_456\""));
464        assert!(json.contains("/etc/passwd"));
465
466        let parsed: PermissionDenial = serde_json::from_str(&json).unwrap();
467        assert_eq!(parsed, denial);
468    }
469
470    #[test]
471    fn test_deserialize_result_message_with_errors() {
472        let json = r#"{
473            "type": "result",
474            "subtype": "error_during_execution",
475            "duration_ms": 0,
476            "duration_api_ms": 0,
477            "is_error": true,
478            "num_turns": 0,
479            "session_id": "27934753-425a-4182-892c-6b1c15050c3f",
480            "total_cost_usd": 0,
481            "errors": ["No conversation found with session ID: d56965c9-c855-4042-a8f5-f12bbb14d6f6"],
482            "permission_denials": []
483        }"#;
484
485        let output: ClaudeOutput = serde_json::from_str(json).unwrap();
486        assert!(output.is_error());
487
488        if let ClaudeOutput::Result(res) = output {
489            assert!(res.is_error);
490            assert_eq!(res.errors.len(), 1);
491            assert!(res.errors[0].contains("No conversation found"));
492        } else {
493            panic!("Expected Result message");
494        }
495    }
496
497    #[test]
498    fn test_deserialize_result_message_errors_defaults_empty() {
499        let json = r#"{
500            "type": "result",
501            "subtype": "success",
502            "is_error": false,
503            "duration_ms": 100,
504            "duration_api_ms": 200,
505            "num_turns": 1,
506            "session_id": "123",
507            "total_cost_usd": 0.01
508        }"#;
509
510        let output: ClaudeOutput = serde_json::from_str(json).unwrap();
511        if let ClaudeOutput::Result(res) = output {
512            assert!(res.errors.is_empty());
513        } else {
514            panic!("Expected Result message");
515        }
516    }
517
518    #[test]
519    fn test_result_message_errors_roundtrip() {
520        let json = r#"{
521            "type": "result",
522            "subtype": "error_during_execution",
523            "is_error": true,
524            "duration_ms": 0,
525            "duration_api_ms": 0,
526            "num_turns": 0,
527            "session_id": "test-session",
528            "total_cost_usd": 0.0,
529            "errors": ["Error 1", "Error 2"]
530        }"#;
531
532        let output: ClaudeOutput = serde_json::from_str(json).unwrap();
533        let reserialized = serde_json::to_string(&output).unwrap();
534
535        assert!(reserialized.contains("Error 1"));
536        assert!(reserialized.contains("Error 2"));
537    }
538
539    #[test]
540    fn test_result_with_new_fields() {
541        let json = r#"{
542            "type": "result",
543            "subtype": "success",
544            "is_error": false,
545            "duration_ms": 5000,
546            "duration_api_ms": 4500,
547            "num_turns": 1,
548            "result": "Done",
549            "session_id": "abc",
550            "total_cost_usd": 0.06,
551            "api_error_status": null,
552            "stop_reason": "end_turn",
553            "terminal_reason": "completed",
554            "fast_mode_state": "off",
555            "modelUsage": {
556                "claude-opus-4-7[1m]": {
557                    "inputTokens": 3817,
558                    "outputTokens": 14,
559                    "costUSD": 0.06
560                }
561            },
562            "usage": {
563                "input_tokens": 3817,
564                "output_tokens": 14,
565                "cache_creation_input_tokens": 3540,
566                "cache_read_input_tokens": 0,
567                "server_tool_use": {
568                    "web_search_requests": 0,
569                    "web_fetch_requests": 2
570                },
571                "service_tier": "standard",
572                "inference_geo": "not_available",
573                "speed": "standard",
574                "iterations": [
575                    {"input_tokens": 3817, "output_tokens": 14, "type": "turn"}
576                ]
577            }
578        }"#;
579
580        let output: ClaudeOutput = serde_json::from_str(json).unwrap();
581        if let ClaudeOutput::Result(res) = output {
582            assert_eq!(res.stop_reason.as_deref(), Some("end_turn"));
583            assert_eq!(res.terminal_reason.as_deref(), Some("completed"));
584            assert_eq!(res.fast_mode_state.as_deref(), Some("off"));
585            let model_usage = res.model_usage.as_ref().unwrap();
586            let entry = model_usage
587                .get("claude-opus-4-7[1m]")
588                .expect("per-model entry present");
589            assert_eq!(entry.input_tokens, 3817);
590            assert_eq!(entry.output_tokens, 14);
591            assert_eq!(entry.cost_usd, 0.06);
592            assert!(res.api_error_status.is_none());
593
594            let usage = res.usage.unwrap();
595            assert_eq!(usage.server_tool_use.web_fetch_requests, 2);
596            assert_eq!(usage.inference_geo.as_deref(), Some("not_available"));
597            assert_eq!(usage.speed.as_deref(), Some("standard"));
598            assert_eq!(usage.iterations.len(), 1);
599        } else {
600            panic!("Expected Result");
601        }
602    }
603
604    #[test]
605    fn test_result_backwards_compatible_without_new_fields() {
606        // Verify old-format messages still parse fine
607        let json = r#"{
608            "type": "result",
609            "subtype": "success",
610            "is_error": false,
611            "duration_ms": 100,
612            "duration_api_ms": 200,
613            "num_turns": 1,
614            "session_id": "abc",
615            "total_cost_usd": 0.01
616        }"#;
617
618        let output: ClaudeOutput = serde_json::from_str(json).unwrap();
619        if let ClaudeOutput::Result(res) = output {
620            assert!(res.api_error_status.is_none());
621            assert!(res.stop_reason.is_none());
622            assert!(res.terminal_reason.is_none());
623            assert!(res.fast_mode_state.is_none());
624            assert!(res.model_usage.is_none());
625        } else {
626            panic!("Expected Result");
627        }
628    }
629
630    #[test]
631    fn test_result_fast_mode_disabled_reason() {
632        let json = r#"{
633            "type":"result","subtype":"success","is_error":false,
634            "duration_ms":100,"duration_api_ms":80,"num_turns":1,
635            "session_id":"s1","total_cost_usd":0.01,
636            "fast_mode_state":"off",
637            "fast_mode_disabled_reason":"sdk_opt_in_required"
638        }"#;
639        let output: crate::ClaudeOutput = serde_json::from_str(json).unwrap();
640        let crate::ClaudeOutput::Result(res) = &output else {
641            panic!("expected Result");
642        };
643        assert_eq!(
644            res.fast_mode_disabled_reason,
645            Some(FastModeDisabledReason::SdkOptInRequired)
646        );
647        assert!(serde_json::to_string(&output)
648            .unwrap()
649            .contains("\"fast_mode_disabled_reason\":\"sdk_opt_in_required\""));
650
651        // Unknown reasons survive decode and round-trip verbatim; the wire
652        // literal "unknown" maps to the typed UnknownReason, not the fallback.
653        assert_eq!(
654            FastModeDisabledReason::from("unknown"),
655            FastModeDisabledReason::UnknownReason
656        );
657        let novel = FastModeDisabledReason::from("solar_flare");
658        assert_eq!(novel, FastModeDisabledReason::Unknown("solar_flare".into()));
659        assert_eq!(novel.as_str(), "solar_flare");
660    }
661
662    #[test]
663    fn test_result_timing_and_user_message_uuid_fields() {
664        let json = r#"{
665            "type":"result","subtype":"success","is_error":false,
666            "duration_ms":100,"duration_api_ms":80,"num_turns":1,
667            "session_id":"s1","total_cost_usd":0.01,
668            "request_sent_wall_ms":1753212345678.25,
669            "user_message_uuid":"um-1"
670        }"#;
671        let output: crate::ClaudeOutput = serde_json::from_str(json).unwrap();
672        let crate::ClaudeOutput::Result(res) = &output else {
673            panic!("expected Result");
674        };
675        assert_eq!(res.request_sent_wall_ms, Some(1753212345678.25));
676        assert_eq!(res.user_message_uuid.as_deref(), Some("um-1"));
677
678        let reserialized = serde_json::to_string(&output).unwrap();
679        assert!(reserialized.contains("\"user_message_uuid\":\"um-1\""));
680    }
681}