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