From 5780deff2f30a1e30b3f807bd2b57cd455688880 Mon Sep 17 00:00:00 2001 From: ajaysi Date: Sat, 7 Mar 2026 11:57:26 +0530 Subject: [PATCH] fix: Normalize specialized agent pillar IDs and log invalid proposals (Closes #383) --- backend/services/today_workflow_service.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/services/today_workflow_service.py b/backend/services/today_workflow_service.py index 1be7cb21..08eeee69 100644 --- a/backend/services/today_workflow_service.py +++ b/backend/services/today_workflow_service.py @@ -311,7 +311,14 @@ async def generate_agent_enhanced_plan(db: Session, user_id: str, date: str) -> raw_proposals = [] for res in results: if isinstance(res, list): - raw_proposals.extend(res) + # Normalize pillar IDs and filter invalid proposals + for proposal in res: + pillar_id = str(proposal.get("pillarId") or "").lower().strip() + if pillar_id not in PILLAR_IDS: + logger.warning(f"Skipping proposal with invalid pillarId: {pillar_id}. Proposal: {proposal}") + continue + proposal["pillarId"] = pillar_id + raw_proposals.append(proposal) elif isinstance(res, Exception): logger.warning(f"Agent proposal failed: {res}")