pce.processChangeRequest(), or call individual phase helpers directly when you need more control over a custom workflow.
State Machine Phases
1
Collect Evidence
collectPceEvidenceSources() merges any explicit sources you provide with results fetched through the configured SourceRetriever. The merged list becomes state.evidenceSources and is used for grounding in every subsequent phase.2
Normalize Changes
The request text is parsed into
PolicyChangeItem[]. The SDK first attempts model-based structured extraction; if the model returns low-confidence output, a heuristic fallback parser runs to ensure at least a partial item list is available for downstream phases.Each item includes:fieldPath— dot-separated path to the target policy fieldproposedValue— the value being added or modifiedaction—add|modify|removecitations— source references that support the changeconfidence— extraction confidence score
3
Ask Missing Info
After normalization, the agent checks each
PolicyChangeItem against its field requirements. Any required field that cannot be resolved from evidence or the request text produces a PceMissingInfoQuestion. Each question is tied to an itemId and fieldPath so your UI can target the prompt precisely.Check state.missingInfoQuestions.length before advancing to avoid generating an incomplete submission packet.4
Validate Items
validatePceItems() checks normalized items against the collected evidence. It produces CaseValidationIssue[] with severity levels:blocking— must be resolved or intentionally overridden before the case is considered submission-readywarning— should be reviewed but does not block packet generationinfo— informational notes for the reviewer
5
Select Execution Mode
selectPceExecutionMode() evaluates the normalised items, evidence confidence scores, and carrier constraints to pick the appropriate automation posture. When you pass executionMode: "auto" to createPceAgent(), this phase runs automatically.6
Build Submission Packet
The agent assembles a
PceSubmissionPacket containing carrier artifacts, validation issues, missing-info questions, and a timestamp. See the Submission Packet guide for the full packet structure and quality gate API.7
Human Review
The generated packet is surfaced for review by a licensed user. The SDK does not submit to carriers — the packet is a draft until a reviewer confirms that evidence, missing-info status, and the validation report meet their standards.
Processing a Reply to Missing-Info Questions
Whenstate.missingInfoQuestions is non-empty, present the questions to the user and pass their reply back to the agent. The agent re-runs normalization and validation against the enriched information.
Execution Modes in Detail
- deterministic_tree
- market_eval
- hybrid
- auto
Use when: All change items are high-confidence, no missing info remains, and carrier validation rules are deterministic (e.g. a well-described vehicle addition with VIN, year, make, model, and effective date all present).This mode runs through a constrained rule tree without model-assisted interpretation, keeping latency and token cost low.
Standalone Helpers
You can import and call PCE phase helpers directly for custom workflows, testing, or when you need fine-grained control over individual phases.Promise<CaseEvidenceSource[]>
Merges explicit evidence sources with retriever results for a given
requestText. Returns deduplicated CaseEvidenceSource[].CaseValidationIssue[]
Validates normalized
PolicyChangeItem[] against CaseEvidenceSource[]. Returns issues grouped by itemId and fieldPath."deterministic_tree" | "market_eval" | "hybrid"
Evaluates a
PceCaseState and returns the most appropriate execution mode.string
Generates a deterministic, hash-based ID for a change item from its field path and proposed value. Safe for deduplication and retry — the same logical change always produces the same ID.