diff --git a/src/resources/extensions/sf/tools/workflow-tool-executors.ts b/src/resources/extensions/sf/tools/workflow-tool-executors.ts index e172b4082..f3f489561 100644 --- a/src/resources/extensions/sf/tools/workflow-tool-executors.ts +++ b/src/resources/extensions/sf/tools/workflow-tool-executors.ts @@ -313,6 +313,8 @@ export async function executeTaskComplete( // payload backwards-compatible for callers that always send it. let escalationPath: string | undefined; let escalationStatus: "pending" | "awaiting-review" | undefined; + let escalationError: string | undefined; + let escalationDisabled = false; if (params.escalation) { try { const { loadEffectiveSFPreferences } = await import( @@ -337,12 +339,19 @@ export async function executeTaskComplete( escalationStatus = params.escalation.continueWithDefault ? "awaiting-review" : "pending"; + } else { + // Feature flag is off — surface this so the agent knows the payload + // was dropped and can either turn the feature on or just make the + // decision themselves. + escalationDisabled = true; } } catch (err) { - // Escalation is additive — never block task completion if it fails. + // Escalation is additive — never block task completion if it fails, + // but DO tell the agent so they don't think the issue was recorded. + escalationError = err instanceof Error ? err.message : String(err); logError( "tool", - `sf_task_complete escalation write failed: ${err instanceof Error ? err.message : String(err)}`, + `sf_task_complete escalation write failed: ${escalationError}`, { tool: "sf_task_complete", op: "escalation" }, ); } @@ -351,7 +360,11 @@ export async function executeTaskComplete( const baseText = `Completed task ${result.taskId} (${result.sliceId}/${result.milestoneId})`; const escalationSuffix = escalationStatus ? ` — escalation ${escalationStatus} at ${escalationPath}` - : ""; + : escalationError + ? ` — WARNING: escalation payload was REJECTED (${escalationError}); the next executor will NOT see your decision. Either fix the payload and retry, or make the choice yourself and document it in the summary.` + : escalationDisabled + ? ` — note: escalation payload was DROPPED because phases.mid_execution_escalation is disabled; document the choice in the summary instead.` + : ""; return { content: [ {