Skip to content

Draft State and Lifecycle

Reading map

Central object: structured draft

The parser should not just output a final transaction. It should output and maintain a draft.

Example:

{
  "draft_id": "draft_123",
  "action": "create_transaction",
  "status": "incomplete",
  "source_text": "Coffee yesterday",
  "transaction": {
    "type": "expense",
    "amount": null,
    "currency": "USD",
    "date": "2026-06-22",
    "category": {
      "id": "coffee",
      "label": "Coffee",
      "confidence": 0.86,
      "source": "inferred_from_text"
    },
    "account_id": {
      "value": "default_cash",
      "confidence": 0.62,
      "source": "default"
    },
    "merchant": null,
    "note": "coffee"
  },
  "missing_fields": ["amount"],
  "warnings": [],
  "next_step": {
    "type": "ask_user",
    "question": "How much was the coffee?"
  }
}

Then the user says:

4.50

The system updates the same draft:

{
  "draft_id": "draft_123",
  "status": "ready_for_confirmation",
  "transaction": {
    "type": "expense",
    "amount": 4.50,
    "currency": "USD",
    "date": "2026-06-22",
    "category": {
      "id": "coffee",
      "label": "Coffee",
      "confidence": 0.86
    },
    "account_id": {
      "value": "default_cash",
      "confidence": 0.62
    },
    "note": "coffee"
  },
  "missing_fields": [],
  "warnings": [],
  "next_step": {
    "type": "show_confirmation"
  }
}

This lets the system behave as a stateful assistant, not a stateless parser.

Draft lifecycle

Define explicit draft states.

empty
→ initialized
→ partially_filled
→ enriched
→ validated
→ ready_for_confirmation
→ confirmed
→ executed

Also include failure/escape states:

needs_clarification
blocked
unsupported
cancelled
expired

A practical state model:

StateMeaning
initializedUser utterance created a candidate action
partially_filledSome slots are missing
enrichingSystem is using tools/defaults/history to fill fields
needs_clarificationUser input is required
validatedBackend accepts the draft shape and values
ready_for_confirmationUser can save with one tap
confirmedUser explicitly approved
executedBackend created the transaction
blockedCannot proceed safely
unsupportedUtterance is not a create-transaction command

This is cleaner than treating every user message as a separate parse event.


Related: Draft patches and field provenance · Clarification as draft repair · Action policy, readiness, and execution gates.

Original text: 02-pipeline.md.