Spaces:
Sleeping
Sleeping
Fix: DateResult is a Pydantic model, not a dict — use attribute access
Browse filesReplace .get() calls with direct attribute access on DateResult.
_merge_dates_into_plan handles both dict and Pydantic object defensively.
Serialize date_result to dict in return payload.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- agents/orchestrator.py +14 -6
agents/orchestrator.py
CHANGED
|
@@ -7,10 +7,18 @@ from agents import validate_agent, date_agent, plan_agent, risk_agent, refine_ag
|
|
| 7 |
|
| 8 |
def _merge_dates_into_plan(plan: ProjectPlan, date_result) -> ProjectPlan:
|
| 9 |
"""Copy date fields from DateResult into the plan. Return updated plan."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
return plan.model_copy(update={
|
| 11 |
-
"estimated_start_date":
|
| 12 |
-
"estimated_end_date":
|
| 13 |
-
"timeline_note":
|
| 14 |
})
|
| 15 |
|
| 16 |
|
|
@@ -66,8 +74,8 @@ async def generate(
|
|
| 66 |
objective=objective,
|
| 67 |
tasks=tasks,
|
| 68 |
teams=teams,
|
| 69 |
-
start_date=date_result.
|
| 70 |
-
end_date=date_result.
|
| 71 |
)
|
| 72 |
|
| 73 |
plan = await _enrich_plan(plan)
|
|
@@ -76,7 +84,7 @@ async def generate(
|
|
| 76 |
return {
|
| 77 |
"plan": plan.model_dump(),
|
| 78 |
"validation": validation,
|
| 79 |
-
"date_result": date_result,
|
| 80 |
"error": None,
|
| 81 |
}
|
| 82 |
except Exception as exc:
|
|
|
|
| 7 |
|
| 8 |
def _merge_dates_into_plan(plan: ProjectPlan, date_result) -> ProjectPlan:
|
| 9 |
"""Copy date fields from DateResult into the plan. Return updated plan."""
|
| 10 |
+
if isinstance(date_result, dict):
|
| 11 |
+
start = date_result.get("estimated_start_date")
|
| 12 |
+
end = date_result.get("estimated_end_date")
|
| 13 |
+
note = date_result.get("timeline_note")
|
| 14 |
+
else:
|
| 15 |
+
start = date_result.estimated_start_date
|
| 16 |
+
end = date_result.estimated_end_date
|
| 17 |
+
note = date_result.timeline_note
|
| 18 |
return plan.model_copy(update={
|
| 19 |
+
"estimated_start_date": start,
|
| 20 |
+
"estimated_end_date": end,
|
| 21 |
+
"timeline_note": note,
|
| 22 |
})
|
| 23 |
|
| 24 |
|
|
|
|
| 74 |
objective=objective,
|
| 75 |
tasks=tasks,
|
| 76 |
teams=teams,
|
| 77 |
+
start_date=date_result.estimated_start_date or start_date,
|
| 78 |
+
end_date=date_result.estimated_end_date or end_date,
|
| 79 |
)
|
| 80 |
|
| 81 |
plan = await _enrich_plan(plan)
|
|
|
|
| 84 |
return {
|
| 85 |
"plan": plan.model_dump(),
|
| 86 |
"validation": validation,
|
| 87 |
+
"date_result": date_result.model_dump(),
|
| 88 |
"error": None,
|
| 89 |
}
|
| 90 |
except Exception as exc:
|