You’ve shipped a working chat feature. Now comes the hard part: figuring out which framework actually fits your production architecture. The tooling landscape has fractured, and comparing AI agent frameworks in a vacuum won’t help you much.
Arcade.dev works across agent frameworks, providing governance and security regardless of which stack teams choose. That cross-framework perspective informs this guide: we see how teams build agents with different tools and where each framework fits best.
The right choice depends on your product’s primary job, its execution model, and how much of the agent stack you want integrated in a single system versus assembled from separate layers. This guide compares the three leading frameworks for Next.js agents (Mastra, Vercel AI SDK, and LangChain/LangGraph) in depth, with four additional actively maintained options for specialized use cases.
TL;DR #
Mastra is the most cohesive choice for Next.js agent development. It integrates agents, workflows, memory, evaluations, observability, and Mastra Studio into one TypeScript-native framework with direct Next.js support.Vercel AI SDK is the strongest fit for adding streaming chat, tool calls, and generative UI as embedded AI features inside an existing Next.js application.LangChain.js with LangGraph.js offers explicit graph control, cyclic workflows, and conceptually aligned Python/TypeScript implementations for teams invested in the LangChain ecosystem.- Choose your execution model first. Run short-lived agents in Next.js route handlers. Use a separate Node.js agent service for more structured workloads, or a durable runtime for long-running workflows, retries, and asynchronous tasks. - For multi-user AI agents that take actions in third-party systems, use a dedicated action runtime such asArcade.devalongside your framework to handle delegated authorization, credential isolation, policy governance, and auditability.
Framework vs. execution model vs. action runtime #
An agent architecture separates into three layers: the framework, the execution model, and the action runtime.
The agent framework is your reasoning and orchestration library. It manages prompts, state, tool calling, memory, workflows, and agent loops.
The execution model dictates where and for how long the agent runs. Your agent can run in-process inside a Next.js route handler, independently in a separate Node server, or across a durable runtime that survives serverless request timeouts.
The action runtime authorizes, governs, and executes actions in third-party systems on behalf of a specific user. The Model Context Protocol (MCP) standardizes how agents connect to tools and data sources, but MCP support alone does not solve delegated authorization, auditability, credential isolation, or policy enforcement.
Should your AI agent run in a Next.js route handler, agent server, or durable runtime? #
Next.js route handlers work well for short-lived, user-initiated agent interactions. Streaming chat, generative UI, and simple tool calls that complete during the request lifecycle belong in this execution layer.
When deploying Next.js AI agents on Vercel, you need to choose between Edge and Node runtimes. Vercel now recommends Node.js over Edge for improved performance and reliability, and Next.js has deprecated runtime = 'edge' on routes and pages. The setting still works for backward compatibility, but Node.js is the safer default for agent workloads given the Edge runtime’s restricted API surface. For any remaining Edge functions, the runtime must begin sending a response within 25 seconds to maintain streaming, with a maximum streaming duration of 300 seconds.
Node route handlers give you more flexibility for model SDKs, database access, session libraries, and server-side integrations. Streaming responses are essential for modern chat UX and agent progress updates.
Serverless timeouts force a hard execution boundary. Vercel’s current defaults with Fluid Compute are 300 seconds across Hobby, Pro, and Enterprise plans, though Pro and Enterprise teams can configure up to 800 seconds (or 1800 seconds in extended beta).
Long-running workflows, automated retries, scheduled jobs, human approvals, and asynchronous follow-ups need to move out of the request lifecycle and into a durable runtime. Some frameworks handle this natively. Mastra’s workflow engine supports persisted suspend-and-resume state via snapshots, and Vercel now offers both Workflows and the AI SDK’s WorkflowAgent for durable execution.
When crossing this execution boundary, user and session context must travel with the task. Your framework needs to pass the authenticated user identity directly into the runtime’s tool execution, rather than falling back to app-wide credentials, because actions should remain strictly user-scoped.
Quick comparison of TypeScript AI agent frameworks by job and execution model #
| Framework | Primary orientation | In-process Next.js route handler | Separate agent server | Durable/event-driven execution | Deployment model | Best shortlist fit |
|---|---|---|---|---|---|---|
| Mastra | ||||||
| Agent-first framework with Next.js integration | Supported via API routes with AI SDK React hooks ( | |||||
Vercel AI SDKAI SDK docs)** LangChain.js + LangGraph.js**LangChain docs)** Inngest AgentKit**Inngest docs)** VoltAgent**VoltAgent docs)** Genkit**Genkit docs)** OpenAI Agents SDK**OpenAI docs)## Evaluation criteria for TypeScript AI agent frameworks
These frameworks serve different primary jobs and execution models, so those two factors decide the shortlist. Within each group, six things separate one framework from another.
Serverless and streaming fit on Next.js route handlers:Next.js App Router support, Node runtime compatibility, streaming text responses, serverless timeout handling, and user session context propagation.Agents, workflows, and memory: Built-in primitives for executing agent loops, persisting state, orchestrating cyclic graphs, and retaining memory.Tool calling and third-party authorization: Schema validation, user context passing, third-party action patterns, anddocumented MCP interoperability.TypeScript ergonomics: Type safety, schema integration, package design, and developer experience.Evaluation and tracing: First-party support fortracing, observability, logging, evaluations, and prompt regression testing.Deployment portability: Runs across various cloud environments, separate services, or managed platforms.
The three leading frameworks for Next.js agents #
Each of these three frameworks takes a different architectural approach to the same problem. The comparison that follows will help you decide which fits your product.
Mastra: best integrated agent framework for Next.js
Best for: Teams building products where the AI agent is the core capability, requiring integrated workflows, memory, evaluation, and observability in one TypeScript framework.
Overview
Mastra is an agent-first TypeScript framework that integrates directly into Next.js while providing the full stack of capabilities that production agent products require. Rather than assembling separate tools for orchestration, memory, evaluation, and observability, Mastra combines them into one coherent system. Mastra agents run directly inside Next.js API routes using handleChatStream()
, with the @ai-sdk/react
useChat()
hook connecting the frontend.
Key features
- Next.js integration via
handleChatStream()
API routes with AI SDK React hooks for streaming frontend - Workflow engine with persisted suspend-and-resume state via
snapshotsstored in libSQL, PostgreSQL, Upstash, or OracleDB - Semantic memory with thread-aware storage for agent context retention
- First-party evaluation scorers for testing agent behavior before changes reach production Mastra Studio: built-in metrics dashboard, traces viewer, logs browser, and evaluation dataset management
Strengths
- Cohesive single-framework experience: agents, workflows, memory, evals, and observability designed and maintained as one TypeScript system
- Direct Next.js integration with AI SDK React hooks, giving teams streaming UI primitives and the full agent framework in one stack
- Built-in observability via Studio with exportable traces, configurable metrics (run counts, model costs, token usage, latency), and full-text log search
Where the fit breaks down
- Teams adding a lightweight chat feature to an existing application, rather than building an agent-first product, may find the full framework more than the use case requires
- Mastra’s Temporal integrationfor distributed fault-tolerant execution is still experimental, and the API may change between releases
Vercel AI SDK: best for streaming AI features in Next.js applications
Best for: Teams adding streaming chat, tool calls, generative UI, and structured output to existing Next.js applications where the application drives the architecture.
Overview
The Vercel AI SDK is the most direct way to add AI features to an existing Next.js application. It handles streaming chat, structured output, and generative UI inside Next.js, deeply integrated with the App Router. The SDK also includes an experimental RSC package for React Server Components integration, though Vercel recommends AI SDK UI for production. AI SDK 7 expanded agent capabilities with improved ToolLoopAgent and the new WorkflowAgent for durable execution.
Key features
streamText functionwith App Router integration and an experimental RSC package for streaming responsesToolLoopAgentwith tool approvals (HMAC signing), runtime context, and lifecycle callbacksWorkflowAgentfor durable agents supporting persisted tool steps, retries, approvals, and resumability- React hooks (
useChat
,useCompletion
) for frontend AI state management - Structured output with schema validation across model providers
Strengths
- Deep App Router integration with React hooks for web-native AI interactions, plus an experimental RSC package for Server Components
- Covers both lightweight request-scoped interactions (ToolLoopAgent) and longer-running workflows (WorkflowAgent) within the Vercel ecosystem
- Provider-agnostic model layer: supports OpenAI, Anthropic, Google, and others through a unified interface
Where the fit breaks down
- The SDK does not include built-in memory management, evaluation frameworks, or an observability dashboard; teams needing these capabilities add them separately or pair with another tool
- WorkflowAgent context values must be serializable; database clients, SDK instances, and class objects cannot be passed through the durable agent loop (
[AI SDK docs](https://ai-sdk.dev/docs/agents/workflow-agent)) - WorkflowAgent exposes only
`stream()`
and not`generate()`
, requiring a stream-to-UI transform at the response boundary for some patterns ([AI SDK docs](https://ai-sdk.dev/docs/agents/workflow-agent))
LangChain.js with LangGraph.js: best for graph-based agent workflows
Best for: Teams that need explicit graph control, cyclic workflows, conceptually aligned Python/TypeScript implementations, or are already invested in the LangSmith ecosystem for tracing and deployment.
Overview
LangChain.js and LangGraph.js provide a layered ecosystem for building agents with explicit graph control, cyclic workflows, and conceptually aligned implementations across Python and TypeScript. The system is best understood as three complementary layers: LangChain.js for higher-level abstractions and prebuilt components, LangGraph.js for low-level graph orchestration with state graphs, nodes, conditional edges, and cyclic control flow, and LangSmith for tracing, evaluation, and managed deployment infrastructure (the hosting product formerly known as LangGraph Platform, renamed as of October 2025).
Key features
LangGraph.jsstate graphs with nodes, conditional edges, and cyclic control flow for fine-grained orchestration- Built-in persistence at the library level for state checkpointing and workflow durability, separate from LangSmith Deployment’s managed hosting LangSmithfor tracing, evaluation, a development Studio, and managed deployment infrastructure- Conceptually aligned Python and TypeScript implementations with shared abstractions for teams working in both languages
- Extensive integration library with prebuilt components, model connectors, and a large community package ecosystem
Strengths
- Substantial ecosystem breadth: mature community, extensive integrations, and the flexibility to work at multiple levels of abstraction from high-level agents to low-level graph control
- Conceptually aligned Python and TypeScript implementations for teams porting existing LangChain patterns or maintaining both codebases
- Layered architecture lets teams use higher-level LangChain.js abstractions or drop into lower-level LangGraph.js graph control depending on the workload
Where the fit breaks down
- The three-layer ecosystem (LangChain.js, LangGraph.js, LangSmith) requires developers to reason about how the pieces connect and where each layer’s responsibilities begin and end
- LangGraph.js and LangChain.js are maintained as separate packages from their Python counterparts; teams working exclusively in TypeScript should verify feature parity for specific integrations they need
Mastra vs. Vercel AI SDK: which should you use for Next.js agents? #
Since Mastra and the Vercel AI SDK both provide agent abstractions and Next.js integrations, their use cases overlap. The clearest distinction is the product’s orientation.
The Vercel AI SDK is closer to an AI layer for a Next.js application. It starts from the application and adds AI capabilities: streaming chat, generative UI, tool calls, and structured output inside your existing frontend architecture. AI SDK 7’s WorkflowAgent extends this into durable execution, and the SDK’s React hooks and App Router integration make it the most ergonomic choice for web-native AI interactions.
Mastra is agent-first: an agent framework that integrates cleanly with Next.js without being built around it. It starts from the agent system: agents, workflows, memory, evaluations, observability, and Mastra Studio. It connects into Next.js via API routes and AI SDK React hooks. When the agent is the core of the product rather than an enhancement to an existing UI, Mastra’s integrated approach means fewer separate tools to connect and operate.
You do not have to pick one or the other. One practical composition pattern uses the Vercel AI SDK to handle Next.js route-handler streaming and the UI response layer, while Mastra manages backend orchestration, workflow state, memory, and evaluation logic. Both tools offer real agent abstractions. The deciding factor is whether your architecture centers on the application or the agent.
Mastra vs. LangChain/LangGraph: which should you use for Next.js agents? #
Mastra and LangChain/LangGraph both provide low-level primitives capable of building sophisticated agents. The difference is how much of the surrounding system comes integrated versus assembled.
LangChain and LangGraph give teams a path from prebuilt agents to fine-grained graph orchestration, with LangSmith covering tracing, evaluation, and deployment. That layered model provides substantial flexibility and a well-established cross-language ecosystem. Teams already using LangSmith for observability and evaluation, or those who need conceptually aligned Python and TypeScript implementations, will benefit from staying within this ecosystem.
Mastra’s advantage for Next.js teams is cohesion. Agents, typed workflows with suspend/resume, semantic memory, evaluation scorers, observability with traces and metrics, and Mastra Studio are designed and maintained as one TypeScript system. Where the LangChain ecosystem asks developers to reason about how LangChain.js, LangGraph.js, and LangSmith fit together and to connect those layers, Mastra provides the same breadth of capability in a single, integrated framework with a maintained Next.js integration.
Neither approach is wrong. Teams that value ecosystem breadth, community size, and aligned Python/TypeScript implementations will lean toward LangChain/LangGraph. Teams that value a single, cohesive TypeScript development experience, especially for Next.js, will find Mastra a more streamlined path.
Other TypeScript agent frameworks to consider #
These frameworks cover specialized use cases. Each fits its niche, but none is the primary comparison for most Next.js agent architectures.
Inngest AgentKit: durable event-driven AI agents
Best for: Teams with durable, event-driven agent workloads that need to outlive a single serverless request, especially those already using Inngest for background job orchestration.
Overview
Inngest AgentKit handles durable, event-driven agent execution where agent tasks are modeled as independently retried, event-driven steps. It fits when agent execution needs to outlive a single serverless request and the application already uses or is willing to adopt Inngest’s orchestration layer.
Key features
step.ai.inferoffloads inference to Inngest infrastructure, pausing execution to avoid idle compute costsstep.ai.wrapwraps Vercel AI SDK, OpenAI, and Anthropic calls into retryable steps with automatic caching- Automatic retry with up to four retries by default for failed steps
- Event-driven function triggering from Next.js app routes
- Both cloud-hosted and
[self-hosted](https://www.inngest.com/docs/self-hosting)deployment options
Strengths
- Purpose-built for durable execution: d inference, automatic retries, and event-driven orchestration as first-class primitives
- Infrastructure-level reliability for agent workloads that cannot tolerate single-request failure boundaries
- Composable with other frameworks (wraps Vercel AI SDK, OpenAI, and Anthropic calls) rather than replacing them
Where the fit breaks down
- Adopting AgentKit means committing to Inngest’s orchestration layer for execution, which adds an infrastructure dependency beyond the agent framework itself
- AgentKit is an execution and orchestration substrate rather than a full agent framework; it now includes Agent Evals(beta) and built-in traces and metrics for AI steps, though these are newer additions compared to more established observability platforms - Best suited for asynchronous, event-driven workloads; synchronous HTTP request/response patterns that complete within serverless timeouts do not benefit from the durable execution model
VoltAgent: observability-first agent development
Best for: Teams that prioritize granular visibility into agent behavior during development, with built-in observability across agents, tools, and multi-step workflows.
Overview
VoltAgent is an open-source TypeScript framework that provides agents, tools, memory, multi-step workflows, and observability. Its developer console gives teams granular visibility into complex agent behavior, fitting those that need to understand and debug agent execution during development.
Key features
- Built-in developer console for real-time agent execution monitoring and debugging
- Agents, tools, and memory as modular TypeScript primitives
- Multi-step workflow engine with suspend/resume and human-in-the-loop support
- MCP integration for connecting to external tools and data sources
- Resumable streaming for client reconnection to in-flight agent operations
Strengths
- Observability-first design: agent execution, tool calls, and workflow steps are visible by default rather than requiring external instrumentation
- Clean TypeScript developer experience with composable primitives for agents, tools, and memory
- Active development with growing community adoption and an open-source core
Where the fit breaks down
- VoltAgent now includes checkpoint persistencewith configurable storage backends (LibSQL, PostgreSQL, Supabase), crash recovery, and time-travel replay, though production durability depends on choosing a persistent storage adapter over the default in-memory provider - Runs best as a structured Node.js service or dedicated agent backend; for stateless chat or simple retrieval inside a route handler, a lighter pattern is a more direct fit
- Smaller ecosystem and integration surface compared to more established frameworks; teams requiring extensive prebuilt integrations should verify availability
Genkit: Google Cloud and Firebase AI flows
Best for: Teams building AI flows and agent features aligned with Google Cloud, Firebase, Vertex AI, or Gemini, with strongly typed flows and a local developer UI.
Overview
Genkit is Google’s open-source framework for building AI applications with strongly typed flows, structured output validation, tracing, and a local developer UI for interactive testing. It provides Next.js integration and deploys naturally to Cloud Run and Cloud Functions for Firebase. A beta Agents API adds sessions, interrupts, background execution, and multi-agent delegation.
Key features
- Strongly typed AI flows with schema-validated structured output Local developer UIfor interactive flow testing and debuggingNext.js integrationwith support for both App Router and Pages Router- Native plugins for Google Cloud, Firebase, and Vertex AI services
- Built-in tracing and observability for flow execution
Strengths
- Strong integration with Google Cloud, Firebase, and Vertex AI for teams already deployed on Google infrastructure
- Type-safe flows with schema validation provide safety and developer confidence for structured AI interactions
- Local developer UI enables interactive testing without deploying, reducing iteration time during development
Where the fit breaks down
- Genkit’s plugin ecosystem and deployment ergonomics are optimized for Google Cloud; teams not invested in Google infrastructure may find provider-neutral alternatives offer broader deployment flexibility
- Genkit’s beta Agents APIadds sessions, interrupts, and multi-agent delegation, but the API surface is still evolving; teams building complex multi-agent architectures should verify stability for their use case - Long-running workloads run on Cloud Run or Cloud Functions for Firebase with appropriate timeout and retry configuration; Genkit does not provide its own standalone durable execution runtime
OpenAI Agents SDK for TypeScript: OpenAI-native agents
Best for: Teams that want lightweight agent primitives with tracing and multi-agent handoffs, especially those building primarily on OpenAI models and hosted tools.
Overview
The OpenAI Agents SDK is a lightweight agent framework that defaults to OpenAI models while supporting custom model providers and an AI SDK adapter for non-OpenAI models. It provides a deliberately small set of primitives rather than a full-stack agent framework, fitting teams that want those building blocks without adopting heavier orchestration.
Key features
Agent, Runner, and tool calling interfacesas composable primitives for agent construction- Built-in tracing for agent execution visibility
- Multi-agent handoff mechanicsfor routing between specialized agents - Guardrails system for input and output validation
AI SDK adapterenabling non-OpenAI model providers Strengths
- Deliberately minimal API surface: agent, runner, tools, tracing, and handoffs without the weight of a full orchestration framework
- First-class OpenAI integration with access to hosted tools, Responses API, and realtime agent capabilities
- Multi-agent handoff mechanics provide a clean pattern for routing between specialized agents
Where the fit breaks down
- The SDK defaults to OpenAI models; using other providers requires the AI SDK adapter or a custom model provider implementation, adding configuration overhead for multi-provider setups Sessionsprovide persistent conversation memory across agent runs, but the SDK does not include a general-purpose durable workflow runtime; long-running orchestration that needs to survive infrastructure restarts requires an external system- Deliberately minimal scope means teams needing integrated evaluation systems and a dedicated observability dashboard will assemble those capabilities separately, though the SDK does include built-in
tracingfor agent execution visibility
When do TypeScript AI agents need an action runtime? #
Framework-native tool execution works well when an agent queries public data, runs in a single-tenant trusted environment, safely uses app-owned credentials, or performs low-risk internal automation.
The gap appears when an agent takes action on behalf of multiple users across systems like email, calendars, CRMs, ticketing tools, or internal business applications. Defining tool schemas and function calls is not enough. Your architecture requires a dedicated action runtime to keep credentials isolated from the LLM, enforce the intersection of user permissions and agent-scoped permissions on every action, manage credential refresh and rotation, and maintain audit logs.
Arcade.dev fills this role as the action runtime beneath whichever agent framework you select. It handles per-user authorization, centralized policy governance, a library of agent-optimized tools, and can require out-of-band human approval for sensitive operations. Arcade provides a REST API for pulling audit logs into your SIEM and supports enterprise deployment across cloud, VPC/private cloud, on-premises, and air-gapped environments.
Integrating an action runtime requires passing stable user context. Configure a stable user identifier per Arcade’s ARCADE_USER_ID guidance to scope authorization, and use the Arcade framework integration docs to choose the correct adapter, including a Mastra integration guide and a Vercel AI SDK integration guide.
Conclusion: how to choose the best TypeScript AI agent framework for your Next.js architecture #
For Next.js agent development, Mastra offers the most integrated path. Its agents, workflows with built-in persistence, semantic memory, evaluation scorers, observability, and Mastra Studio live together in one TypeScript-native framework with direct Next.js integration. When the agent is the core of the product, or a central part of the application, Mastra’s cohesive design means less time assembling separate tools and more time building. The Vercel AI SDK is the right choice when the primary job is adding AI-powered features to an existing Next.js application: streaming chat, generative UI, and web-native interactions where the application drives the architecture. AI SDK 7’s WorkflowAgent extends its reach into durable execution, making it capable of more than lightweight request-scoped work.
LangChain.js with LangGraph.js fits teams that need explicit graph control, conceptually aligned Python/TypeScript implementations, or are already invested in the LangSmith ecosystem for tracing, evaluation, and deployment.
For more specialized needs, consider Inngest AgentKit for durable event-driven execution, VoltAgent for observability-first development with built-in checkpoint persistence, Genkit for Google Cloud alignment with its beta Agents API, or the OpenAI Agents SDK for lightweight OpenAI-native agents with session-based memory. Commit to your execution constraints first. Figure out whether your workload survives within a Next.js route handler, requires a separate Node server, or needs a durable runtime. For multi-user per-action authorization and governance, use Arcade.dev as your action runtime alongside your chosen framework.
Frequently asked questions #
What is the best TypeScript AI agent framework for Next.js?
For most Next.js agent development, Mastra provides a cohesive experience by integrating agents, workflows, memory, evaluations, observability, and Studio into one TypeScript framework with direct Next.js support. The Vercel AI SDK is the strongest fit for adding streaming chat and generative UI to existing applications, while LangChain/LangGraph fits teams that need graph-based orchestration or conceptually aligned Python/TypeScript implementations.
Which AI agent framework works best inside a Next.js route handler?
The Vercel AI SDK has the deepest App Router integration for short-lived agent interactions inside Next.js route handlers, with streaming responses, tool calls, and React hooks. Mastra agents also run directly in Next.js API routes using handleChatStream()
with AI SDK React hooks, giving teams both streaming UI and full agent framework capabilities in the same request.
Should I use Mastra or the Vercel AI SDK?
The Vercel AI SDK is closer to an AI layer for a Next.js application. It starts from the application and adds AI capabilities. Mastra is an AI-first agent framework that integrates naturally with Next.js. It starts from the agent system and connects into your frontend. Some teams use both: the Vercel AI SDK for route-handler streaming and the UI layer, with Mastra managing backend orchestration, workflow state, memory, and evaluation.
Which TypeScript AI agent framework is best for long-running workflows?
Mastra’s workflow engine supports built-in persisted suspend-and-resume state via snapshots, with an experimental Temporal integration for distributed, fault-tolerant execution. The Vercel AI SDK’s WorkflowAgent (introduced in AI SDK 7) also provides durable execution with retries and resumability. Inngest AgentKit also works well for event-driven workflows modeled as independently retried steps.
Which framework should I use for RAG-heavy AI agents in TypeScript?
LlamaIndex.TS was the leading RAG-focused TypeScript framework, but the repository was archived in April 2026. Teams starting new RAG-heavy projects should evaluate alternatives: Mastra includes semantic memory and retrieval primitives, LangChain.js offers document s and retrieval chains, and the Vercel AI SDK can be paired with vector databases for retrieval patterns. For existing LlamaIndex.TS deployments, plan a migration path to an actively maintained framework.
Is LangChain.js still a good choice for TypeScript AI agents?
LangChain.js with LangGraph.js is a strong choice when you need explicit graph control, cyclic workflows, or conceptually aligned implementations with existing Python LangChain patterns. The ecosystem provides substantial flexibility through its layered model: LangChain for higher-level abstractions, LangGraph for low-level orchestration, and LangSmith for tracing, evaluation, and deployment. Teams that value a single integrated TypeScript system for Next.js may find Mastra a more streamlined alternative.
Do TypeScript AI agent frameworks handle user authorization for third-party actions?
Most frameworks handle tool calling but do not fully solve delegated user authorization, credential isolation, policy enforcement, or audit logging for multi-user deployments. For production multi-user actions, teams pair their agent framework with a dedicated action runtime such as Arcade.dev.
Can AI agents run on the Next.js Edge runtime?
Vercel now recommends Node.js over Edge for improved performance and reliability, and Next.js has deprecated runtime = 'edge'
on routes and pages. The setting still works for backward compatibility, but Node.js is the safer default for most agent workloads, offering full API coverage, better compatibility with model SDKs and database clients, and longer execution windows.