Circle V2 API Docs
    Preparing search index...

    The deep chart-review agent for summary (deliverable) questions: a createAgent tool loop that gathers evidence and returns a deliverable (agentSummaryAnswerSchema) rather than a graded verdict. The runner verifies its citations downstream but skips the verify/abstain gate.

    Monomorphic in its output, so pass/fail and summary are two classes (a unioned responseFormat breaks createAgent's overload inference). Everything except the answer schema/name is shared behavior via ../buildSystemPrompt and ../tools.

    Hierarchy

    Index

    Constructors

    • Parameters

      • config: {
            settings: {
                citationSimilarityThreshold: number;
                confidenceThreshold: number;
                enableAgenticDocSelection: boolean;
                enableCitationGate: boolean;
                enableCitationVerification: boolean;
                enableCoverageFacts: boolean;
                enableDeadlineResolution: boolean;
                enableDocumentCatalogue: boolean;
                enableEvidenceHint: boolean;
                enableFetchDocumentOnMetadata: boolean;
                enableGroundingGate: boolean;
                enableIntentAwarePlanning: boolean;
                enableLatestPriorInstances: boolean;
                enableLiveChartUnits: boolean;
                enableLooseCitationMatch: boolean;
                enableMetadataManifestOnly: boolean;
                enableMultiWindowDates: boolean;
                enableNoChartsBailout: boolean;
                enablePassFailRecheck: boolean;
                enablePerQuestionInstructions: boolean;
                enableQueryHydration: boolean;
                enableRunConstantPrefix: boolean;
                enableSegmentInlining: boolean;
                enableSelectionRetry: boolean;
                enableSignatureFacts: boolean;
                enableSubClaimFanOut: boolean;
                enableSubClaimFetchDocuments: boolean;
                enableSubdocumentCatalogue: boolean;
                enableUnitCitationVerification: boolean;
                enableVerificationGate: boolean;
                judgeRecursionLimit: number;
                latestPriorInstanceCount: number;
                maxFanOutSubClaims: number;
                recursionLimit: number;
                rerankModel:
                    | "bge-reranker-v2-m3"
                    | "pinecone-rerank-v0"
                    | "cohere-rerank-3.5";
                searchCandidatePoolSize: number;
                selectionRecursionLimit: number;
                subClaimRecursionLimit: number;
            };
            tools: {
                enableFetchDocument: boolean;
                enableMetadataFilter: boolean;
                enableRerank: boolean;
                enableSearchChart: boolean;
                enableSearchChartText: boolean;
                enableSignatures: boolean;
                enableTimeline: boolean;
                enableTimeTools: boolean;
            };
        }
        • settings: {
              citationSimilarityThreshold: number;
              confidenceThreshold: number;
              enableAgenticDocSelection: boolean;
              enableCitationGate: boolean;
              enableCitationVerification: boolean;
              enableCoverageFacts: boolean;
              enableDeadlineResolution: boolean;
              enableDocumentCatalogue: boolean;
              enableEvidenceHint: boolean;
              enableFetchDocumentOnMetadata: boolean;
              enableGroundingGate: boolean;
              enableIntentAwarePlanning: boolean;
              enableLatestPriorInstances: boolean;
              enableLiveChartUnits: boolean;
              enableLooseCitationMatch: boolean;
              enableMetadataManifestOnly: boolean;
              enableMultiWindowDates: boolean;
              enableNoChartsBailout: boolean;
              enablePassFailRecheck: boolean;
              enablePerQuestionInstructions: boolean;
              enableQueryHydration: boolean;
              enableRunConstantPrefix: boolean;
              enableSegmentInlining: boolean;
              enableSelectionRetry: boolean;
              enableSignatureFacts: boolean;
              enableSubClaimFanOut: boolean;
              enableSubClaimFetchDocuments: boolean;
              enableSubdocumentCatalogue: boolean;
              enableUnitCitationVerification: boolean;
              enableVerificationGate: boolean;
              judgeRecursionLimit: number;
              latestPriorInstanceCount: number;
              maxFanOutSubClaims: number;
              recursionLimit: number;
              rerankModel:
                  | "bge-reranker-v2-m3"
                  | "pinecone-rerank-v0"
                  | "cohere-rerank-3.5";
              searchCandidatePoolSize: number;
              selectionRecursionLimit: number;
              subClaimRecursionLimit: number;
          }

          Loop-control and post-processing knobs.

          • citationSimilarityThreshold: number

            How a citation quote is matched against its source document during citation verification. At 1 only an exact normalized-substring match counts, identical to a plain includes() check. Below 1 (the default 0.7), a quote that fails the exact check falls back to a windowed string-similarity match and is accepted when the best-scoring document window meets this threshold — recovering faithful quotes the model lightly reworded or re-punctuated without accepting quotes whose words are simply absent.

          • confidenceThreshold: number

            Below this confidence (or with insufficient evidence) a pass/fail verdict is downgraded to needs_review.

          • enableAgenticDocSelection: boolean

            Select documents by NAVIGATING the catalogue — the agent is given what exists and expands only the buckets the question needs — instead of one structured call over a full listing.

            OFF here, awaiting the eval arm that measures it against the single-call selector. The selector now has its full context, so what remains before flipping it on is the A/B.

            Moving retrieval out of the agent loop was originally decided on cost, so the single-call selector stays reachable either way, and the comparison is the point. Reachable at RUNTIME: both jobbables forward this from LegacyChartReviewSettings, so the LaunchDarkly flag decides and turning it off does not need a deploy. Before that was wired, this default was production.

          • enableCitationGate: boolean

            The citation (abstain) gate: downgrade a pass/fail verdict to needs_review when it relied on citations that could not be matched to their source document (or ended up with none). Independent of enableCitationVerification: with verification on but this off, unverifiable citations are still dropped but the verdict keeps its status. Opt-IN: off unless a production caller turns it on (resolveAuditQuestionGateConfig reads its LaunchDarkly flag with a false fallback, so an unconfigured flag or a dead provider leaves it off).

          • enableCitationVerification: boolean

            Deterministically verify every citation quote against the authoritative document text before returning. Fabricated/unverifiable citations are always dropped when this is on. On by default; only turn off in tests that don't wire up document loading. Whether an unverifiable citation also downgrades a pass/fail verdict to needs_review is a separate lever (enableCitationGate).

          • enableCoverageFacts: boolean

            Count each same-titled group's coverage of the care period from the documents' own stated dates, so the agent reads a day list instead of folding dozens of dates itself — which it did differently on every run. Coverage only; the cadence a question requires stays in the rubric.

          • enableDeadlineResolution: boolean

            Resolve "by midnight the next business day after admission" to a facility-local deadline instant and measure each signature against THAT, instead of handing the agent elapsed hours since admission — the wrong unit for a wall-clock bound, and the one it read as a verdict. Abstains when the facility's own instructions redefine a business day. Off until the eval says otherwise.

          • enableDocumentCatalogue: boolean

            Render the selector's candidate documents as a catalogue — grouped by type, then name, indexed by ISO week, with each name's most recent document named and per-week counts (including zeros) — instead of one line per document.

            A flat listing repeats each document's type and tags on every row, so a few hundred documents is largely duplicated strings, and counting is left to the model. Off by default: it changes what every selection sees, so it wants an A/B on the same questions rather than a rollout.

          • enableEvidenceHint: boolean

            Name the evidence that would satisfy the criterion in the agent's seed turn, from decompose's suggestedSearchQueries. NOT retrieval guidance — this path has no search tool; it tells the agent what would count as sufficient. Produced before document selection, so it can name evidence the selected set lacks, which is why the rendering disclaims absence.

          • enableFetchDocumentOnMetadata: boolean

            When enableMetadataManifestOnly is on for a signature question, keep fetch_document as an escape hatch so the agent can escalate to full text. Turn off to force the signatures + time-tool path only. Default on; only consulted when the metadata-manifest path is active.

          • enableGroundingGate: boolean

            The grounding gate: downgrade a definitive verdict (pass/fail/not_applicable) to needs_review when the agent reached it without reading any source document. When off, an ungrounded verdict ships as-is. Opt-IN: off unless a production caller turns it on (resolveAuditQuestionGateConfig reads its LaunchDarkly flag with a false fallback, so an unconfigured flag or a dead provider leaves it off).

          • enableIntentAwarePlanning: boolean

            Feed the classified (abstract) date intent into question decomposition so the planner enumerates cadence steps correctly. On by default.

          • enableLatestPriorInstances: boolean

            A latest pick that is its group's newest dated instance also carries the instances just before it: the newest can be a form opened on the review day and never filled in.

          • enableLiveChartUnits: boolean

            Derive packet forms from raw_document at run time when stored units are empty. Off by default.

          • enableLooseCitationMatch: boolean

            Treat an ellipsis (…, ..., [...]) or blank line (\n\n / \r\n\r\n) in a citation quote as elided text: every fragment must be found in the source document, in document order. Recovers faithful partial quotes that can never match contiguously. On by default; an eval can disable it to run a baseline arm.

          • enableMetadataManifestOnly: boolean

            For signature/completion questions (needsSignature), send only the document listing into the agent instead of inlining full text — the agent must use get_document_signatures (and optionally fetch_document when enableFetchDocumentOnMetadata is on). Opt-in experiment; default off so prod keeps the full-inline path until an eval arm wins.

          • enableMultiWindowDates: boolean

            Resolve a date window PER sub-claim for questions carrying two or more time criteria, instead of injecting the single whole-question window (which applies one criterion authoritatively and drops the rest). Falls back to the single window when a question isn't compound. On by default; exists so an eval can run both arms.

          • enableNoChartsBailout: boolean

            Abstain up front when the patient has no charts at all, instead of paying the preprocess calls and the tool loop to discover there was nothing to grade. Off by default: it changes the returned status for chartless patients.

          • enablePassFailRecheck: boolean

            Re-run the single agent's fail, missing or needs_review verdict on gpt-4.1 with the same input; the re-check's verdict replaces it. A sub-claim fan-out verdict is not re-checked. A cheap first-pass model is only accurate with this on.

          • enablePerQuestionInstructions: boolean

            Let a question's own additional_instructions note reach the prompts. Off by default, so a note written while the feature was dark cannot start steering verdicts on its own.

          • enableQueryHydration: boolean

            Inline clinical synonyms into every search_chart query before embedding it, so a chart phrasing that differs from the question's wording ("CIWA" vs "withdrawal") matches on the first search. Trades precision for recall, so it ships off and is A/B'd.

          • enableRunConstantPrefix: boolean

            Keep the system prompt run-constant by moving the per-question content (restated question, sub-claims, hints, date windows) into the seed turn AFTER the documents. Everything the provider can cache then precedes the first per-question byte, so the documents cache too across the questions of a run that select the same set. Pass/fail only — the summary agent keeps the per-question content in its system prompt. Ships off: it reorders the prompt, and the measured win is cache-rate, not yet a demonstrated cost saving.

          • enableSegmentInlining: boolean

            Narrow to picked forms when present; default off.

          • enableSelectionRetry: boolean

            Run agentic selection once more, told to search wider, when the first pass selects nothing.

          • enableSignatureFacts: boolean

            Precompute the signatures on the selected documents — signer, capacity, and hours from admission — into the agent's opening turn, so it neither extracts them nor does the arithmetic. Elapsed hours only: the threshold lives in the question, and "upon admission" has no agreed tolerance to encode here.

          • enableSubClaimFanOut: boolean

            Replace the single tool loop with a map-reduce: one gatherer agent per decomposed sub-claim, each in its own context, then one judge agent that writes the verdict from their pooled evidence. The judge keeps the full toolset because sub-claims are often relational — "signed within 72h of admission" is a comparison BETWEEN claims that no single gatherer can see.

          • enableSubClaimFetchDocuments: boolean

            Give each gatherer the document manifest without inlined text, so it must fetch_document what it relies on. Handed the full text a gatherer skips the read, which leaves it looking ungrounded — the grounding check counts tool reads, not inlined context.

          • enableSubdocumentCatalogue: boolean

            Form-by-form listing for multi-form uploads; agentic-only; no-op without stored units.

          • enableUnitCitationVerification: boolean

            Verify quotes with a unitId against that form alone. Off by default.

          • enableVerificationGate: boolean

            The verification (abstain) gate: downgrade a pass/fail verdict to needs_review when the self-critique verify pass found the evidence insufficient, disagreed the evidence supports the status, or was below confidenceThreshold. When off, the verifier's adjusted status ships as-is (the verify pass still runs). Opt-IN: off unless a production caller turns it on (resolveAuditQuestionGateConfig reads its LaunchDarkly flag with a false fallback, so an unconfigured flag or a dead provider leaves it off).

          • judgeRecursionLimit: number

            Tool-loop bound for the judge. It starts with the gatherers' evidence in hand, so it needs far fewer turns than a cold loop; the cap is what stops it silently redoing the whole search and paying for the fan-out twice.

          • latestPriorInstanceCount: number

            How many instances before the newest that pick carries. Read only with the lever above on.

          • maxFanOutSubClaims: number

            Upper bound on sub-claims that will fan out. Above this the reduce prompt bloats and cost stops being predictable, so the runner falls back to the single-agent loop. Fan-out also needs at least 2 claims to be worth anything — below that it is pure overhead.

          • recursionLimit: number

            Bounds the tool loop so a runaway agent can't spin forever.

          • rerankModel: "bge-reranker-v2-m3" | "pinecone-rerank-v0" | "cohere-rerank-3.5"

            Reranker model used by search_chart when tools.enableRerank is on. See chartRerankModelSchema for the hosted set.

          • searchCandidatePoolSize: number

            Candidate chunk pool search_chart gathers across the vector stores before reranking down to limit. Only consulted when tools.enableRerank is on; a wider pool gives the reranker more to reorder at the cost of one rerank call.

          • selectionRecursionLimit: number

            Tool-loop bound for document SELECTION, which navigates an in-memory catalogue rather than reading charts. Sized like subClaimRecursionLimit and for the same reason: the step had its own constant, but every caller passed recursionLimit (48, the grading agent's budget), so the constant was unreachable and selection got a budget it has no use for.

          • subClaimRecursionLimit: number

            Tool-loop bound for one gatherer. Much tighter than recursionLimit because a gatherer works a single atomic claim; sizing it near recursionLimit / N keeps the worst-case turn bound comparable to the single-agent loop.

        • tools: {
              enableFetchDocument: boolean;
              enableMetadataFilter: boolean;
              enableRerank: boolean;
              enableSearchChart: boolean;
              enableSearchChartText: boolean;
              enableSignatures: boolean;
              enableTimeline: boolean;
              enableTimeTools: boolean;
          }

          Toolset selection. Flag-gated tools: fetch_document, search_chart, get_document_signatures, is_within_hours / get_difference_in_hours, build_timeline. list_documents is not built at all — see tools.ts. The metadata-filter / rerank levers below are inert while search_chart is off.

          • enableFetchDocument: boolean

            Include fetch_document. Default on. The runner may turn this off for a metadata-manifest run when settings.enableFetchDocumentOnMetadata is false.

          • enableMetadataFilter: boolean

            Experimental: when on, search_chart exposes a fileNames param and pushes it down as a real Pinecone file_name metadata filter instead of relying only on the best-effort JS post-filter. Default off.

          • enableRerank: boolean

            Experimental: when on, search_chart over-fetches a candidate pool (searchCandidatePoolSize instead of limit) and reranks it with a Pinecone reranking model before returning the top limit. Default off: the over-fetch plus the cross-encoder call is paid on every search, and the ranking win over plain semantic top-k has not been measured. Turn it on per-arm to A/B it.

          • enableSearchChart: boolean

            Include the search_chart semantic-retrieval tool — the loop's only path to text the selected rows do not render (uploaded PDFs whose text lives only in Pinecone). Ships OFF until re-chunking lands; registered so enabling it is a flag change rather than a deploy.

          • enableSearchChartText: boolean

            Literal OCR phrase lookup; default off.

          • enableSignatures: boolean

            Include the structured get_document_signatures tool.

          • enableTimeline: boolean

            Include the build_timeline tool (a chronological event index of the whole chart).

          • enableTimeTools: boolean

            Include the is_within_hours / get_difference_in_hours time tools.

      • OptionalmodelOverride: PromptModelConfig

      Returns AuditSummaryAgent

    Properties

    modelOverride?: PromptModelConfig
    outputSchema: ZodObject<
        {
            answer: ZodString;
            citations: ZodArray<
                ZodObject<
                    {
                        documentId: ZodNullable<ZodString>;
                        fileName: ZodString;
                        page: ZodNullable<ZodNumber>;
                        quote: ZodString;
                        unitId: ZodNullable<ZodString>;
                    },
                    $strip,
                >,
            >;
            confidence: ZodNumber;
            evidenceTrail: ZodArray<
                ZodObject<
                    {
                        claim: ZodString;
                        documentId: ZodNullable<ZodString>;
                        fileName: ZodNullable<ZodString>;
                        note: ZodString;
                        verdict: ZodEnum<
                            {
                                not_found: "not_found";
                                refuted: "refuted";
                                supported: "supported";
                                unclear: "unclear";
                            },
                        >;
                    },
                    $strip,
                >,
            >;
        },
        $strict,
    > = agentSummaryAnswerSchema

    Structured shape the loop must return. Typed as LangChain's interop schema so createAgent's overload infers T = TOutput directly (no cast). Subclasses still declare it with z.object(...), which is assignable to InteropZodType<TOutput>.

    recursionLimit: number = DEFAULT_RECURSION_LIMIT

    Bounds the tool loop. Override to widen/narrow.

    snapshot: {
        commitHash: string;
        description: string;
        inputVariables: string[];
        model: {
            model: string;
            reasoningEffort: string;
            serviceTier: string;
            useResponsesApi: boolean;
        };
        name: string;
        syncedFrom: string;
        tags: string[];
        template: string;
        templateFormat: string;
    } = snapshot

    Committed cold-start snapshot for the system prompt (hub name, template, model).

    Accessors

    • get agentName(): string

      Hub identifier — derived from the committed snapshot.

      Returns string

    Methods

    • The seed messages for the loop. Defaults to a single user turn.

      Parameters

      • input: AuditAgentInput

      Returns BaseMessageLike[]

    • Build the ChatOpenAI instance from the already-resolved config — resolveSystemPrompt has applied any override by this point. Tests override this to inject a fake.

      Parameters

      Returns ChatOpenAI

    • The responseFormat handed to createAgent. Defaults to the bare outputSchema so every agent that does not override it keeps LangChain's own strategy selection.

      Returns AgentResponseFormat<
          {
              answer: string;
              citations: {
                  documentId: string
                  | null;
                  fileName: string;
                  page: number | null;
                  quote: string;
                  unitId: string | null;
              }[];
              confidence: number;
              evidenceTrail: {
                  claim: string;
                  documentId: string
                  | null;
                  fileName: string | null;
                  note: string;
                  verdict: "supported" | "refuted" | "unclear" | "not_found";
              }[];
          },
      >

    • The tools the agent may call. May be empty. Optional runner ctx threads into .toTool(ctx).

      Parameters

      • input: AuditAgentInput
      • Optionalctx: RunnerContext

      Returns (ServerTool | ClientTool)[]

    • The seed user turn for the loop. Override buildMessages for full control.

      Parameters

      • input: AuditAgentInput

      Returns string

    • Parameters

      • input: AuditAgentInput
      • Optionalctx: RunnerContext

      Returns Promise<
          AgentResult<
              {
                  answer: string;
                  citations: {
                      documentId: string
                      | null;
                      fileName: string;
                      page: number | null;
                      quote: string;
                      unitId: string | null;
                  }[];
                  confidence: number;
                  evidenceTrail: {
                      claim: string;
                      documentId: string
                      | null;
                      fileName: string | null;
                      note: string;
                      verdict: "supported" | "refuted" | "unclear" | "not_found";
                  }[];
              },
          >,
      >

    • Defaults to the agent's snapshot name — each has a distinct static prefix, so same-prefix traffic routes together and realizes the automatic cache at volume. Override to spread one agent's traffic over several keys.

      Returns string

    • Optional verbatim system prompt. When it returns a non-empty string, the agent uses it as-is, bypassing the hub and variable formatting. Defaults to none.

      Parameters

      • _input: AuditAgentInput

      Returns string | undefined

    • Pure: map typed input to the system-prompt template's variables.

      Parameters

      • input: AuditAgentInput

      Returns Record<string, unknown>

    • Optional non-PII trace inputs for the child span.

      Parameters

      • input: AuditAgentInput

      Returns Record<string, unknown>