@@ -291,7 +291,8 @@ def apply_json_patches(
291291 patched_data = apply_patches_to_data (current_data , patches )
292292 validated_patched_data = model_class (** patched_data )
293293 agent .state .set (
294- key = "current_extraction" , value = validated_patched_data .model_dump ()
294+ key = "current_extraction" ,
295+ value = validated_patched_data .model_dump (mode = "json" ),
295296 )
296297
297298 return {
@@ -303,9 +304,9 @@ def apply_json_patches(
303304 def make_buffer_data_final_extraction (agent : Agent ) -> str :
304305 valid_extraction = model_class (** agent .state .get ("intermediate_extraction" ))
305306
306- agent .state .set ("current_extraction" , valid_extraction .model_dump ())
307+ agent .state .set ("current_extraction" , valid_extraction .model_dump (mode = "json" ))
307308
308- return f"Successfully made the existing extraction the same as the buffer data { str (valid_extraction .model_dump ())[100 : ]} ..."
309+ return f"Successfully made the existing extraction the same as the buffer data { str (valid_extraction .model_dump (mode = 'json' ))[: 100 ]} ..."
309310
310311 return extraction_tool , apply_json_patches , make_buffer_data_final_extraction
311312
@@ -1051,7 +1052,7 @@ async def structured_output_async(
10511052 ContentBlock (
10521053 text = f"""
10531054 You have successfully extracted the following data:
1054- { json .dumps (result .model_dump (), indent = 2 )}
1055+ { json .dumps (result .model_dump (mode = "json" ), indent = 2 )}
10551056
10561057 Please take one final careful look at this extraction:
10571058 1. Check each field against the source document
0 commit comments