AI Agent for Automated Merchant Classification and Transaction Matching

ramp · Finance · 2025 · source Agentic: yes · promotional bias: med · source-backed · extracted with prompt 0.5.2 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Financial transaction enrichment

Ramp needed to fix ambiguous merchant matches at transaction scale without hours of manual support and engineering intervention.

Constraints:

Architecture

Ramp built a merchant-classification correction agent around user-supplied correction requests. A context builder combines card-acceptor fields, MCCs, receipt-derived merchant names/addresses/line items, user memos, and related merchants retrieved by embeddings plus name matching. The primary LLM maps the request to one of a small set of actions, guardrails reject hallucinated or unsafe actions and force retries, a second LLM can rewrite rejection reasoning for users, and evaluation progresses from manual review to follow-up/rejection signals, LLM judging, and shadow-mode testing.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  correction-request-ui[Correction request UI] --> context-builder[Context builder]
  context-builder --> related-merchant-retriever[Related merchant retriever]
  related-merchant-retriever --> merchant-database[Merchant database]
  context-builder --> primary-llm-decision-agent[Primary LLM decision agent]
  primary-llm-decision-agent --> guardrail-validator[Guardrail validator]
  guardrail-validator --> primary-llm-decision-agent
  primary-llm-decision-agent --> merchant-action-executor[Merchant action executor]
  merchant-action-executor --> merchant-database
  merchant-action-executor --> correction-request-ui
  primary-llm-decision-agent --> rejection-explanation-llm[Rejection explanation LLM]
  evaluation-harness[Evaluation harness] --> primary-llm-decision-agent
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Correction request UI Lets users submit the proposed merchant name, website, and category for a misclassified transaction. Context builder, Merchant action executor
Context builder Assembles card acceptor data, MCC, receipts, memos, user-supplied correction details, and related merchants for the LLM. Correction request UI, Related merchant retriever, Primary LLM decision agent
Related merchant retriever Fetches related existing merchants via transaction/merchant embeddings and requested-name matching instead of loading every merchant. Context builder, Merchant database
Merchant database Stores Ramp merchant records, mapped card acceptors, categories, websites, and logos. Related merchant retriever, Merchant action executor
Primary LLM decision agent Maps the request and context to create/update/reassign/reject decisions and produces reasoning. Context builder, Guardrail validator, Rejection explanation LLM, Merchant action executor
Guardrail validator Constrains the LLM to allowed actions and supplied targets, catches hallucinations, and triggers retry. Primary LLM decision agent
Merchant action executor Applies valid low-impact merchant updates and exposes changes to the front end. Primary LLM decision agent, Merchant database, Correction request UI
Rejection explanation LLM Rewrites rejection reasoning into clear user-facing language. Primary LLM decision agent
Evaluation harness Uses manual reviews, follow-up and rejection rates, LLM-as-judge, and shadow mode to evaluate agent success. Primary LLM decision agent

Data flow

A user reports a wrong merchant by giving a proposed merchant name, website, and category. Ramp builds LLM context from transaction card-acceptor metadata, receipt/memo evidence, and related merchants fetched by vector and name search. The LLM decides whether to create, update, reassign, or reject; guardrails ensure the selected action and target are allowed, retrying hallucinated responses. If the action changes the merchant classification, the UI updates within seconds; if rejected, another LLM rewrites the reason for user-facing explanation. Evaluation uses manual review early, weak production signals, and an LLM judge at rollout scale.

5 supporting quotes
“When the user supplies a new merchant name, website, and category to fix a merchant classification, the agent's LLM must choose how to respond.”article, stated
“To map a request to an action, we must determine whether the user's request is reasonable. The LLM uses three parts of its context to guide this decision:”article, stated
“We pull merchants that are similar to the transaction using vector embedding similarity and merchants whose names roughly match the requested merchant name.”article, stated
“If the LLM hallucinates, we inform it of its mistake and have it retry until we get a valid response.”article, stated
“When our LLM takes an action that modifies the transaction's merchant classification in some way, the user will observe a change on the front end in seconds.”article, stated

Why this architecture

Ramp needed more than name matching because payment-processor data is cryptic and user context may be the only disambiguating signal. The architecture keeps the LLM useful by giving it targeted merchant context rather than every record, then boxing actions inside guardrails because changing merchant records incorrectly can affect policy enforcement and customer workflows.

3 supporting quotes
“User context is sometimes the only way to map a transaction to a merchant unambiguously. Card acceptor data alone is insufficient and can lead to our initial merchant classification being incorrect.”article, stated
“Giving it every Ramp merchant does not scale and would overload the LLM's context window. Instead, we use a RAG approach to fetch K related merchants.”article, stated
“We allow the LLM to take only one of a select set of actions because modifying Ramp's merchant records correctly is not straightforward.”article, stated

Models used: LLM · second LLM for rejection explanation · LLM judge

Scale

Alternatives considered (roads not taken)

Manual support/finance/engineering correction for most requests

Rejected because: The workload scales with card transactions and hours-long manual handling could not keep up with growth.

“The problem of fixing merchant classifications scales proportionally with the number of Ramp card transactions. A manual approach to handling these requests simply is not sustainable as we grow.”article, stated

Use only the user-submitted merchant information

Rejected because: The LLM would not know whether an existing merchant record already exists or whether the requested category is reasonable.

“Solving this problem with just the user's information would be extremely difficult.”article, stated

Put every Ramp merchant into the prompt

Rejected because: It would not scale and would overload the LLM context window, so Ramp retrieves K related merchants instead.

“Giving it every Ramp merchant does not scale and would overload the LLM's context window. Instead, we use a RAG approach to fetch K related merchants.”article, stated

Unconstrained free-form LLM actions

Rejected because: Guardrails require the LLM to choose only supplied actions/targets and retry when hallucinating.

“We require that the LLM always chooses one of the provided actions. This is crucial to ensure the guardrails discussed above work.”article, stated

Patterns

rag-retrieval (retrieval)

The agent combines transaction metadata, receipts, memos, and related merchant signals through RAG.

“nguage model (LLM) backed by embeddings and rapid online analytical processing (OLAP) queries, multimodal retrieval augmented generation (RAG), and a set of carefully constructed guardrails.”article, stated

guardrails-io-filtering (safety)

Ramp explicitly uses constructed guardrails around the agent’s classification changes.

“ine analytical processing (OLAP) queries, multimodal retrieval augmented generation (RAG), and a set of carefully constructed guardrails.”article, stated

Tradeoffs

How to serve misclassification requests at scale.

Chose automated agentic correction over manual support escalation for most requests.

Rationale: Manual handling did not scale with transaction volume; agentic handling reduced wait time and support cost.

“A manual approach to handling these requests simply is not sustainable as we grow.”article, stated

Merchant context retrieval.

Chose RAG over K related merchants from embeddings and name matching over placing every Ramp merchant in the LLM context.

Rationale: The retrieved subset gives the LLM enough candidates without overloading the context window.

“Giving it every Ramp merchant does not scale and would overload the LLM's context window. Instead, we use a RAG approach to fetch K related merchants.”article, stated

Action safety.

Chose allowed action sets and post-processing guardrails with retries over free-form LLM mutations to merchant records.

Rationale: Constrained actions make guardrails enforceable and prevent unsafe merchant changes or hallucinated reassignment targets.

“Similarly, if the LLM chooses to reassign a transaction to another merchant, the target must be in the supplied list. Otherwise, the LLM may be moving transactions to an inappropriate merchant.”article, stated

Gotchas (what bit them)

Processor merchant fields are ambiguous and misleading.

Root cause: Card acceptor names and categories often do not map cleanly to the real merchant or user intent.

Resolution: Use user context, receipt-derived signals, embeddings, and OLAP lookup instead of relying on processor metadata alone.

“Card acceptor data alone is insufficient and can lead to our initial merchant classification being incorrect.”article, stated

Evaluation

Ramp monitored production behavior and used LLM-based evaluation for accuracy claims.

Metrics: nearly all reports handled · less than 10 seconds · 99% accuracy in summary

“We have been monitoring our agent's performance on incorrect merchant reports for several months.”article, implied

Outcomes

This source is a Ramp engineering post with strong self-reported gains.

“Instead of waiting for hours for manual human intervention, our customers are unblocked by our agent in less than 10 seconds.”article, stated