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