ToolCallErrorJson

org.llm4s.toolapi.ToolCallErrorJson
@Stable

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|timeout|cancelled>",
 "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
   }
 ]
}

Attributes

Source
ToolParameterError.scala
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

Source
ToolParameterError.scala

Convert a ToolParameterError to structured JSON for parameterErrors array

Convert a ToolParameterError to structured JSON for parameterErrors array

Attributes

Source
ToolParameterError.scala
def toJson(error: ToolCallError): Obj

Convert a ToolCallError to structured JSON for ToolMessage.content.

Convert a ToolCallError to structured JSON for ToolMessage.content.

Value parameters

error

The tool call error to serialize

Attributes

Returns

ujson.Obj containing structured error information

Source
ToolParameterError.scala