What AFORI Is

AFORI Solutions is building the agentic operating system for insurance. The platform is a B2B system where AI agents work alongside brokers, underwriters, and claims operators to digitize insurance applications, compare policies, process commission reports, extract claim forms, summarize cases, and handle the document-heavy correspondence that dominates the industry.

Forty-plus specialized agents already live inside the platform: broker copilots, policy digitizers, quote summarizers, contract QA, claim summarizers, email assistants, tariff question handlers, payment reminder checkers, and many more. Each one is scoped to a specific operator task, grounded in real customer documents, and evaluated continuously against production expectations.

The company is headquartered in Barcelona, with a European insurance customer base that demands GDPR discipline, multilingual reasoning, and tight feedback loops with design partners across the region.

My Role

I joined AFORI as Founding Backend Engineer and Senior Context Engineer. The title captures two disciplines that the role sits between:

  • Founding Backend Engineer: I own the architecture of the backend monorepo, the agent runtime, the ingestion pipeline, the ORM contracts, and the cross-repo dependency discipline that keeps four tightly coupled repositories shipping in lockstep.
  • Senior Context Engineer: I design how AI agents find, rank, filter, and consume information at inference time. Retrieval scopes, token budgets, reranking strategies, citation flows, and evaluation harnesses all fall under this work.

Context engineering is the newer of the two. It is the discipline that decides whether an agent hallucinates, whether it cites the right clause, and whether it stays within a sensible cost envelope. It sits between retrieval, prompting, and evaluation, and it is where most agentic systems succeed or fail.

What I Am Building

The Two-Stage Document Ingestion Pipeline

Insurance documents arrive from everywhere: broker uploads, email attachments, third-party syncs, partner APIs. Most of them arrive before anyone knows which case, claim, or policy they belong to. A pipeline that demands scope at arrival time stalls indefinitely. A pipeline that re-runs extraction per scope wastes compute.

I built a two-stage ingestion pipeline that separates extraction from indexing:

  • Stage one materializes a canonical extraction artifact as soon as a document lands, regardless of scope. Extraction runs exactly once per document.
  • Stage two publishes embeddings into scoped vector indexes when business context is assigned. Scope assignment becomes a metadata operation, not a reprocessing event.

The same document can project into multiple scopes without re-extracting. Documents without scope are still usable the moment a human assigns them. I wrote up the full architecture publicly: Building a Two-Stage Document Ingestion Pipeline for AI Agents at Scale.

The Agent Context Layer Architecture

A single monolithic prompt context does not work for insurance. An agent might need the active case, the customer’s underlying accounts, the policy statutory record, recent claim history, regulatory references, and operational playbook guidance. Loading all of that into every prompt blows through context windows, inflates cost, and buries the signal in noise.

I designed the Agent Context Layer Architecture: a seven-layer context retrieval system where each layer has its own entity scope, rate of change, caching policy, and token budget. A ContextAssembler service resolves which layers a given task needs, queries each layer’s document store, ranks chunks by relevance, and assembles a final payload that respects per-layer and total token budgets.

The seven layers:

  1. Transactional โ€” active case or claim, always loaded first
  2. Statutory โ€” account identity and relationship documents
  3. Insurance โ€” policies, coverage, underlying contracts
  4. Interaction History โ€” prior correspondence scoped to the entity
  5. Regulatory and Compliance โ€” jurisdictional references
  6. Operational / Playbook โ€” team and tenant procedures
  7. Third Party and Counterparty โ€” external references

Budgets are proportional. Unused allocation redistributes to higher-priority layers. Agents pay only for the context they actually use.

The Agent Evaluation Harness

Unit tests confirm a function runs. They do not confirm an agent made the right decision, cited the right document, or refused to hallucinate a policy clause. Traditional testing leaves the highest-risk surface of the platform untested.

I built an agent evaluation harness with LLM-tagged Jest suites that run smoke, unit, and end-to-end evaluations against real agent graphs. Evaluations assert on structured output shape, tool call sequences, grounding citations, and refusal behavior. Regressions surface before production, not after.

The Cross-Repo Discipline

The platform spans four repositories: apps (frontend monorepo), distribution-api (backend monorepo), agents (AI agent logic), and orm (shared TypeORM entities). They must evolve together. A schema change in orm can silently break an agent. A new agent tool can break a backend service.

I established the explicit dependency flow (apps โ†’ distribution-api โ†’ orm and distribution-api โ†’ agents โ†’ orm), local package linking for cross-repo changes in flight, release tracking via changesets, and a testing rule: whenever a contract changes, update the nearest dependent repo test as well, not just the source.

The Stack

1
2
3
4
5
6
7
Languages:         TypeScript, Node.js 22+
Backend:           Express, TypeORM, Turborepo monorepo
AI Framework:      LangGraph, LangChain
Data:              PostgreSQL, PGVector, Redis, BullMQ
Frontend (team):   React 18, Vite, Tailwind v4
Testing:           Jest (backend, agents), Vitest (frontend)
Infrastructure:    Docker, GitHub Actions, GitHub Packages

Why This Project Matters

Most AI demos collapse the moment they meet real production constraints: multi-tenancy, late-binding scope, non-uniform document domains, strict compliance requirements, and operators who will not tolerate hallucinated facts about a real customer’s policy.

AFORI is a bet that agentic AI only becomes trustworthy when the engineering underneath it is serious. Founding the backend and the context layer at this stage means the patterns I establish now will determine how every new agent, every new document type, and every new tenant plugs into the platform for years to come.

That is the work I want to be doing, and Barcelona is a good place to do it.

Writing: Two-Stage Document Ingestion Pipeline

Experience: Founding Backend Engineer at AFORI Solutions | AI Backend Lead at Anaqua | Founder at Sparrow Intelligence

Technologies: LangChain, AI Agents, RAG Systems, PGVector, TypeScript, Node.js