objectiveai_sdk/functions/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 [`FunctionExecutionChunk`](super::FunctionExecutionChunk).
9///
10/// Each variant carries `task_path` — the full hierarchical path from the
11/// root execution down to the failing task (or, for the reasoning variant,
12/// to the execution whose reasoning agent failed). Empty `task_path` means
13/// the error is at the root execution itself.
14///
15/// Wire shape (internally tagged on `"type"`):
16/// ```json
17/// {"type":"function_task_error","task_path":[0],
18/// "swiss_pool_index":1,"swiss_round":0,"error":{}}
19/// {"type":"vector_completion_task_error","task_path":[0,1],"error":{}}
20/// {"type":"vector_completion_task_error","task_path":[0,1],
21/// "agent_completion_index":2,"error":{}}
22/// {"type":"reasoning_agent_completion_error","task_path":[],"error":{}}
23/// ```
24///
25/// Does NOT include:
26/// - The chunk's own top-level `.error` — reachable directly via
27/// [`FunctionExecutionChunk::error`](super::FunctionExecutionChunk::error).
28/// - The reasoning summary's own `.error`; only the inner agent
29/// completion's failure surfaces as a reasoning error.
30#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
31#[serde(tag = "type", rename_all = "snake_case")]
32#[schemars(rename = "functions.executions.response.streaming.InnerError")]
33pub enum InnerError<'a> {
34 /// A nested function execution task failed at its top level.
35 /// Yielded when a
36 /// [`FunctionExecutionTaskChunk`](super::FunctionExecutionTaskChunk)'s
37 /// wrapped inner `FunctionExecutionChunk` has its own `.error` set.
38 ///
39 /// `task_path` locates the failing task; `swiss_pool_index` /
40 /// `swiss_round` / `split_index` carry the tournament/split context
41 /// from the wrapper when set.
42 #[schemars(title = "FunctionTaskError")]
43 FunctionTaskError {
44 task_path: Vec<u64>,
45 #[serde(default, skip_serializing_if = "Option::is_none")]
46 #[schemars(extend("omitempty" = true))]
47 swiss_pool_index: Option<u64>,
48 #[serde(default, skip_serializing_if = "Option::is_none")]
49 #[schemars(extend("omitempty" = true))]
50 swiss_round: Option<u64>,
51 #[serde(default, skip_serializing_if = "Option::is_none")]
52 #[schemars(extend("omitempty" = true))]
53 split_index: Option<u64>,
54 error: Cow<'a, error::ResponseError>,
55 },
56 /// A vector completion task failed. The optional `agent_completion_index`
57 /// is the discriminator:
58 /// - `None` → the task itself failed (the wrapper's own `.error`).
59 /// - `Some(N)` → agent completion `N` inside the task's vector
60 /// completion failed.
61 ///
62 /// `task_path` locates the vector completion task.
63 #[schemars(title = "VectorCompletionTaskError")]
64 VectorCompletionTaskError {
65 task_path: Vec<u64>,
66 #[serde(default, skip_serializing_if = "Option::is_none")]
67 #[schemars(extend("omitempty" = true))]
68 agent_completion_index: Option<u64>,
69 error: Cow<'a, error::ResponseError>,
70 },
71 /// The inner agent completion of a reasoning summary failed
72 /// (`ReasoningSummaryChunk.inner.error`).
73 ///
74 /// `task_path` identifies whose reasoning — empty for the root
75 /// execution; non-empty for a nested execution at that path.
76 #[schemars(title = "ReasoningAgentCompletionError")]
77 ReasoningAgentCompletionError {
78 task_path: Vec<u64>,
79 error: Cow<'a, error::ResponseError>,
80 },
81}