Building agents with Mastra?

Mastra agents stuck, looping or forgetting? We ship it properly.

Mastra pitches itself as the TypeScript agent framework you can ship, and most of the time that is accurate. The rough edges show up when a long-running workflow forgets its own memory between steps, an eval scorer never reports a result back to the dashboard, or a tool loop keeps running because the model cannot decide it is done. We work through the agents, memory store, workflows and evals until the production run matches the demo.

  • Since 2015Fixing technology
  • FreeEstimates
  • US teamReal engineers

mastra-dev.log

still failing

What it is

Mastra at a glance

Mastra is an open-source TypeScript framework for building AI agents, workflows and retrieval pipelines on top of any model provider. It ships primitives for agents, tools, memory, workflows, evals, voice and a local developer playground, plus adapters for OpenAI, Anthropic, Google, Mistral, Cohere and open-weights providers through the Vercel AI SDK. The project was open-sourced in 2024 by the team behind Gatsby.

The framework is used for conversational agents, back-office automations, RAG applications and multi-step workflows in Node and edge runtimes. It integrates with pgvector, Pinecone, Chroma and LibSQL for storage, and deploys cleanly to Vercel, Cloudflare, Netlify and plain Node servers. Observability hooks into OpenTelemetry out of the box.

Type
TypeScript AI agent and workflow framework
First released
2024 initial open-source release
License
Elastic License v2, free for most use
Maintained by
Mastra core team
Typically used for
Conversational agents, RAG, multi-step workflows, evals, voice applications in Node and edge

The honest version

Mastra pros and cons

No technology is all upside. This is where Mastra earns its place and where it tends to cause trouble.

Where Mastra is strong

  • TypeScript end to endTypes flow from tool definitions through agent handlers to workflow steps, which catches whole classes of agent-framework bugs at compile time rather than at 2am in production.
  • Honest primitives, not magicAgents, tools, memory and workflows are small and legible. You can read the implementation of any of them in a short sitting, which is unusual for an agent framework.
  • Built-in evalsScorers for faithfulness, answer relevance, toxicity and custom metrics ship with the framework, and they run from the CLI or in CI so quality does not drift between releases.
  • Local dev playgroundmastra dev gives you a browser UI with traces, memory inspection and tool call views, which collapses the feedback loop when debugging agent behavior.
  • Deploys to the usual placesVercel, Cloudflare, Netlify and plain Node are all first-class targets, with edge compatibility flagged in the agent and workflow configuration.

Where Mastra bites

  • The API is still movingMinor releases bring breaking changes in agent and memory APIs often enough that locking a version is important for anything approaching production.
  • Memory stores need deliberate setupThe default in-memory store works in development and silently loses state between serverless invocations. Teams routinely ship agents that cannot remember a user across page refreshes.
  • Edge runtime gotchasSeveral features and adapters still assume Node, so deploying to Vercel Edge or Cloudflare Workers can surface runtime incompatibilities that only appear after deploy.
  • Evals can be slow and flakyScorers that call a model themselves add latency and cost, and sometimes time out on a large eval set, which hides regressions rather than surfacing them.
  • Smaller community than LangChain or LlamaIndexRecipes, Stack Overflow answers and example repos exist but are thinner, so on uncommon problems you are reading the source rather than copying a snippet.
  • Observability needs configurationTracing, metrics and the playground are great once wired up, but a default install does not export traces to your APM and the connection has to be built.

Sound familiar?

Common Mastra problems we fix

The Mastra problems that bring people to us, and what you have once each one is fixed.

memory store returned null for threadId

The agent lost the user's history

The project deployed with the default in-memory store, which does not survive across serverless cold starts. We move the memory to LibSQL or Postgres and verify state survives a deploy and a restart.

Threads persist across sessions

tool loop detected: 12 calls in one turn

The agent is stuck calling the same tool

A tool whose result looks almost right but not quite triggers another call every time. We tighten the tool's return shape, add a max_steps and give the model a clear termination condition so it stops without the loop firing.

Agents terminate cleanly

EvalScorerTimeout: faithfulness

Evals time out and hide regressions

A model-graded scorer running against 2000 rows blows past the 30 second per-row budget. We split the eval set, cache deterministic inputs, and swap to a lighter scorer for most rows with the expensive one on a sample.

Evals finish and catch regressions

LibSQLConnectionError on edge

Memory store is unreachable from edge

A LibSQL URL that works from Node fails on Vercel Edge because of outbound restrictions or SDK incompatibility. We switch to a store with native edge support, or move the agent off edge for the paths that need persistence.

Storage reachable from every runtime

VectorStoreError: dimension mismatch

Vector queries fail after a model swap

Embeddings generated with one model do not match the dimensions expected by another. We version the vector index per embedding model and backfill on switch so a query never lands on mismatched vectors.

Retrieval works after model changes

AgentAbort: max_steps reached

Agent runs end without answering

The agent hits the step cap because it is loading, thinking and loading again instead of deciding. We tune the system prompt and the tool budget so the model has a clear path to answer, and the step cap becomes a safety net rather than a wall.

Agents answer within budget

deployed to Vercel: Node APIs unsupported

Edge deploy fails on first request

Code that imported fs or a Node-only SDK breaks on edge, and the error only shows after deploy. We split the agent into edge-safe handlers and Node-only paths so each runtime gets what it can actually run.

Agent runs on the target runtime

What we do

Mastra help, from stuck agents to production playbooks

Hire us to unblock one broken agent, or hand us the whole Mastra stack.

Rescue
Loops broken, lost memory restored, and agents that never terminate brought back to a clean final answer.
Memory and storage
LibSQL, Postgres or pgvector configured with the right lifetimes, deployed against your real runtime, and tested against cold starts.
Workflow design
Multi-step pipelines modeled as workflows with retries, idempotency and clear failure modes, instead of nested agent calls that are hard to debug.
Evals in CI
A held-out eval set wired into GitHub Actions, with budget-aware scorers and alerts when a prompt or model change moves a metric.
Managed Tech
Weekly eval runs, dependency pinning as Mastra evolves, trace sampling into your observability stack, and a US engineer on retainer for the days a minor release changes an API.

How it works

From first message to fixed

  1. Look Free estimate

    Tell us what's going wrong. We look at it, then tell you plainly what's wrong and what it will cost.

  2. Fix

    We fix the cause, not the symptom. If something is down, getting it back up comes first.

  3. Harden

    Backups, monitoring, updates and access, so the same problem can't quietly come back.

  4. Hand back or stay on

    You get a plain-language write-up. Or we stay on for hosting, upkeep and new work.

Often found together

Running Mastra alongside something else?

We work on the whole stack, so the problem can be wherever it actually is.

Questions

Mastra questions

Something else? Call+1 737 727 7327

Why does my Mastra agent keep forgetting the user?

The default memory store is in-process, which means every serverless invocation starts with an empty slate. For anything beyond a demo you need a persistent store like LibSQL, Postgres or a managed vector database. We configure the store once with the right lifetimes and verify that a thread survives a cold start and a deploy before calling it done.

How do I stop an agent calling the same tool forever?

Tool loops usually mean the agent cannot tell from the tool's response that it has enough information to answer. Tighten the return schema so the useful fields are obvious, make the tool description clearer about what constitutes a complete result, and set max_steps as a safety net. A good agent should normally terminate well before the cap.

Can I deploy Mastra to Vercel Edge or Cloudflare Workers?

Yes for many workloads, but not all adapters and stores are edge-compatible. Anything that relies on Node-only APIs or a database SDK that does not run on edge will break on first request. We split handlers by runtime so edge gets the fast paths and Node runs the parts that need persistence or heavy SDKs.

Are Mastra's evals good enough to catch regressions?

The built-in scorers for faithfulness, relevance and toxicity are solid baselines and catch obvious breakage. For domain-specific quality you will still want custom scorers written against your own expected answers, and you want them running in CI on every prompt or model change so a regression is caught before it ships.

How much does Mastra help cost?

The initial estimate is free. Give us the agents, the deploy target and the current pain points, and a US engineer will come back with a scoped price and a plan before any code moves.

Free estimate

Mastra giving you trouble?

Share the agent config and what is going sideways, and a US engineer will reply with a plan and a price.

  • No charge to find out what it will take
  • If it's urgent, say so

Replies come from a person. By sending, you authorize us to email you back. No marketing.