#[non_exhaustive]pub enum PromptError {
Provider(ProviderError),
Report(ErrorReport),
Memory {
error: SessionError,
response: Option<Box<PromptResponse>>,
},
MaxTurns {
max_turns: usize,
chat_history: Vec<Message>,
prompt: Message,
},
Cancelled {
chat_history: Vec<Message>,
reason: String,
},
UnknownToolCall {
tool_name: String,
available_tools: Vec<String>,
allowed_tools: Vec<String>,
chat_history: Vec<Message>,
},
}Expand description
Why an agent run failed, whether it was awaited or streamed.
Variants that wrap another error display it unchanged and forward its source.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Provider(ProviderError)
A provider completion failed.
Report(ErrorReport)
Structured effect failure from a handler, a hook, or a stream item. A relayed provider failure arrives as its report.
Memory
The run’s conversation could not be loaded from its memory store,
before any model call, or the finished run could not be saved there
(AgentBuilder::memory). The run did
not succeed. A failed save may already have set aside a torn last
line the log ended in (to recovered/ in the store) and stored the
blobs of the run’s images; its own append stored nothing or, cut
short, a cut last line, which the next save sets aside. A remote
store that applied the append before failing to answer may hold all
of it.
Fields
error: SessionErrorWhy the store refused or failed, such as
SessionError::Changed when
another run saved to the log after this one loaded it.
response: Option<Box<PromptResponse>>The finished run whose save failed; None when the load did.
MaxTurns
The run exhausted its total model-call budget.
Fields
Cancelled
The run was cancelled.
Fields
UnknownToolCall
The model attempted to call a tool unavailable for the current turn.
Implementations§
Source§impl PromptError
impl PromptError
Sourcepub fn provider_response_body(&self) -> Option<&str>
pub fn provider_response_body(&self) -> Option<&str>
Returns the provider response body exposed by a wrapped completion error.
Sourcepub fn provider_response_json(&self) -> Result<Option<Value>, Error>
pub fn provider_response_json(&self) -> Result<Option<Value>, Error>
Parses the provider response body of a wrapped completion error as JSON when present.
Sourcepub fn provider_request_id(&self) -> Option<&str>
pub fn provider_request_id(&self) -> Option<&str>
Returns the provider transport request id exposed by a wrapped completion error, or carried by a wire report.
Sourcepub fn provider_response_status(&self) -> Option<StatusCode>
pub fn provider_response_status(&self) -> Option<StatusCode>
Returns the HTTP status exposed by a wrapped completion error, or carried by a wire report.
Sourcepub fn provider_response_headers(&self) -> Option<&HeaderMap>
pub fn provider_response_headers(&self) -> Option<&HeaderMap>
Returns the response headers exposed by a wrapped completion error or report.
Source§impl PromptError
impl PromptError
Sourcepub fn cancelled(chat_history: Vec<Message>, reason: impl Into<String>) -> Self
pub fn cancelled(chat_history: Vec<Message>, reason: impl Into<String>) -> Self
Build a PromptError::Cancelled. A driver gets the history from
AgentRun::cancel_error, or closes
its own with repair.
Trait Implementations§
Source§impl Debug for PromptError
impl Debug for PromptError
Source§impl Display for PromptError
impl Display for PromptError
Source§impl Error for PromptError
impl Error for PromptError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<ErrorReport> for PromptError
impl From<ErrorReport> for PromptError
Source§fn from(source: ErrorReport) -> Self
fn from(source: ErrorReport) -> Self
Source§impl From<PromptError> for StreamToStdoutError
impl From<PromptError> for StreamToStdoutError
Source§fn from(source: PromptError) -> Self
fn from(source: PromptError) -> Self
Source§impl From<PromptError> for StructuredOutputError
impl From<PromptError> for StructuredOutputError
Source§fn from(source: PromptError) -> Self
fn from(source: PromptError) -> Self
Source§impl From<PromptError> for ScenarioError
Available on crate feature test-utils only.
impl From<PromptError> for ScenarioError
test-utils only.Source§fn from(source: PromptError) -> Self
fn from(source: PromptError) -> Self
Source§impl From<ProviderError> for PromptError
A relayed failure is the report the origin sent.
impl From<ProviderError> for PromptError
A relayed failure is the report the origin sent.