AITools

get_fill_state

Last updated on

Report a draft's progress, open targets, rules, and the next target to fill

Reports where a form or checklist draft stands: how many required targets are done, which are still open or blocked, whether the rules pass, and which target to fill next. An agent uses it to decide its next question.

The draft is not changed. Only forms and checklists are supported.

Input

Takes a source plus:

FieldTypeRequiredDescription
dataobjectNoThe draft payload, usually data from fill or update_fill. Default {}.
evaluation_contextobjectNoThe draft's evaluation_context
include_optionalbooleanNoInclude optional targets in candidates. Default false.

Output

FieldTypeDescription
artifact_kind"form" | "document" | "bundle" | "checklist"Artifact kind, when known
phasestringDraft phase, such as draft
summaryobjectrequired_total, required_done, required_remaining, completion_percent
defs_valuesobjectEvaluated defs values
rulesobjectvalid, plus errors[] and warnings[] of RuleViolation entries from the artifact's rules
open_requiredFillItemState[]Visible, required, unfilled targets
open_optionalFillItemState[]Visible, optional, unfilled targets
blockedFillItemState[]Hidden targets that can become visible once their prerequisites are filled
doneFillItemState[]Filled targets
candidatesFillTarget[]Targets that can be filled now. Forms use dependency order, with required targets before optional targets by default and declaration order breaking ties. Checklists use item declaration order.
nextFillTarget | nullThe first candidate, or null when nothing is left
evaluation_contextobjectThe draft's fixed context
errorsToolError[]Set when the draft data was rejected (validation_error), or when the form's logic could not be evaluated (logic_unresolved) and the rules were not run
errorToolErrorSet when the state could not be computed

A RuleViolation has rule_id, the key of the failed rule in the artifact's rules section, and message, the rule's message. Errors come from rules with error severity and make valid false. Warnings come from rules with warning severity and do not.

{
  "valid": false,
  "errors": [{ "rule_id": "depositWithinLimit", "message": "Pet deposit cannot exceed $500" }],
  "warnings": []
}

A FillTarget has kind (field, party, or annex for forms; item for checklists), key, required, and order. A FillItemState adds visible, status (hidden, optional, or required), filled, and blockedBy (the unfilled targets that keep it hidden). These nested entries keep their camelCase keys.

Direct usage

import { executeGetFillState } from "@paradoc/ai-tools"

const state = await executeGetFillState({
  source: "registry",
  registry_url: "https://public.paradoc.dev",
  artifact_name: "pet-addendum",
  data: draft.data,
  evaluation_context: draft.evaluation_context,
})

if (state.next) {
  // Ask the user for state.next.key
}

Example response

For a pet addendum with the tenant, pet name, and species filled. The open_required, done, and candidates lists are shortened.

{
  "artifact_kind": "form",
  "phase": "draft",
  "summary": {
    "required_total": 6,
    "required_done": 3,
    "required_remaining": 3,
    "completion_percent": 50
  },
  "defs_values": {},
  "rules": { "valid": true, "errors": [], "warnings": [] },
  "open_required": [
    { "kind": "party", "key": "landlord", "required": true, "order": 1, "visible": true, "status": "required", "filled": false, "blockedBy": [] }
  ],
  "open_optional": [],
  "blocked": [],
  "done": [
    { "kind": "party", "key": "tenant", "required": true, "order": 0, "visible": true, "status": "required", "filled": true, "blockedBy": [] }
  ],
  "candidates": [
    { "kind": "party", "key": "landlord", "required": true, "order": 1 }
  ],
  "next": { "kind": "party", "key": "landlord", "required": true, "order": 1 },
  "evaluation_context": {
    "asOf": { "date": "2026-09-22", "datetime": "2026-09-22T14:05:11.630Z" }
  }
}

On this page