structured_data_extraction, or an ERP read). Then call compare. Do not use ai_call or python_code_tool just to diff extracted fields.
decide_next_action writes prompt every run. Two valid patterns:
- Compose the prompt from prior step results already in history — both sides, tolerances, match rules — in citation form.
- Reference extraction variables in the prompt (
Invoice:\n${VAR_2}\nPO:\n${VAR_3}). The platform substitutes those tokens before the compare LLM runs.
prompt.
Convert extracted fields to citation form:
{"quantity": {"value": 2, "word_id_groups": [7]}}→Quantity: 2[cite:7]- Never write
word_id_groups=[7]in the prompt.
Authentication and enablement
No integration. Uses the agent’s LLM. Default-on. Applied learning rules for this comparison are injected by the orchestrator.Inputs
prompt(required): the comparison, including both sides, match rules, and citation markers. May embed${VAR_N}references to priorextracted_datavariables.
Output
Primary output isstructuredContent — a JSON comparison matrix, not a prose verdict.
Fields— header rows (PO number, vendor, totals) with per-document values and_row_meta.compare(status+reason).LineItem1…LineItemN— one array per logical line. Each array is row-per-document with aSourcefield (Invoice,PO,GRN). Do not treat this as column-per-document._group_meta— per-line status,mismatch_columns, and per-field verdicts underfields._doc_meta— title,documents[](name, icon, priority), andcomparison_summary.
match, mismatch, missing. Every verdict includes a short reason. When a learned rule drove a verdict, the object also has rule_id (rule-N).
Step metadata holds provider, model, token counts, and applied_memories.
The task feed renders this matrix (CompareFeedItem) with match/mismatch badges and citation highlights when word_id_groups are present.
PO / 3-way matching
- Extract the invoice with
structured_data_extraction. - Extract the PO file, or read it from the ERP (
read_sap_purchase_order, …). For 3-way, also extract/read the GRN. - Call
comparewith apromptthat includes every side in citation form (composed bydecide_next_action, or referenced via${VAR_N}). - Read the structured matrix for later review or writeback. Needing line-level JSON is not a reason to replace this tool with
ai_call.
Not a substitute for
structured_data_extraction— extract fields first; compare does not read raw files.llm_match— fuzzy match one value against a synced catalog (vendor/item), not document-vs-document.ai_call— generic enrichment (coding, mapping, summaries). Not invoice-vs-PO.
compare if learned-rule forwarding should apply.
Limits and side effects
- One LLM call per invocation. No external writes.
- Large prompts are accepted (
MaxTokensis high); billed per call plus tokens.
Expected errors
- Empty
prompt. - Provider failure.