objectiveai_sdk/vector/completions/response/streaming/inner_error.rs
1use std::borrow::Cow;
2
3use serde::{Deserialize, Serialize};
4
5use crate::error;
6
7/// An error from a single agent completion inside a [`VectorCompletionChunk`](super::VectorCompletionChunk).
8///
9/// Yielded by [`VectorCompletionChunk::inner_errors`](super::VectorCompletionChunk::inner_errors).
10/// Identifies the failing completion by its `index` (matching
11/// [`AgentCompletionChunk::index`](super::AgentCompletionChunk::index)) and
12/// carries the underlying [`ResponseError`](error::ResponseError) as a `Cow`
13/// so iteration is zero-allocation (`Cow::Borrowed`) while deserialization
14/// always lands in `Cow::Owned`.
15///
16/// Wire shape:
17/// ```json
18/// { "agent_completion_index": 1, "error": { ... } }
19/// ```
20#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
21pub struct InnerError<'a> {
22 /// Index of the failing completion (matches `AgentCompletionChunk::index`).
23 pub agent_completion_index: u64,
24 /// The underlying error from the agent completion.
25 pub error: Cow<'a, error::ResponseError>,
26}