Skip to main content

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