Blog/

case studies

Medusa builds e-commerce agents with Mastra

·

May 30, 2025

MedusaJS is the most popular open-source Javascript e-commerce framework, with over 29K stars on Github, and helps companies build custom online stores. Founded in 2021 and headquartered in Copenhagen, Denmark, the 15 person team has raised $9M across two funding rounds, including an $8M seed round in 2022 led by Dawn Capital.

Choosing Mastra to iterate quickly

Co-founders Oli & Seb wanted to quickly test different agent architectures for a new "AI solutions engineer" that would allow users to ask an agent to build features into stores end-to-end. Because they were a Typescript framework, Mastra was the natural choice.

Mastra's built-in eval framework and local development environment allowed the team to prototype different agent configurations, while the workflow visualization helped them understand how different architectures performed in practice

"Mastra's TypeScript framework enabled us to quickly experiment with different architectures using the primitives and the dashboard gave us easy visibility into execution state and memory persistence. We used multiple eval frameworks to determine which configurations best handled feature generation requests."

Senior Software Engineer Riqwan Thamir demonstrates the MedusaJS AI solutions engineer agent in the Mastra Cloud

First approach: multi-agent

Using Mastra's workflow primitives, the team built their first architecture with separate agents handling different parts of the e-commerce feature pipeline

"We started out with a fleet of agents because we thought, well, for every component that we need to do, let's have an agent that does it," said Oli Juhl, co-founder and CTO. Mastra made it simple to set up different agent configurations and test coordination patterns. Medusa built separate agents for database models, API endpoints, frontend components, and business logic.

The initial results were mixed. "We were having some problems with the accuracy and the transferable knowledge between the agents and the latency between all the agents and the different tools they were using," explained Senior Software Engineer Adrien De Peretti.

The agents couldn't maintain context about how different parts of the system connected. An agent generating a database model didn't understand how frontend components would consume the data, leading to mismatched interfaces and integration problems.

The successful approach: single-agent architecture

But because Mastra has single-agent, multi–agent, and workflow primitives, when multi-agent didn't work as expected, the team could pivot quickly to test a completely different architecture with only minor code changes.

"The best results we have seen have come from using one agent…with the entire code base fed into the context," Juhl explained. "Both the storefront and the entire Medusa repo into the context using Gemini."

Putting the whole codebase in context made an immediate difference. "If we provide everything like the entire code base of both projects, we are able to build end to end features with some pretty strict guardrails included in the prompt," Juhl noted.

The single-agent approach generated code that imported existing modules correctly, followed established patterns, and integrated with database schemas. "Even the simplest prompts actually give very good results," Juhl observed. "We can write something as simple as 'build me a product review feature for my e-commerce store' and it builds it end-to-end."

"The developer experience is pretty fantastic," Juhl noted. "We were able to set up and test quickly with your framework which I really love" and quickly made the decision to release this agent as an experimental feature to certain customers.

A successful rollout

One month after shipping to customers, Medusa has seen validation of their AI solutions engineer. The team has successfully merged PRs generated by the agent, with customers actively using the feature.

The rollout has been selective, with Medusa choosing six companies to work with initially with their own engineering teams. Through "AI Tickets" in their Medusa Cloud dashboard, these customers submit prompts for features they want built, with Medusa manually running those prompts through the agent before opening PRs. "The people we've chosen are the ones that usually when they have problems or they need something, they are capable of giving enough details and digging enough for us to be able to do something about it instead of just saying it doesn't work," explains De Peretti. "Users seem pretty happy for now. There's a lot of excitement around the feature. We're moving forward with a greater rollout as we speak."

Members of the internal development team have been converted, too. "I don't use Cursor anymore," says Thamir. "I use this agent for my local development flows and it's so much better than Cursor... I build entire features just using the agent."

The team is now working through scaling challenges—primarily rate limiting from API providers and context management for long conversations that can reach 4 to 5 million tokens—while preparing to expand access to more developers and eventually non-technical users like e-commerce managers.

Stay up to date