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