@@ -20,6 +20,8 @@ import { AgenticaConstant } from "../constants/AgenticaConstant";
2020import { AgenticaDefaultPrompt } from "../constants/AgenticaDefaultPrompt" ;
2121import { AgenticaSystemPrompt } from "../constants/AgenticaSystemPrompt" ;
2222import { isAgenticaContext } from "../context/internal/isAgenticaContext" ;
23+ import { AgenticaJsonParseError } from "../errors/AgenticaJsonParseError" ;
24+ import { AgenticaValidationError } from "../errors/AgenticaValidationError" ;
2325import { createAssistantMessageEvent , createCallEvent , createExecuteEvent , createJsonParseErrorEvent , createValidateEvent } from "../factory/events" ;
2426import { decodeHistory , decodeUserMessageContent } from "../factory/histories" ;
2527import { __get_retry } from "../utils/__retry" ;
@@ -223,11 +225,10 @@ async function correctTypeError(
223225 call_id : callEvent . id ,
224226 operation : callEvent . operation ,
225227 arguments : callEvent . arguments ,
226- value : {
227- name : "ValidationError" ,
228- message : `Invalid arguments. The validation failed after ${ AgenticaConstant . RETRY } retries.` ,
228+ value : new AgenticaValidationError ( {
229+ arguments : callEvent . arguments ,
229230 errors : validateEvent . result . errors ,
230- } ,
231+ } ) ,
231232 success : false ,
232233 } ) ,
233234 operation : callEvent . operation ,
@@ -283,12 +284,10 @@ async function correctJsonError(
283284 call_id : toolCall . id ,
284285 operation : parseErrorEvent . operation ,
285286 arguments : { } ,
286- value : {
287- name : "JsonParseError" ,
288- message : `Invalid JSON format. The parsing failed after ${ AgenticaConstant . RETRY } retries.` ,
287+ value : new AgenticaJsonParseError ( {
289288 arguments : parseErrorEvent . arguments ,
290- errorMessage : parseErrorEvent . errorMessage ,
291- } ,
289+ reason : parseErrorEvent . errorMessage ,
290+ } ) ,
292291 success : false ,
293292 } ) ,
294293 operation : parseErrorEvent . operation ,
0 commit comments