5-agent pipeline

How Counterclaim writes a winning insurance appeal in under a minute

Counterclaim is not a single AI prompt that drafts a generic letter. It is a structured pipeline of five specialized agents, each with a distinct job: read the denial, research the law, draft the letter, attack the draft as the insurer would, and edit the final version into a print-ready PDF. The result is a formal appeal that cites real statutes, real coverage policy, and real clinical evidence - and that has already survived an adversarial pre-review before it reaches your printer.

Got a denial letter in front of you?

Skip the explainer - upload it now and see the pipeline run live.

Try it free

The 5-agent pipeline

Agent 1

Reader

Extracts the facts from your denial.

The Reader agent ingests the OCR text of your denial letter or Explanation of Benefits and pulls out the structured facts that the rest of the pipeline depends on: insurer name, plan type, member ID, claim number, denial code (CO-50, CO-11, PR-1, and so on), CPT/HCPCS codes, ICD-10 diagnosis codes, billed amount, place of service, treating physician, denial date, and the deadline by which an internal appeal must be filed.

Reader runs on the same model as the rest of the pipeline but with a tightly scoped extraction prompt and a strict JSON schema for output. It also flags inconsistencies - for example, a CPT code that doesn't pair with the diagnosis on the claim, or a denial reason that doesn't match the cited code - so the Writer downstream knows where the insurer's own paperwork is weak.

Agent 2

Researcher

Pulls the law and clinical evidence.

Running in parallel with Reader, the Researcher agent identifies the legal and clinical authority a winning appeal will need. That includes the relevant section of your state's insurance code (e.g., Texas Insurance Code § 1259, California's Knox-Keene Act, New York Insurance Law § 4904), federal law where applicable (the ACA's external review provisions, ERISA § 503, MHPAEA, the No Surprises Act), peer-reviewed clinical literature supporting medical necessity, and your insurer's own published clinical coverage policy.

Reader and Researcher are independent - Reader reads the patient's documents, Researcher reads the world - so they execute concurrently via Promise.all. Each writes its output to the database the moment it resolves, so the live pipeline visualizer ticks them off independently rather than at a single artificial moment.

Agent 3

Writer

Drafts the formal appeal letter.

Once Reader and Researcher both complete, the Writer agent receives both outputs and synthesizes them into a three-paragraph formal appeal letter formatted for USPS Certified Mail. Paragraph one establishes the patient, the claim, and the denial being contested. Paragraph two presents the medical and legal basis for the appeal, citing both clinical evidence and the specific statutes or policy provisions the insurer has misapplied. Paragraph three states the requested relief and the deadline for the insurer's response.

The Writer is constrained by a system prompt that requires every assertion to be supported by a citation supplied by the Researcher - no hallucinated case law, no invented statute numbers. If the Researcher didn't surface authority for a particular argument, the Writer omits that argument rather than fabricating one.

Agent 4

Adversary

Attacks the draft as the insurer's lawyer.

The Adversary agent is given the Writer's draft and instructed to act as the insurance company's appeals attorney. Its job is to find every weakness: vague citations, claims unsupported by the cited evidence, factual statements the insurer could rebut with their own coverage policy, missing exhibits, and procedural mistakes that would let the insurer dismiss the appeal on technical grounds.

This adversarial step is where most single-shot AI appeal letters fall down. A draft that looks confident in isolation often crumbles when read by someone whose job is to deny it. By pre-litigating those weaknesses internally, Counterclaim forces the Editor downstream to either fix them or remove them.

Agent 5

Editor

Hardens the citations and ships the final letter.

The Editor agent takes the Writer's draft plus the Adversary's critique and produces the final, print-ready letter. It tightens citations, removes any argument the Adversary identified as weak, adds the document checklist a patient will need to attach, and emits clean print-ready HTML that renders to a PDF on download with no UI chrome - just the letter, formatted for certified mail.

Editor also runs a citation verification step: every statute, regulation, or guideline cited in the final letter is checked against the Researcher's source material and flagged with a verification status. Citations the system can't verify against a real source are removed rather than passed through as plausible-looking filler.

What we cite for you

The Researcher agent's job is to make sure no claim in your appeal stands on air. Depending on your denial type and your state, the citations the Editor surfaces in the final letter come from four families of source material:

  • State insurance code

    The specific section of your state's insurance statute that governs the denied service - for example, Texas Insurance Code § 1259 on prudent layperson emergency standards, California Knox-Keene Health Care Service Plan Act on medical necessity reviews, or New York Insurance Law § 4904 on external appeals.

  • ACA external review and federal law

    The federal external review process required by the Affordable Care Act, ERISA § 503 procedural protections for employer plans, the Mental Health Parity and Addiction Equity Act for behavioral health denials, and the No Surprises Act for surprise out-of-network bills.

  • Peer-reviewed clinical literature and guidelines

    Evidence supporting medical necessity, drawn from PubMed-indexed studies and major guideline bodies - NCCN for oncology, AHA/ACC for cardiology, AAN for neurology, ASCO, ACOG, APA, and others depending on the specialty involved in your claim.

  • Your insurer's own coverage policy

    The published clinical policy bulletin or medical coverage policy your insurer maintains for the specific service. Quoting an insurer's own policy back to them - and showing your case meets it - is one of the most effective appeal moves available.

Why an adversary in the loop matters

Most AI-drafted appeal letters look strong because they were never read by anyone whose job was to dismantle them. The Adversary agent simulates the appeals attorney on the insurer's side: it looks for unsupported claims, vague citations, missing exhibits, and procedural mistakes that would let the insurer reject the appeal on technicalities. Every weakness it finds is passed to the Editor, which either repairs it or removes the argument. The result is a letter that has already lost the easy fights internally - so the insurer can't win them.

Privacy and data handling

  • Uploaded files are held in memory only for the duration of pipeline processing - they are not written to long-term object storage.
  • Sessions (extracted fields, generated letter, deadlines) are purged automatically after one hour. Download your PDF before that window expires.
  • No account, email, or sign-in is required to use Counterclaim. We don't have a user database to leak.
  • We never share your documents with the model providers for training and never sell or share session data with third parties.

Limitations and when to consult a lawyer

Counterclaim is a drafting aid, not a law firm. It is well-suited to the broad middle of denial cases - medical necessity, prior authorization, step therapy, missing information, balance billing - where the appeal turns on applying clear law to documented facts. There are categories where you should at least talk to a licensed attorney before relying on a generated letter:

  • Complex behavioral health and inpatient psychiatric denials. Mental health parity litigation moves quickly and the comparative-analysis demand has procedural requirements that benefit from counsel.
  • Self-funded ERISA plan disputes with a denial of coverage worth more than $25,000, where federal court is a realistic next step. ERISA's administrative-record rule means everything you don't put in the internal appeal can be excluded from any later lawsuit.
  • Complex oncology, transplant, and rare-disease cases involving multiple specialists, off-label regimens, or experimental designations where a single appeal will not end the dispute.
  • Coverage denials that have already been litigated. If you've been to external review and lost, the next step is a complaint, lawsuit, or regulatory filing - not another letter.

Counterclaim does not provide legal advice and using it does not create an attorney-client relationship. The output is a draft you sign and send under your own name; you remain responsible for its contents.

Frequently asked questions

Try the pipeline on your own denial.

Upload your denial letter or EOB on the home page and watch the 5-agent pipeline run in real time. Free during launch, no account required.

Try it free