Inspiration

Construction contractors lose millions not because they do bad work but because they can't see their own financials clearly until it's too late. We watched a $50M HVAC contractor close three projects at half their expected margin with no warning, no explanation, and no recovery path. Dashboards showed the data. Nobody was connecting the dots. We built MARGIN SENTINEL because the industry doesn't need more charts it needs something that thinks.

What it does

MARGIN SENTINEL is an autonomous AI agent that protects margin across a construction portfolio. Given a single prompt or nothing at all it scans every project, calculates true realized margin using actual labor burden rates, flags underbilled revenue, identifies rejected change order losses, and surfaces cross-project patterns invisible to the human eye. It streams its reasoning in real time so you can watch it work, then delivers specific dollar-quantified actions: not "there's a risk" but "Summit Data Center has $2.7M unbilled and a 417-day billing lag submit final pay app today."

How we built it

We built MARGIN SENTINEL on Next.js 14 with the Vercel AI SDK powering an autonomous multi-step agent loop running on Claude. The agent chains up to 20 tool calls scanning portfolios, drilling into labor variance, cross-referencing billing completion against SOV progress, and analyzing 1,300 unstructured field notes for hidden signals. v0 scaffolded the UI, Granola defined the agent's goals and behavior, and Resend handles email delivery. The entire 18,000-record dataset is indexed in-memory at startup for sub-second tool responses. We used Server-Sent Events to stream every agent step to the frontend in real time, so the reasoning is never a black box.

Challenges we ran into

The hardest problem wasn't the AI it was the math. Construction accounting is deceptively complex: net contract value changes with every approved CO, labor cost requires per-row burden multipliers not a fixed rate, and billing lag means something completely different depending on whether a project is 40% or 99% complete. We also discovered mid-build that the dataset had no pending change orders — all COs were either approved or rejected which broke our risk model and forced us to recalibrate the entire scoring formula around cost overrun magnitude and billing exposure instead. Getting the agent to stop after one finding and keep digging was its own battle.

Accomplishments that we're proud of

The agent discovered something we didn't plant: Summit Data Center is 99% complete with a 417-day billing lag and $2.7M sitting unbilled. That's pure cash recovery, and no human scanning a dashboard caught it. We're also proud of the real-time reasoning feed watching the agent chain 12 tool calls, quantify dollar impacts, and arrive at a specific action plan feels genuinely different from anything else in the space. And the cross-project pattern detection correctly identified that material costs are running 8–9x over budget across all five projects a systemic bidding problem, not a project execution problem.

What we learned

Agents need constraints more than they need freedom. The breakthrough moment was forcing the agent to never report a problem without a dollar amount attached, and never stop investigating after fewer than five tool calls. That one rule changed the output quality more than any prompt engineering we did. We also learned that construction data is messy in ways that matter — verbal approvals buried in field notes, rejected COs representing real unrecoverable losses, billing completion percentages that diverge from physical completion. The domain knowledge is half the product.

What's next for MARGIN SENTINEL

Live data integration with Procore, Sage, and Viewpoint so the agent runs on real project data, not CSVs. Predictive margin forecasting that projects final cost at completion based on current burn rate trajectory. Automated weekly portfolio emails to the CFO before anyone asks. And a mobile alert layer if a project crosses a risk threshold at 11pm on a Friday, the PM gets a text, not a dashboard notification they'll see Monday. The end state is a system that catches margin erosion in week two of a project, not week twenty-two.

Built With

  • anthropic
  • claude
  • granola
  • next.js
  • papaparse
  • react
  • recharts
  • resend
  • shadcn-ui
  • tailwindcss
  • typescript
  • v0
  • vercel
  • vercel-ai-sdk
Share this project:

Updates