pub struct Response {
pub task: Task,
pub success: bool,
pub tokens: u64,
pub model: String,
pub contents: String,
}Expand description
Execution outcome, distinct from queue or executor transport errors.
Fields§
§task: TaskOriginal task; the API executor updates its history on successful output.
success: boolWhether contents represent output (true) or an execution failure (false).
tokens: u64Token usage; the API executor reports total tokens, or zero if absent.
model: StringResolved request model; not necessarily the model name returned by the API.
contents: StringOutput text or failure details; structured output remains JSON text.
Implementations§
Source§impl Response
impl Response
Sourcepub fn success<M: ToString, C: ToString>(
task: Task,
tokens: u64,
model: M,
contents: C,
) -> Self
pub fn success<M: ToString, C: ToString>( task: Task, tokens: u64, model: M, contents: C, ) -> Self
Creates a successful response without changing the task or its history.
Sourcepub fn error<M: ToString, C: ToString>(
task: Task,
tokens: u64,
model: M,
error: C,
) -> Self
pub fn error<M: ToString, C: ToString>( task: Task, tokens: u64, model: M, error: C, ) -> Self
Creates an unsuccessful response with failure details in contents.
Sourcepub fn with_history(self, history: Vec<Interaction>) -> Self
pub fn with_history(self, history: Vec<Interaction>) -> Self
Replaces the history stored inside the returned task’s JSON contents.
§Panics
Panics if task contents are neither a JSON object nor null.
Sourcepub fn chat_history(&self) -> Result<Vec<Interaction>>
pub fn chat_history(&self) -> Result<Vec<Interaction>>
Decodes returned history; missing, null, or malformed history is an error. The API executor currently includes the latest user prompt twice.