objectiveai_sdk/functions/inventions/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 [`FunctionInventionChunk`](super::FunctionInventionChunk).
9///
10/// Yielded by [`FunctionInventionChunk::inner_errors`](super::FunctionInventionChunk::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///
22/// Does NOT include the invention chunk's own top-level `.error` — that
23/// field is reachable directly via [`FunctionInventionChunk::error`](super::FunctionInventionChunk::error).
24#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
25#[schemars(rename = "functions.inventions.response.streaming.InnerError")]
26pub struct InnerError<'a> {
27 /// Index of the failing completion (matches `AgentCompletionChunk::index`).
28 pub agent_completion_index: u64,
29 /// The underlying error from the agent completion.
30 pub error: Cow<'a, error::ResponseError>,
31}