ToolCallErrorJson

org.llm4s.toolapi.ToolCallErrorJson

JSON serialization helpers for structured tool error payloads.

Converts ToolCallError and ToolParameterError instances to machine-readable JSON format for ToolMessage.content, enabling LLMs and consumers to programmatically parse validation errors and self-correct tool arguments.

Output schema:

{
 "isError": true,
 "toolName": "<string>",
 "errorType": "<unknown_function|null_arguments|invalid_arguments|handler_error|execution_error>",
 "message": "<human readable summary>",
 "parameterErrors": [   // optional: only present for invalid_arguments
   {
     "parameterName": "<string>",
     "kind": "<missing_parameter|null_parameter|type_mismatch|invalid_nesting>",
     "expectedType": "<string|null>",
     "receivedType": "<string|null>",
     "availableParameters": ["<string>", ...]  // optional hint
   }
 ],
 "error": "<legacy error string for older consumers>"
}

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

Flatten MultipleErrors into a list of individual errors

Flatten MultipleErrors into a list of individual errors

Attributes

Convert a ToolParameterError to structured JSON for parameterErrors array

Convert a ToolParameterError to structured JSON for parameterErrors array

Attributes

def toJson(error: ToolCallError): Obj

Convert a ToolCallError to structured JSON for ToolMessage.content.

Convert a ToolCallError to structured JSON for ToolMessage.content.

Always includes the legacy "error" field for backward compatibility with older consumers that expect the escaped string format.

Value parameters

error

The tool call error to serialize

Attributes

Returns

ujson.Obj containing structured error information