Skip to main content

format_tool_error

Function format_tool_error 

Source
pub fn format_tool_error(e: &Error) -> String
Expand description

Error-aware serialization for tool-execution error paths. Replaces e.to_string() at the sites that hand the model a failure message:

  • Error::Tool(s)s (drops the "tool error: " prefix from e.to_string()).
  • Error::ToolExecutionFailed { output, .. }output (drops the "tool execution failed: " prefix).
  • Error::ToolFail { output, code:None, hint:None, .. }output.
  • Error::ToolFail { output, code, hint, .. } (either set) → JSON {message, code?, hint?}.
  • everything else → e.to_string() (the thiserror-formatted string).