Fix Phase 2 detection: pass original task status to create_content

The scheduler sets status to "automation underway" before the tool runs,
so create_content's API re-fetch never saw "outline approved". Now the
scheduler passes the pre-change status via clickup_task_status arg.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix/customer-field-migration
PeninsulaInd 2026-03-08 19:18:12 -05:00
parent a3eacbd0e5
commit b4f1ddfced
2 changed files with 6 additions and 1 deletions

View File

@ -451,6 +451,7 @@ class Scheduler:
try:
# args already built during validation above
args["clickup_task_id"] = task_id
args["clickup_task_status"] = task.status
# Execute the skill via the tool registry
if hasattr(self.agent, "_tools") and self.agent._tools:

View File

@ -771,8 +771,12 @@ def create_content(
task_id = ctx.get("clickup_task_id", "")
# Determine phase from ClickUp task status
# Prefer status passed by scheduler (pre-status-change) over re-fetching
phase = 1
if task_id and ctx:
original_status = ctx.get("clickup_task_status", "")
if original_status and original_status.lower() == "outline approved":
phase = 2
elif task_id and ctx:
client = _get_clickup_client(ctx)
if client:
try: