Skip to main content
Case workflow primitives are the shared building blocks that power the PCE agent and the application pipeline — but they’re also exported directly so you can compose them into any durable agent flow you need. Whether you’re building a claims intake agent, a COI request tracker, a renewal preparation workflow, or something entirely custom, these primitives give you grounded evidence, typed validation, structured missing-info questions, and submission artifacts without having to rebuild the scaffolding yourself.

Core Types

CaseEvidenceSource

Source text used for validation and citation. Carries a sourceId, raw text, and optional metadata like page number or document type.

CaseCitation

A citation with a sourceId, exact quote, optional page number, and optional fieldPath. Used to ground claims in case items back to real source text.

CaseValidationIssue

An info, warning, or blocking issue tied to an itemId and fieldPath. Blocking issues must be resolved before a submission packet is considered ready.

MissingInfoQuestion

A question tied to an itemId and optional fieldPath. Surfaces required information that could not be inferred from the request or evidence sources.

CasePacketArtifact

A generated artifact — email draft, underwriter summary, JSON packet, or validation report — associated with a submission packet.

CaseState

The durable workflow state object. Carries items, evidence sources, validation issues, missing-info questions, citations, and execution status.

Evidence Validation

Use validateQuotedEvidence() to check that a citation’s quote is genuinely present in the referenced source. Call this any time you accept a new citation — from a model, from a user, or from an external system.
string
required
The ID of the case item this citation belongs to.
string
Optional dot-separated field path the citation supports (e.g. vehicle.vin).
string
required
The text that should appear verbatim in the referenced source.
CaseCitation
required
The citation object to validate. Must include sourceId and quote.
CaseEvidenceSource[]
required
The evidence sources to check against. The validator looks for the sourceId in this list and confirms the quote is present in the source text.
validateQuotedEvidence() performs an exact substring match by default. Normalisation (whitespace collapsing, case folding) is applied before comparison so minor formatting differences don’t produce false negatives.

Proposal Scoring

When your workflow generates multiple competing proposals for a case item — for example, different interpretations of an ambiguous request — use evaluateCaseProposals() to select the best one before committing.
Proposals are scored on six dimensions:
evaluateCaseProposals() internally weights grounding and consistency most heavily when selecting the best proposal. Proposals with blocking citation issues (missing quote, unknown source) are excluded entirely before scoring begins.

Stable IDs

Case workflows often run as async jobs that may be retried or deduplicated. Use stableCaseId() to generate deterministic, hash-based identifiers so the same logical case always produces the same ID regardless of how many times it’s processed.
string
required
A short label prepended to the hash — e.g. "case", "item", "packet". Helps you identify the ID type at a glance.
string[]
required
Array of strings that uniquely identify the entity. The hash is computed from the concatenation of these values in order.
Input order matters — stableCaseId("case", ["a", "b"]) and stableCaseId("case", ["b", "a"]) produce different IDs. Establish a consistent ordering convention within your application.

Building a Custom Workflow

These primitives compose naturally. Here’s a sketch of a claims intake workflow built from case primitives:

PCE Overview

See how these primitives are assembled in the built-in Policy Change Endorsement agent.

Application Pipeline

Explore how case state patterns apply to the application processing pipeline.