@@ -26,6 +26,7 @@ def validate_memory_url_path(path: str) -> bool:
2626 >>> validate_memory_url_path("invalid://test") # Contains protocol
2727 False
2828 """
29+ # Empty paths are not valid
2930 if not path or not path .strip ():
3031 return False
3132
@@ -68,7 +69,13 @@ def normalize_memory_url(url: str | None) -> str:
6869 ValueError: Invalid memory URL path: 'memory//test' contains double slashes
6970 """
7071 if not url :
71- return ""
72+ raise ValueError ("Memory URL cannot be empty" )
73+
74+ # Strip whitespace for consistency
75+ url = url .strip ()
76+
77+ if not url :
78+ raise ValueError ("Memory URL cannot be empty or whitespace" )
7279
7380 clean_path = url .removeprefix ("memory://" )
7481
@@ -79,8 +86,6 @@ def normalize_memory_url(url: str | None) -> str:
7986 raise ValueError (f"Invalid memory URL path: '{ clean_path } ' contains protocol scheme" )
8087 elif "//" in clean_path :
8188 raise ValueError (f"Invalid memory URL path: '{ clean_path } ' contains double slashes" )
82- elif not clean_path .strip ():
83- raise ValueError ("Memory URL path cannot be empty or whitespace" )
8489 else :
8590 raise ValueError (f"Invalid memory URL path: '{ clean_path } ' contains invalid characters" )
8691
@@ -123,7 +128,9 @@ class EntitySummary(BaseModel):
123128 title : str
124129 content : Optional [str ] = None
125130 file_path : str
126- created_at : datetime
131+ created_at : Annotated [
132+ datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })
133+ ]
127134
128135 @field_serializer ("created_at" )
129136 def serialize_created_at (self , dt : datetime ) -> str :
@@ -140,7 +147,9 @@ class RelationSummary(BaseModel):
140147 relation_type : str
141148 from_entity : Optional [str ] = None
142149 to_entity : Optional [str ] = None
143- created_at : datetime
150+ created_at : Annotated [
151+ datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })
152+ ]
144153
145154 @field_serializer ("created_at" )
146155 def serialize_created_at (self , dt : datetime ) -> str :
@@ -156,7 +165,9 @@ class ObservationSummary(BaseModel):
156165 permalink : str
157166 category : str
158167 content : str
159- created_at : datetime
168+ created_at : Annotated [
169+ datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })
170+ ]
160171
161172 @field_serializer ("created_at" )
162173 def serialize_created_at (self , dt : datetime ) -> str :
@@ -170,7 +181,9 @@ class MemoryMetadata(BaseModel):
170181 types : Optional [List [SearchItemType ]] = None
171182 depth : int
172183 timeframe : Optional [str ] = None
173- generated_at : datetime
184+ generated_at : Annotated [
185+ datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })
186+ ]
174187 primary_count : Optional [int ] = None # Changed field name
175188 related_count : Optional [int ] = None # Changed field name
176189 total_results : Optional [int ] = None # For backward compatibility
@@ -235,9 +248,9 @@ class ProjectActivity(BaseModel):
235248 project_path : str
236249 activity : GraphContext = Field (description = "The actual activity data for this project" )
237250 item_count : int = Field (description = "Total items in this project's activity" )
238- last_activity : Optional [datetime ] = Field (
239- default = None , description = "Most recent activity timestamp"
240- )
251+ last_activity : Optional [
252+ Annotated [ datetime , Field ( json_schema_extra = { "type" : "string" , "format" : "date-time" })]
253+ ] = Field ( default = None , description = "Most recent activity timestamp" )
241254 active_folders : List [str ] = Field (default_factory = list , description = "Most active folders" )
242255
243256 @field_serializer ("last_activity" )
@@ -253,7 +266,9 @@ class ProjectActivitySummary(BaseModel):
253266 )
254267 summary : ActivityStats
255268 timeframe : str = Field (description = "The timeframe used for the query" )
256- generated_at : datetime
269+ generated_at : Annotated [
270+ datetime , Field (json_schema_extra = {"type" : "string" , "format" : "date-time" })
271+ ]
257272 guidance : Optional [str ] = Field (
258273 default = None , description = "Assistant guidance for project selection and session management"
259274 )
0 commit comments