How MongoDB Built Sage, Its Internal Agent Platform, on Mastra

MongoDB's developer productivity team built Sage after a hackathon prototype for reading CI logs took off. It now runs Parsley AI's log analysis, JIRA and Slack triage, and release-note generation for teams across the company, all on Mastra.

Mohamed Khelif's team works on Evergreen, MongoDB's continuous integration system. On any given day, Evergreen spins up over 100k EC2 instances and runs hundreds of thousands of CI tasks for most of the company. It generates a lot of exhaust: artifacts, files, and somewhere in the range of terabytes of logs a day.

When a build fails, an engineer has to go figure out why. Traditionally that meant opening Parsley — MongoDB's log viewer, which can render gigabytes of log data in the browser — and reading. A lot of reading. Scrolling through logs, deciphering what went wrong, connecting it to other runs, figuring out whether you were looking at a real failure or a flaky test. For a lot of engineers, that work ate up a big chunk of the day.

About a year ago, MongoDB ran their annual hackathon "skunkworks" with a simple directive: build something with AI tooling. An idea came up. What if an agent could do the log reading for you?

From a Go prototype to a TypeScript framework

The first version was a hack in the most literal sense. The team — Mohamed Khelif, Lead Engineer, Sophie Stadler, Minna K-T, Jeff Zambory, Austin Hartschen, Trevor Guidry, Malik Hadjri, Srdjan Pajic, Aaron Hammer, Shreeven Kommireddy — wrote their own layer to talk to the LLMs and their own tool-calling, in Go. First commit was May 2025. They shipped it at the hackathon and it was a massive hit. "After the hackathon, everybody was like, this is awesome — this does what we need to do," Mohamed told us.

So they decided to productionize it. And productionizing meant getting off the hand-rolled Go and onto something they could maintain.

Mohamed's team is a TypeScript team, so they wanted something in TypeScript — easier for engineers to onboard. He spent time researching every framework and library in the space and wrote up a proposal. Mastra was the one they went with.

"It was the support that the team offered, the level of maturity at the time, and overall the ergonomics of the library were really nice." — Mohamed Khelif, Lead Engineer

The first Mastra commit was July 2025. They rebuilt the agent on top of Mastra's primitives — the orchestration, the agents, the tool-calling they'd previously written by hand — and shipped Parsley AI, the AI agent that lives within the Parsley log viewer. Internally, it was another massive success.

What Parsley AI actually does

Here's the thing about MongoDB's CI logs: you can't just search across them. At terabytes a day, that's near impossible to do in a price-performant way. So Parsley AI processes logs on an as-needed basis — when an engineer is actually doing an investigation.

When they do, it's not one agent. Parsley AI is a supervisor agent (internally, the "Sage thinking agent") that has a set of other agents available to it as tools. One of them, "Ask Evergreen," knows how to talk to the CI system — under the hood it's a set of wrappers around GraphQL queries, built with a custom tool factory. Another can look back at historical runs to tell you whether a failure is systemic or a one-off.

The interesting one is the log analyzer. It downloads a log file, and depending on size, chunks it up and walks through it — summarizing the first chunk, passing that summary forward as context, summarizing the next, and keeping a trailing summary as it goes until it reaches a root-cause analysis at the end. The team started with a chain-of-agents approach and now picks the technique based on file size. Individual logs run from a few kilobytes to tens of megabytes; some cost a few dollars just to process.

The questions engineers ask are exactly the ones that used to burn hours — "Why did this fail?" or "Is this a systemic failure? Go read the last ten runs and tell me." Work that took someone hours of reading files and drawing comparisons now runs in seconds.

One demo, and the platform took off

In November, MongoDB's developer productivity org — the team's org, whose whole mission is making it easier for engineers to build — held an offsite in San Diego. Mohamed wanted to get other people building agents, so he gave a presentation.

In 15 minutes, live, he explained what their platform was, explained what Mastra was, and vibe-coded an agent that took the messages within a Slack support thread and output a structured JIRA ticket — reporter, action items, all of it — as JSON. The thing engineers used to do by hand: read the thread, open JIRA, summarize, fill in the fields.

The group was blown away that it only took 15 minutes to build an agent. Someone in the audience asked to take it over and productionize it. They did, and now engineers at MongoDB have access to a tool called Memento that lets them quickly capture user issues and requests.

That was the turning point. The infrastructure underneath Parsley AI had a name — Sage, a wrapper around Mastra that handles the internal plumbing — auth, networking, and exposing agents over HTTP — so teams don't have to rebuild that themselves. After the offsite, Sage stopped being one team's tool and started being a platform other teams built on.

The agents that followed

Lumber tracks support load. MongoDB's developer productivity org fields a steady stream of support questions across the channels it covers, and the org wanted to know where that load was actually going.

Lumber reads a support question, figures out which team it should route to, explains why, and does the bookkeeping in the background. It's an agent on the Sage instance, and it became the org's source of truth for support load.

Ask Sage is the Q&A bot that lives in MongoDB's Devprod Slack support channels. It replaced a third-party RAG service the team had outgrown, moving to something they could evaluate and improve using their own eval tooling. The team rebuilt it on Sage.

It uses a retrieval tool for RAG, then an agent forms the answer, posts it to Slack, collects thumbs up/thumbs down, and reuses the same Lumber agent to tag the right team. With central triage and routing, they've consolidated a sprawl of separate Slack channels into one.

Then it spread past Mohamed's team:

  • The release team built a workflow that takes every JIRA ticket going into a MongoDB release and turns it into release notes.
  • The cloud team behind MongoDB Atlas is building a CI failure triage service: every morning, something has to sift through all the failures that emerged from overnight builds — and when hundreds of thousands of people commit to a codebase, failures emerge — figure out which team owns each one, and post a Slack summary.
  • Another team is building triage for inbound customer support tickets: has MongoDB seen this before, is it a storage-layer issue or a networking issue, which team gets it.

There's also Sagebot, which you tag on a JIRA ticket and it does the ticket — today it spins up a self-hosted Claude Code instance and opens a PR you can follow up on. The team is migrating it to run as a Mastra workflow, so the prompts become reusable and everything gets auto-instrumented through Mastra's wiring.

Building agents, 20+ engineers later

The agents are spreading. The agent work now involves a couple dozen engineers who've contributed code to the Sage codebase, plus a few bots committing code of their own.

The next step is turning Sage into a true self-service platform: letting engineers create and iterate on agents without going through a PR for every one. Mohamed's team is also thinking about scale — today each team gets its own directory and a bootstrap script wires everything into one central Mastra instance, and he'd like a cleaner way to run "micro" Mastra instances that a central one stitches together. (We've got ideas there.)

What strikes me is how Mohamed thinks about value. A lot of companies right now are trying to figure out whether AI is actually worth what it costs — coding agents in particular run up real bills, and the ROI can be fuzzy. Sage's agents are the opposite.

"It's really easy to see the value, because we're able to see the cost of each request and directly tie that to time savings." — Mohamed Khelif, Lead Engineer

A few-dollar log analysis that replaces an hour of an engineer reading log files is not a hard call.

That's the kind of thing we built Mastra for: fun enough to build a hackathon toy with, sturdy enough to take into production at MongoDB's scale. If you want to start where Mohamed started, head to your command line:

npm create mastra@latest

Happy building!

Start building today

Quickstart