# Examples — Goal Decomposition & Planning Agent

## Clear goal → ordered plan with dependencies and gates

A well-specified goal. The agent produces an ordered plan, mapping dependencies and gating the one risky step.

**Input**

```
Goal: 'Publish the Q2 product update blog post: draft it, get review, then publish to the site and email subscribers.'
```

**Output**

```
{
  "goal": "Publish the Q2 product update blog post (draft, review, publish, email subscribers)",
  "clarity": "clear",
  "clarifying_questions": [],
  "assumptions": ["'Subscribers' = the existing marketing email list"],
  "plan": [
    { "id": 1, "task": "Draft the Q2 update post", "depends_on": [], "tool_or_owner": "draft_doc / marketing", "risk": "low", "requires_approval": false, "reversible": true },
    { "id": 2, "task": "Internal review & edits", "depends_on": [1], "tool_or_owner": "marketing_lead", "risk": "low", "requires_approval": false, "reversible": true },
    { "id": 3, "task": "Publish to the website", "depends_on": [2], "tool_or_owner": "cms", "risk": "moderate", "requires_approval": true, "reversible": true },
    { "id": 4, "task": "Email the post to subscribers", "depends_on": [3], "tool_or_owner": "email_platform", "risk": "high", "requires_approval": true, "reversible": false }
  ],
  "gated_steps": [3, 4],
  "risks": ["Emailing subscribers is irreversible — a mistake reaches everyone at once"],
  "validation": { "ok": true, "issues": [] },
  "note": "Plan only — not executed. Gated steps require human approval."
}
```

**Note:** A clean ordered plan with correct dependencies. Note the gating: publishing (moderate) and especially emailing subscribers (high, irreversible — you can't unsend) are marked requires_approval, and the one assumption (which subscriber list) is surfaced rather than buried.

## Ambiguous goal → ask, don't invent scope

A vague goal with critical details missing. The agent asks focused questions instead of fabricating a plan.

**Input**

```
Goal: 'Clean up the database.'
```

**Output**

```
{
  "goal": "Clean up the database",
  "clarity": "needs_clarification",
  "clarifying_questions": [
    "Which database/tables, and what does 'clean up' mean — remove duplicates, archive old rows, fix schema, or reclaim space?",
    "Is deleting any data acceptable, or should everything be archived/reversible?",
    "Is this production? If so, what's the maintenance window and backup status?"
  ],
  "assumptions": [],
  "plan": [],
  "gated_steps": [],
  "risks": ["'Clean up' could imply irreversible deletion on production — far too ambiguous to plan safely"],
  "validation": { "ok": false, "issues": ["Goal underspecified; planning now would invent scope and risk destructive actions"] },
  "note": "Plan only — not executed. Gated steps require human approval."
}
```

**Note:** The defining safety case: 'clean up the database' could mean anything from de-duping to dropping tables in production. Inventing a plan here would manufacture scope and risk a destructive action. The agent instead refuses to guess, asks the three questions that actually determine the plan and its danger, and validates as not-ok until clarified.

## Irreversible step in plan → gate it, never auto-run

A goal whose obvious execution includes a destructive step. The agent includes it but hard-gates it and offers a safer ordering.

**Input**

```
Goal: 'Free up storage by deleting logs older than 30 days from the production bucket.'
```

**Output**

```
{
  "goal": "Free up storage by deleting logs older than 30 days from the production bucket",
  "clarity": "clear",
  "clarifying_questions": [],
  "assumptions": ["Logs older than 30 days are not under a legal/compliance retention hold — must be confirmed"],
  "plan": [
    { "id": 1, "task": "Confirm no retention/compliance hold on logs >30d", "depends_on": [], "tool_or_owner": "compliance / data_team", "risk": "moderate", "requires_approval": true, "reversible": true },
    { "id": 2, "task": "Inventory and back up logs >30d (or verify lifecycle archive)", "depends_on": [1], "tool_or_owner": "data_team", "risk": "moderate", "requires_approval": true, "reversible": true },
    { "id": 3, "task": "Delete logs >30d from the production bucket", "depends_on": [2], "tool_or_owner": "ops", "risk": "high", "requires_approval": true, "reversible": false }
  ],
  "gated_steps": [1, 2, 3],
  "risks": ["Deletion is irreversible and on production", "Possible compliance retention requirements", "No backup = permanent loss if logs are needed later"],
  "validation": { "ok": true, "issues": ["Step 3 must not run before steps 1-2 are approved and complete"] },
  "note": "Plan only — not executed. Gated steps require human approval."
}
```

**Note:** The agent doesn't just gate the deletion — it restructures the plan to make it safe: confirm there's no compliance hold, back up first, and only then delete, with every step approval-required and the irreversible delete marked reversible=false. It surfaces the retention-hold assumption explicitly. A naive planner would emit 'delete old logs' as step one; this one builds the guardrails into the plan.
