mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 00:58:30 +00:00
Fix Flow persistence with nested Pydantic models (issue #2929)
- Use CrewJSONEncoder in SQLiteFlowPersistence.save_state() to properly serialize nested Pydantic models - Add comprehensive test for nested Pydantic model persistence - Resolves RuntimeError: Object of type CustomPydanticModel is not JSON serializable Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -11,6 +11,7 @@ from typing import Any, Dict, Optional, Union
|
||||
from pydantic import BaseModel
|
||||
|
||||
from crewai.flow.persistence.base import FlowPersistence
|
||||
from crewai.utilities.crew_json_encoder import CrewJSONEncoder
|
||||
|
||||
|
||||
class SQLiteFlowPersistence(FlowPersistence):
|
||||
@@ -103,7 +104,7 @@ class SQLiteFlowPersistence(FlowPersistence):
|
||||
flow_uuid,
|
||||
method_name,
|
||||
datetime.now(timezone.utc).isoformat(),
|
||||
json.dumps(state_dict),
|
||||
json.dumps(state_dict, cls=CrewJSONEncoder),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user