@@ -251,9 +251,13 @@ def extraction_tool(
251251 When you call this tool it overwrites the previous extraction, if you want to expand the extraction use jsonpatch.
252252 This tool needs to be Successfully invoked before the patch tool can be used."""
253253
254- logger .info ("extraction_tool called" , extra = {"models_extraction" : extraction })
255- extraction_model = model_class (** extraction ) # pyright: ignore[reportAssignmentType]
256- extraction_dict = extraction_model .model_dump ()
254+ # Note: The @tool decorator passes data as a dict, not as a model instance
255+ # We need to validate it manually using the Pydantic model
256+ extraction_model = model_class .model_validate (extraction ) # pyright: ignore[reportAssignmentType]
257+ extraction_dict = extraction_model .model_dump (mode = "json" )
258+ logger .info (
259+ "extraction_tool called" , extra = {"models_extraction" : extraction_dict }
260+ )
257261 agent .state .set (key = "current_extraction" , value = extraction_dict )
258262 logger .debug (
259263 "Successfully stored extraction in state" ,
@@ -1000,7 +1004,9 @@ async def structured_output_async(
10001004 state = {
10011005 "current_extraction" : None ,
10021006 "images" : {},
1003- "existing_data" : existing_data .model_dump () if existing_data else None ,
1007+ "existing_data" : existing_data .model_dump (mode = "json" )
1008+ if existing_data
1009+ else None ,
10041010 "extraction_schema_json" : schema_json , # Store for schema reminder tool
10051011 },
10061012 conversation_manager = SummarizingConversationManager (
0 commit comments