Merge PR #394: Derive task memory feedback_score from persisted task.status
- Use canonical persisted task.status (from DB) instead of incoming request parameter - Implement explicit status-to-score mapping: completed→+1, skipped/dismissed/rejected→-1, other→0 - Normalize all negative outcomes uniformly for self-learning memory - Ensure memory feedback aligns with backend status normalization rules - Preserve contextuality_validation and quality_status response fields - Keep failures non-fatal to API behavior with exception handling - Improve code clarity with explicit conditional logic over ternary operators
This commit is contained in:
@@ -191,10 +191,18 @@ async def set_task_status(
|
||||
# Record outcome in memory for self-learning
|
||||
try:
|
||||
memory = TaskMemoryService(user_id, db)
|
||||
normalized_status = (task.status or "").lower()
|
||||
if normalized_status == "completed":
|
||||
feedback_score = 1
|
||||
elif normalized_status in {"skipped", "dismissed", "rejected"}:
|
||||
feedback_score = -1
|
||||
else:
|
||||
feedback_score = 0
|
||||
|
||||
await memory.record_task_outcome(
|
||||
task,
|
||||
feedback_score=1 if status == "completed" else -1 if status == "dismissed" else 0,
|
||||
feedback_text=completion_notes
|
||||
task,
|
||||
feedback_score=feedback_score,
|
||||
feedback_text=completion_notes,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
|
||||
Reference in New Issue
Block a user