@@ -470,14 +470,18 @@ async def _construct_filesystem_system_prompt(self) -> str:
470470 attachments_entries = list (await self .virtual_filesystem .list_directory (path = "/attachments" ))
471471 editable_documents_entries = list (await self .virtual_filesystem .list_directory (path = "/editable_documents" ))
472472 archives_entries = list (await self .virtual_filesystem .list_directory (path = "/archives" ))
473-
473+
474474 # Separate regular files from archives
475- regular_files = [entry for entry in (attachments_entries + editable_documents_entries ) if isinstance (entry , FileEntry )]
475+ regular_files = [
476+ entry for entry in (attachments_entries + editable_documents_entries ) if isinstance (entry , FileEntry )
477+ ]
476478 archives_files = [entry for entry in archives_entries if isinstance (entry , FileEntry )]
477479
478480 # TODO: Better ranking algorithm
479481 # order the regular files by timestamp, newest first
480- regular_files .sort (key = lambda f : f .timestamp , reverse = True )
482+ regular_files .sort (
483+ key = lambda f : f .timestamp .timestamp () if hasattr (f .timestamp , "timestamp" ) else f .timestamp , reverse = True
484+ )
481485 # take the top 25 regular files
482486 regular_files = regular_files [:25 ]
483487 # order them alphabetically by path
@@ -502,14 +506,17 @@ async def _construct_filesystem_system_prompt(self) -> str:
502506 # Add ARCHIVES_ADDON_PROMPT if there are archives
503507 if archives_files :
504508 system_prompt += "\n " + ARCHIVES_ADDON_PROMPT + "\n "
505-
509+
506510 # order the archives files by timestamp, newest first
507- archives_files .sort (key = lambda f : f .timestamp , reverse = True )
511+ archives_files .sort (
512+ key = lambda f : f .timestamp .timestamp () if hasattr (f .timestamp , "timestamp" ) else f .timestamp ,
513+ reverse = True ,
514+ )
508515 # take the top 25 archives files
509516 archives_files = archives_files [:25 ]
510517 # order them alphabetically by path
511518 archives_files .sort (key = lambda f : f .path .lower ())
512-
519+
513520 for file in archives_files :
514521 # Format permissions: -rw- for read_write, -r-- for read
515522 permissions = "-rw-" if file .permission == "read_write" else "-r--"
0 commit comments