💡 Inspiration

In enterprise finance and auditing, "AI hallucinations" aren't just inconvenient—they are catastrophic. If a financial LLM hallucinates an account balance or posts an unbalanced journal entry, the entire general ledger is corrupted.

We asked: How can we build an autonomous financial agent that organizations can trust with their balance sheet?

The answer was AgentLedger: a zero-trust multi-model fleet where mathematical constraints (abs(sum(debits) - sum(credits)) < 0.001), privacy redaction, and compliance gates are strictly enforced at the Model Context Protocol (MCP) tool layer.


⚙️ What It Does

  1. Intelligent Multimodal Ingest (gemini-3.5-flash): Parses invoice scans, PDFs, and raw OCR text into strict, mathematically verified financial JSON schemas.
  2. Privacy Shield (gemma-2-2b-it): Redacts bank account numbers, routing codes, employee identities, and SSNs into privacy tokens ([REDACTED_ACCOUNT], [REDACTED_SSN]) before reasoning.
  3. Autonomous ReAct Audit (gemini-3.5-pro): Implements a multi-turn Reason + Act loop that queries the chart of accounts, audits tax compliance, maps debits and credits, and detects mismatches.
  4. Zero-Trust Commitment & Rejection:
    • Balanced Entries: Atomically posted to Google Cloud SQL (PostgreSQL).
    • Unbalanced or Low-Confidence Entries (<85%): Rejected and queued for Human-in-the-Loop review.
  5. Real-time SSE Dashboard & HITL Workflow: Streams live agent thoughts, tool calls, and observations with an interactive "Approve & Post" override card.

🛠️ How We Built It

  • AI Models: gemini-3.5-pro (ReAct reasoning), gemini-3.5-flash (multimodal extraction), gemma-2-2b-it (PII redaction).
  • SDKs & Frameworks: @google/genai (Google Gen AI TypeScript SDK), @modelcontextprotocol/sdk (Model Context Protocol), Antigravity CLI.
  • Backend & Database: Node.js v20+, TypeScript, Express (Server-Sent Events), PostgreSQL with ACID transaction pooling.
  • Google Cloud Infrastructure:
    • Google Cloud Run: Containerized microservice deployment.
    • Google Cloud SQL: Managed PostgreSQL 16 instance connected via native Cloud SQL Proxy Unix sockets.
    • Google Secret Manager: Secure injection of GEMINI_API_KEY and database credentials.
    • Google Cloud Build & Artifact Registry: Automated CI/CD container build pipeline.

🧗 Challenges We Ran Into

  • Ensuring Zero Hallucinations: Prompt instructions alone are not enough for double-entry bookkeeping. We solved this by enforcing zero-trust checks at the tool execution level inside src/mcp/ledgerTools.ts, making it impossible for the agent to commit an unbalanced transaction.
  • PII Redaction without Corrupting Financial Numbers: Distinguishing between account numbers (which must be redacted) and financial totals/quantities (which must be preserved). We paired Gemma 2 2B IT with strict preservation rules.

🏅 Accomplishments That We're Proud Of

  • 100% Pass Rate on Zero-Trust Audit Suite: 9/9 automated checks verifying mathematical balance, low-confidence safety thresholds, and PII protection.
  • Multi-Model Google Fleet: Seamless pipeline orchestrating Gemma 2 2B IT $\rightarrow$ Gemini 3.5 Flash $\rightarrow$ Gemini 3.5 Pro.
  • Zero-Downtime Cloud Run Deployment: Single-command script (./deploy.sh) connecting Cloud Run to Cloud SQL with Secret Manager integration.

📚 What We Learned

Enterprise-grade agentic workflows require a defense-in-depth architecture: combining fast models for extraction, specialized edge models for privacy, reasoning models for orchestration, and hard deterministic boundaries at the tool layer.


🔮 What's Next for AgentLedger

  • ERP connectors for NetSuite, SAP, and QuickBooks via MCP sidecars.
  • Automated multi-currency foreign exchange (FX) variance revaluation.
  • Autonomous vendor discrepancy communication agent.

Built With

Share this project:

Updates

Submission history