Skip to main content

tool_error

Function tool_error 

Source
pub fn tool_error(code: &str, msg: &str) -> CallToolResult
Expand description

Build a typed-code tool-error response without a structured details payload. Text channel reads "ERROR [<CODE>]: <msg>" and structured_content carries {code, message} (no details); the code field matches the wire envelope agents see from tool_error_with_payload, so consumers that branch on the UPPER_SNAKE_CASE token get the same shape on either form. Use this helper when the failure has no structured recovery payload beyond the message body; reach for tool_error_with_payload otherwise.

Pre-fix the text channel emitted "ERROR: <msg>" without the typed code, leaving the prefix-form contract a half-delivered promise on the simple form.