Skip to content
Blog

Automating Tax Preparation Workflows with Specialized Multi-Agent Fleets

Multi-agent tax document ingestion (W-2, 1099, 1098), calculation agents, compliance checkers, and audit log generation using Gemini 3 & Pydantic AI.

Published on • October 24, 2026

AI Assistant

Tax preparation involves processing unstructured documents (W-2 statements, 1099-NEC, 1098-INT mortgage forms, medical receipts), extracting financial values, applying regulatory tax codes, and auditing math accuracy. Deploying a single LLM prompt to perform end-to-end tax preparation risks hallucination errors.

By contrast, a Specialized Multi-Agent Fleet decomposes tax preparation into dedicated, single-responsibility agents: Document Extractor, Calculation Engine, Compliance Auditor, and Review Coordinator.

Multi-Agent Tax Preparation Fleet Architecture

                                [Tax Preparation Request]
                                           |
                              +--------------------------+
                              | Document Ingestion Agent |
                              | (Extract W-2 / 1099 Data) |
                              +--------------------------+
                                           |
                              +--------------------------+
                              | Tax Calculation Agent    |
                              | (Formulas & Deductions)  |
                              +--------------------------+
                                           |
                              +--------------------------+
                              | Compliance Audit Agent   |
                              | (Cross-Checks IRS Rules) |
                              +--------------------------+
                                           |
                              +--------------------------+
                              | Final Review & CPA Sign  |
                              +--------------------------+

Step 1: Document Extraction Agent (W-2 & 1099 Data Extraction)

The Document Extraction Agent converts unstructured PDF text or OCR images into validated Pydantic data schemas:

from pydantic import BaseModel, Field
from pydantic_ai import Agent

class W2Form(BaseModel):
    employer_ein: str = Field(..., description="Employer Identification Number")
    wages_box1: float = Field(..., description="Box 1 Wages, tips, other compensation")
    federal_tax_box2: float = Field(..., description="Box 2 Federal income tax withheld")

w2_extractor_agent = Agent(
    'google-gla:gemini-1.5-pro',
    result_type=W2Form,
    system_prompt="Extract structured W-2 data from OCR text. Validate numeric values."
)

Step 2: Tax Calculation Agent

The Calculation Agent processes structured W-2/1099 schemas using deterministic python tax formulas, avoiding floating-point or arithmetic LLM errors:

class TaxCalculationResult(BaseModel):
    gross_income: float
    standard_deduction: float
    taxable_income: float
    estimated_tax_due: float

def compute_tax(w2_data: W2Form, filing_status: str = "single") -> TaxCalculationResult:
    gross = w2_data.wages_box1
    deduction = 14600.0 if filing_status == "single" else 29200.0
    taxable = max(0.0, gross - deduction)
    
    # Deterministic calculation logic
    estimated_tax = taxable * 0.12 if taxable < 47150 else taxable * 0.22
    
    return TaxCalculationResult(
        gross_income=gross,
        standard_deduction=deduction,
        taxable_income=taxable,
        estimated_tax_due=estimated_tax
    )

Step 3: Compliance Audit Agent (Maker-Checker)

The Compliance Auditor Agent cross-checks the calculated numbers against IRS rules, flagging discrepancies for human CPA review:

class AuditReport(BaseModel):
    is_compliant: bool
    risk_score: float
    audit_flags: list[str]

audit_agent = Agent(
    'google-gla:gemini-1.5-pro',
    result_type=AuditReport,
    system_prompt="Audit tax return data against IRS deduction guidelines. Flag unusual expense ratios."
)

Benefits of the Multi-Agent Approach

  1. Deterministic Accuracy: Mathematical calculations execute in Python code rather than LLM text outputs.
  2. Audit Trails: Every extracted document, line-item calculation, and compliance flag is saved with complete execution provenance.
  3. CPAs in the Loop: Low-confidence document extractions trigger automated human review queues.

Conclusion

Decomposing tax preparation into specialized agent teams enables secure, highly accurate financial process automation.

References & Further Reading