-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
Problem
update_task_status in agent_memory_server/tasks.py contains dead code at lines 96-97:
# Ensure created_at is always set
if task.created_at is None:
task.created_at = datetime.now(UTC)This code is unreachable because Task.created_at is defined as datetime (non-optional) with default_factory=lambda: datetime.now(UTC). If a task somehow has created_at: null in Redis, Task.model_validate_json() raises a ValidationError before this backfill code can execute, making the task permanently unrecoverable.
Root Cause
The Task model field created_at: datetime does not accept None. The Pydantic validator rejects null values before the Python code has a chance to backfill.
Proposed Fix
- Remove the dead backfill code from
update_task_status - Make
created_atexplicitlyOptional[datetime]with adefault_factory, OR keep it non-optional (preferred —created_atshould always exist on valid tasks)
Since create_task always produces tasks with created_at set (via default_factory), the simplest fix is to remove the dead code.
Related
Part of #190 (Summary Views and Tasks)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels