Skip to main content

objectiveai_sdk/laboratories/executions/response/streaming/
inner_error.rs

1use std::borrow::Cow;
2
3use serde::{Deserialize, Serialize};
4
5use crate::error;
6
7/// An inner error from a [`LaboratoryExecutionChunk`](super::LaboratoryExecutionChunk).
8///
9/// Yielded by [`LaboratoryExecutionChunk::inner_errors`](super::LaboratoryExecutionChunk::inner_errors).
10/// The variant identifies which child collection the failing agent
11/// completion came from; fields locate it by `index` (builder or
12/// evaluation index) and `agent_index` (agent slot within that builder
13/// or evaluation), with the underlying [`ResponseError`](error::ResponseError)
14/// held as a `Cow` so iteration is zero-allocation while deserialization
15/// still produces a self-owning value.
16///
17/// Wire shape (internally tagged on `"type"`):
18/// ```json
19/// { "type": "builder",    "builder_index": 0,    "agent_completion_index": 1, "error": { } }
20/// { "type": "evaluation", "evaluation_index": 2, "agent_completion_index": 0, "error": { } }
21/// ```
22///
23/// Does NOT include the lab chunk's own top-level `.error` — that
24/// field is the chunk's own failure state and is reachable directly
25/// via [`LaboratoryExecutionChunk::error`](super::LaboratoryExecutionChunk::error).
26#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
27#[serde(tag = "type", rename_all = "snake_case")]
28pub enum InnerError<'a> {
29    /// An error from a [`BuilderChunk`](super::BuilderChunk).
30    Builder {
31        /// Builder index (matches `BuilderChunk::index`).
32        builder_index: u64,
33        /// Agent completion index within the builder (matches `BuilderChunk::agent_index`).
34        agent_completion_index: u64,
35        /// The underlying error from the agent completion.
36        error: Cow<'a, error::ResponseError>,
37    },
38    /// An error from an [`EvaluationChunk`](super::EvaluationChunk).
39    Evaluation {
40        /// Evaluation index (matches `EvaluationChunk::index`).
41        evaluation_index: u64,
42        /// Agent completion index within the evaluation (matches `EvaluationChunk::agent_index`).
43        agent_completion_index: u64,
44        /// The underlying error from the agent completion.
45        error: Cow<'a, error::ResponseError>,
46    },
47}