0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00
Commit graph

792 commits

Author SHA1 Message Date
dane-ai-mastra[bot]
d60ba71be0 chore: version - exit prerelease mode 2026-11-12 21:12:29 +00:00
dane-ai-mastra[bot]
5c87442ed7
chore: version packages (alpha) (#30203)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases

> The changelog information of each package has been omitted from this
message, as the content exceeds the size limit.

## @mastra/auth-auth0@1.3.0-alpha.0


## @mastra/auth-clerk@1.4.0-alpha.0


## @mastra/auth-okta@0.3.0-alpha.0


## @mastra/auth-supabase@1.2.0-alpha.0


## @mastra/client-js@1.60.0-alpha.13


## @mastra/auth@1.2.0-alpha.0


## @mastra/core@1.83.0-alpha.13


## @mastra/playground-ui@69.0.0-alpha.15


## @mastra/rag@2.8.0-alpha.3


## @mastra/server@1.83.0-alpha.13


## @mastra/server-adapters-test-suite@0.3.0-alpha.5


## @mastra/auth-better-auth@1.1.11-alpha.2


## @mastra/auth-cloud@1.2.9-alpha.0


## @mastra/auth-neon@0.3.6-alpha.1


## @mastra/auth-workos@1.6.9-alpha.0


## @mastra/discord@1.3.4-alpha.0


## @mastra/react@1.15.0-alpha.13


## @mastra/deployer-cloud@1.83.0-alpha.13


## @mastra/deployer-cloudflare@1.2.42-alpha.3


## @mastra/deployer-netlify@1.2.42-alpha.1


## @mastra/deployer-sandbox@0.3.27-alpha.1


## @mastra/deployer-vercel@1.2.42-alpha.1


## @mastra/longmemeval@1.1.42-alpha.13


## @mastra/opencode@0.1.42-alpha.13


## @mastra/factory@0.28.0-alpha.15


## create-factory@0.4.3-alpha.15


## @mastra/code-sdk@1.19.0-alpha.15


## mastracode@0.50.0-alpha.14


## @mastra/agent-builder@1.2.1-alpha.5


## mastra@1.39.0-alpha.15


## @mastra/connect@1.4.0-alpha.6


## @mastra/deployer@1.83.0-alpha.13


## @mastra/editor@0.17.1-alpha.7


## @mastra/mcp@2.9.0-alpha.5


## @mastra/mcp-docs-server@1.3.13-alpha.17


## @mastra/memory@1.41.1-alpha.5


## @mastra/schema-compat@1.4.0-alpha.2


## @mastra/elysia@0.1.23-alpha.13


## @mastra/express@1.5.27-alpha.13


## @mastra/fastify@1.5.27-alpha.13


## @mastra/hono@1.7.25-alpha.13


## @mastra/koa@1.7.27-alpha.13


## @mastra/nestjs@0.3.0-alpha.13


## @mastra/next@0.2.41-alpha.13


## @mastra/tanstack-start@0.2.41-alpha.13


## @mastra/voice-google-gemini-live@0.14.19-alpha.2


## @mastra/voice-openai-realtime@0.14.9-alpha.3


## @mastra/voice-xai-realtime@0.2.18-alpha.2


## @mastra/inngest@1.11.2-alpha.9


## @mastra/temporal@0.6.0-alpha.13


## create-mastra@1.39.0-alpha.15


## @internal/playground@1.39.0-alpha.15

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-12 12:07:03 -08:00
Daniel Lew
4ba2bdef89
feat(server): memory, observability and agent builder MCP toolsets (#29931)
## Description

Adds four toolsets to the built-in MCP server at `/api/mcp`:

- `memory`: threads, messages, memory search, and Observational Memory.
`get_observations` can wait for pending Observational Memory work, for
example right after `call_agent`.
- `observability`: trace and span queries, logs, and trace trajectories.
- `observability_analytics`: `analyze_metrics`, `analyze_scores`, and
`analyze_feedback`, plus metric name and label lookups.
- `stored_agents`: list allowed models, and create, read, and update
stored agents.

With these, an MCP client such as Claude Code can create an agent, talk
to it, read what it remembered, and explain a slow trace.

### Behavior

- **On by default, shown only when supported.** Each toolset appears
only when the app has the matching capability (a memory-enabled agent,
an observability store that supports the queries, an editor for stored
agents). Apps that don't set `server.mcp.toolsets` get these tools on
upgrade, including write tools. Set `toolsets` to keep the previous set,
or `readOnly: true` to drop writes. The changeset says this.
- **Same checks as HTTP.** Every tool dispatches through its HTTP route,
so authentication, RBAC, FGA, thread ownership, and agent visibility
apply unchanged. No MCP caller gets more access than the same caller
over HTTP.
- **Observability isn't scoped per user.** Anyone with
`observability:read` sees all traces, as over HTTP. The docs show how to
leave those toolsets out.
- **Builder model policy.** When the agent builder restricts models,
`create_stored_agent` and `update_stored_agent` check the model the
agent runs (`provider` and `name`, in every conditional variant; other
keys on `model` are rejected), models named in `defaultOptions` such as
`structuredOutput.model`, enabled fallback models (`modelList`), memory
models, input and output processor models, and the defaults they fall
back to. Anything the policy can't check is rejected. The HTTP
stored-agent routes don't apply this check. Agents created or updated
over MCP are published immediately (`update_stored_agent` defaults
`autoPublish` to `true`).
- **Results fit MCP client limits.** `get_trace` returns light span
records with every span id, and `get_span` returns one span in full.
Long lists are cut to fit, with a note on how to get the rest, and a
single oversized item has its long values shortened (ids are never cut).
- **Errors.** Bad `analyze_*` and `list_metric_names` arguments return
400. A failed observability store lookup is retried on the next request
instead of hiding the observability tools until restart.

Stacked on #29930.

## Test plan

- `@mastra/server`: unit tests for the toolsets, capability detection,
result sizing, and schemas.
- Shared adapter suite (`builtin-mcp-toolsets-test-suite`) on Hono,
Express, Fastify, Koa, Elysia, and NestJS: memory ownership compared
with HTTP on the same request, read-only mode, analytics dispatch, and
argument errors. Hono also runs observability tests against in-memory,
LibSQL, and DuckDB stores.
- `@mastra/editor` integration tests for the builder model policy across
`model` (static and conditional), `defaultOptions`, fallback models,
memory, and processors. They need no provider API keys.
- Run end to end with two users over MCP and HTTP, and with Claude Code.

---------

Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-12 10:25:19 -08:00
Daniel Lew
27705673f2
feat(server): OAuth discovery and audience checks for the built-in MCP endpoint (#29930)
## Description

Lets MCP clients such as Claude Code sign in to the built-in `/api/mcp`
endpoint with OAuth instead of a pasted token. The endpoint tells
clients where to sign in (RFC 9728 protected-resource metadata) and can
reject tokens issued for a different API (audience check).

```ts
new Mastra({
  server: {
    auth: new MastraJwtAuth({
      jwksUri: 'https://auth.example.com/.well-known/jwks.json',
      issuer: 'https://auth.example.com/',
    }),
    mcp: { oauth: { resource: 'https://my-app.example.com/api/mcp' } },
  },
});
```

### Behavior changes

**OAuth discovery for `/api/mcp`** (`@mastra/server`, every server
adapter including NestJS)
- When `server.auth` is set and the built-in MCP server is on, a `401`
from `/api/mcp` carries `WWW-Authenticate: Bearer
resource_metadata="…"`. `error="invalid_token"` is added only when a
token was sent (RFC 6750 §3).
- Metadata is served publicly at
`/.well-known/oauth-protected-resource/api/mcp` and
`/.well-known/oauth-protected-resource`, with `Cache-Control: no-store`.
- The document lists `resource`, `authorization_servers`, optional
`scopes_supported`, and `bearer_methods_supported: ['header']`. Without
`oauth.resource`, `resource` is derived from the request origin.
- The challenge, metadata routes and audience check apply only to
`/api/mcp`. Other routes are unaffected.

**Audience check** (`server.mcp.oauth.resource`)
- When set, the token audience must include this exact value, or the
request gets 401.
- An invalid value (non-URL, or a non-loopback `http://` URL) turns
discovery off and logs an error, but the audience check still runs
against it. Requests fail closed until the value is fixed.
- A provider that can't check audience (no `verifyAudience`, for example
`SimpleAuth` API keys) is accepted by default. The server logs a startup
warning on adapters built on `MastraServer`, not on NestJS.
- `requireAudience: true` (opt-in, only valid together with `resource`)
rejects those requests on `/api/mcp` with 401 `invalid_token`. Inside
`CompositeAuth`, only requests accepted by such providers are rejected.
Without `resource`, nothing changes.

**Config and provider hooks** (`@mastra/core`)
- New `server.mcp.oauth` config: `resource`, `requireAudience`,
`authorizationServers`, `scopesSupported`.
- Two new optional auth-provider methods:
  - `getOAuthMetadata()` advertises the provider's authorization server.
  - `verifyAudience()` checks the token audience.
- `CompositeAuth` combines the authorization servers of its providers.
It checks the audience with the provider that accepted the token, and
rejects when that provider can't be determined. The new
`getAuthenticatedProvider(user)` returns that provider.

**Providers**
| Provider | Advertises its authorization server | Checks audience
against `oauth.resource` |
|---|---|---|
| `MastraJwtAuth` | Yes, its `issuer` | Yes |
| Auth0 | Yes, the tenant | Yes |
| Clerk | Yes, the Frontend API | No |
| Okta | Yes, the issuer | No: Okta already enforces its own `audience`
(`OKTA_AUDIENCE`) |
| Supabase | Yes, `<url>/auth/v1` (requires Supabase's OAuth 2.1 server)
| No |

`MastraJwtAuth` gains `jwksUri` and `issuer` options
(`JWT_AUTH_JWKS_URI`, `JWT_AUTH_ISSUER`), so it can verify tokens signed
by an identity provider. JWKS keys are restricted to their key type, so
HMAC tokens forged with the public key are rejected.

**JWT subject as user id** (`@mastra/auth`, Auth0, Clerk)
- When a token has no `id` claim, the user's `id` is now set to `sub`.
Existing `id` claims are kept.
- Standard OIDC access tokens only carry `sub`. Before this change, RBAC
never loaded roles for these users, so every protected route returned
`403 Missing required permission`.
- Unless `mapUserToResourceId` is set, this also scopes data for these
users:
- **Owned records** (stored agents, skills, workspaces and other owned
records): each user sees their own records plus public ones. Admin
permissions keep the full list.
- **Tool-provider connections:** per-author connections move from the
shared `default` owner to the user's `sub`. Existing connections need
reconnecting, or set `mapUserToResourceId: () => 'default'` to keep the
old shared behavior.
  - **Feedback:** recorded with `sub` as the user id.
- The changeset describes all of these effects.

**Test suite** (`@mastra/server-adapters-test-suite`)
- New `createBuiltinMCPOAuthTestSuite`.
- The package now has `@mastra/auth` and `jose` as peer dependencies.

Stacked on #29929.

## Test plan

- `packages/server`: `src/server/mcp/oauth.test.ts` and
`oauth-without-mcp.test.ts`. They cover metadata, the challenge format,
resource validation, failing closed on an invalid `resource`, and
discovery working without `@mastra/mcp` installed.
- `packages/auth` `jwt.test.ts`:
  - JWKS and issuer validation
  - string and array `aud`
- an algorithm-confusion token that is HS256-signed with the real RSA
public key PEM and must be rejected
  - `sub` used as `id`
- `packages/core` `composite-auth.test.ts`: per-provider audience
delegation, rejection when the authenticating provider is unknown, and
`getAuthenticatedProvider`.
- `auth/auth0`, `auth/clerk`, `auth/okta`, `auth/supabase` unit tests.
- `createBuiltinMCPOAuthTestSuite` on Hono, Express, Fastify, Koa and
Elysia, plus the NestJS equivalent. It checks:
  - the challenge, and fetching the advertised metadata URL
  - audience accept and reject, including for an invalid `resource`
  - `requireAudience`:
    - `SimpleAuth` + `resource`: 200 by default, 401 in strict mode
    - a JWT with a matching audience: 200 in strict mode
    - a mixed `CompositeAuth`: only the API key is rejected
  - RBAC with a token that carries only `sub`
- that a `sub`-only user can't list another user's private stored agent
- `tsc --noEmit` and `oxlint` on the touched packages, plus docs `pnpm
check` and Vale.
- Manual run end to end with Claude Code against a local identity
provider: discovery, client registration, PKCE login, and two users with
different roles.

---------

Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-12 10:10:31 -08:00
Daniel Lew
392c7b69d5
feat(server): built-in MCP endpoint for agents, workflows and tools (#29929)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-12 12:56:28 -05:00
Daniel Lew
d05afc4a90
refactor(server): shared route authorization and in-process dispatchRoute across adapters (#29928)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-12 12:30:28 -05:00
arctic-char
c0d3bfdc43
feat: pass the authenticated user to DynamicArgument callbacks (#28612)
Dynamic agent config callbacks now get the authenticated end user as an
optional `user` argument, so you can personalize an agent without
digging auth keys out of `requestContext` yourself. It works in any
`DynamicArgument` callback: instructions, model, tools, memory,
workspace, processors, scorers, and so on.

```ts
import { Agent } from '@mastra/core/agent';

const supportAgent = new Agent({
  id: 'support-agent',
  instructions: ({ user }) =>
    user ? `You are helping ${user.name ?? user.id}.` : 'You are a helpful assistant.',
  model: ({ user }) => (user?.role === 'admin' ? 'openai/gpt-5' : 'openai/gpt-5-mini'),
  tools: ({ user }) => (user ? { accountTool, ...(user.role === 'admin' ? { adminTool } : {}) } : {}),
  memory: ({ user }) => (user ? userMemory : undefined),
});
```

`user` always has the same `MastraUser` shape, no matter which auth
provider you use, and it's `undefined` for unauthenticated requests:

```ts
import type { MastraUser } from '@mastra/core/types';

// { id: string; name?: string; email?: string; avatarUrl?: string; role?: string }
```

The server auth middleware builds it through a new overridable
`toMastraUser()` on `MastraAuthProvider`. The default handles common
shapes (`id`/`sub`/`userId`, `name`, `email`, `avatarUrl`/`picture`,
`role`), and JWT, Cloud, Supabase, Neon and Better Auth ship overrides
for their user objects. Custom providers can map their own shape:

```ts
import { MastraAuthProvider } from '@mastra/core/server';
import type { MastraUser } from '@mastra/core/types';

class MyAuth extends MastraAuthProvider<MyUser> {
  async authenticateToken(token: string) { /* ... */ }
  async authorizeUser(user: MyUser) { return true; }

  toMastraUser(user: MyUser): MastraUser {
    return { id: user.accountId, name: user.profile.displayName, role: user.permissions.primaryRole };
  }
}
```

Inline auth configs can pass `toMastraUser` too. If the provider user
has no role and an RBAC provider is configured, the primary RBAC role
fills it in, so `user.role` also works with WorkOS, Okta, Google and
Neon. The raw provider user is still available when you need
provider-specific fields, and the new context key is reserved, so
clients can't spoof it through the request body:

```ts
instructions: ({ requestContext }) => {
  const rawUser = requestContext.get('mastra__user'); // provider-specific object, unchanged
  // ...
},
```

Dynamic `vectorStore` resolvers on RAG tools get `user` as well:

```ts
createVectorQueryTool({
  indexName: 'docs',
  model: embedder,
  vectorStore: ({ user }) => (user ? tenantStores.get(user.id)! : sharedStore),
});
```

Inside core, every place that invoked a `DynamicArgument` callback
inline now goes through a single `resolveDynamicArgument` helper, which
reads the user from `requestContext` at call time. This is non-breaking:
callbacks get an extra optional field, providers get a method with a
working default. Requests served through an `MCPServer` don't get `user`
yet, since MCP builds its own request context; that's documented.

Tested with unit tests for the helper, normalization and each provider
override, middleware tests (inline config, provider role, RBAC role,
CompositeAuth ordering, unauthenticated), regression tests for the
migrated call sites, and an end-to-end test where an agent behind a fake
auth provider gets personalized instructions. Core, server, rag and the
touched auth packages typecheck clean, and their suites pass.



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5
When a signed-in user makes a request, configuration callbacks can now
use a standard set of details about that user. When a workflow resumes,
it uses the new request’s user details instead of restoring them from
the earlier run.

## Summary
- Added optional `user` data to `DynamicArgument` callbacks and RAG
vector-store resolvers. Callbacks can also use `getRequestUser()` to
read the normalized user from request context.
- Added the `MastraUser` type and `toMastraUser()` normalization hooks
for auth providers and inline auth configs. The server stores the
normalized user in a reserved request-context key and uses the primary
RBAC role when the user has no role.
- Updated core dynamic configuration paths to use the shared resolver.
Added user support to agent scopes and migrated A2A memory resolution.
- Added `withoutLiveRequestKeys()` to remove live authentication and
authorization data from saved context during workflow resume, restart,
and time travel. Saved non-authentication context, such as tenant data,
remains available.
- Added documentation and changesets. Raised relevant `@mastra/core`
peer dependency minimums to 1.81.0. MCPServer requests do not receive
the normalized `user`.

## Validation
The author reports passing typechecks and test suites across core,
server, RAG, and several auth packages. The author also reports three
failing Inngest tests and earlier failures in evented workflow and
scheduler tests, which reportedly fail the same way on comparison
sources. These results are author-reported and have not been
independently verified.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-12 10:55:12 -05:00
dane-ai-mastra[bot]
05a6931471
chore: version packages (alpha) (#30172)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @mastra/client-js@1.60.0-alpha.12

### Minor Changes

- Allow `querySpans()` to sort by `model` or `provider`.
([#30096](https://github.com/mastra-ai/mastra/pull/30096))

  ```ts
  orderBy: [{ field: 'model', direction: 'asc' }];
  ```

### Patch Changes

- The generated route types for scores now include the `SCORER` and
`PROCESSOR` entity types, matching the entity types experiments can
emit. ([#30145](https://github.com/mastra-ai/mastra/pull/30145))

- Add span-local error counts.
([#30088](https://github.com/mastra-ai/mastra/pull/30088))

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
## @mastra/factory@0.28.0-alpha.14

### Minor Changes

- A card's sandbox now stops as soon as the card is done with that
context, instead of idling until the provider times it out.
([#29981](https://github.com/mastra-ai/mastra/pull/29981))

- When a card moves out of the last phase of a context into a phase that
runs in another one, Factory stops that context's sandbox. Triage →
Planning stops the triage sandbox; Planning → Building keeps the shared
`work` sandbox running. A run still in flight on the session keeps its
sandbox until it ends.
- When a card finishes, Factory stops every sandbox it holds, from any
Factory process, by identity through the configured sandbox provider.
Before, only the process that had opened a sandbox stopped it.
- A card that comes back to a context resumes the same sandbox with its
files.

Stopping never fails the move. Sandboxes are stopped, not destroyed;
deleting a session still destroys its sandbox.

- Added two read routes that answer what the new session page shows
without sending a project's cards.
([#30097](https://github.com/mastra-ai/mastra/pull/30097))

`GET /web/factory/projects/:id/work-items/starters` counts the cards
behind each starter on the project's default board, such as the cards
whose run failed, the pull requests awaiting review and the cards not
yet triaged.

`GET /web/factory/projects/:id/work-items/activity?since=<instant>`
returns how many cards the project has, and when cards were created and
completed since that instant. `since` is required and must be an ISO
date-time such as `2026-06-01T00:00:00.000Z`. The answer carries an
`ETag`, so asking again for the same `since` with `If-None-Match`
returns a 304 with no body when nothing changed.

### Patch Changes

- Fixed environment templates that could stop rebuilding for good. When
a build start was never recorded and the sandbox provider can't list its
builds (Mastra Platform), every later Build now, schedule and push run
used to skip with `unresolved` forever. Factory now treats that start as
failed 30 minutes after its lease lapsed and the next trigger builds.
([#30148](https://github.com/mastra-ai/mastra/pull/30148))

Saving a change to a template input (setup commands, the working
directory, settings, environment repositories, source-control
connections or Build variables) now rebuilds the template once the
project has one, so new sandboxes stop rerunning setup on every boot.
Saves that change nothing don't build, and a change saved during any
build, scheduled ones included, is built when that build ends.

- Factory sessions and MCP clients can now read the Factory's audit
trail with `factory_list_audit_events`: who did what to which work item,
run, branch or setting, and when. Filter by actor (`me`, a user id, or
an agent, optionally with the agent runs a person started), namespace or
exact actions, work item and time range, and page back with a cursor.
The tool only returns this Factory's events and never returns request
context (IP address, user agent), actor emails or event metadata beyond
who started an agent run. It leaves out events from or about other
people's private sessions.
([#30165](https://github.com/mastra-ai/mastra/pull/30165))

- Added a "Join the issue's card instead" switch to intake routes in the
Factory UI. A route for pull requests that close an issue can now put
the pull request on that issue's card instead of giving it a card of its
own; until now only the route Factory seeds could do this. The switch
shows on new and saved routes whose conditions include "Source kind is
Pull request" and "Pull request closes an issue is Yes".
([#30197](https://github.com/mastra-ai/mastra/pull/30197))

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/code-sdk@1.19.0-alpha.14
  - @mastra/mcp@2.9.0-alpha.4
## @mastra/observability@1.24.0-alpha.7

### Minor Changes

- Add span-local error counts.
([#30088](https://github.com/mastra-ai/mastra/pull/30088))

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
## @mastra/core@1.83.0-alpha.12

### Minor Changes

- Add model and provider as span query sort fields.
([#30096](https://github.com/mastra-ai/mastra/pull/30096))

  ```ts
  orderBy: [{ field: 'model', direction: 'asc' }];
  ```

- Add span-local error counts.
([#30088](https://github.com/mastra-ai/mastra/pull/30088))

### Patch Changes

- Name the agent in the missing-storage error thrown by `Memory`. When
an agent's memory never received storage because the agent was never
attached to a Mastra instance, accessing `memory.storage` now fails with
`[Agent:<name>] Memory requires a storage provider to function. ...`, so
it is clear which agent is misconfigured. The registration and
standalone-storage guidance added in #29972 is unchanged, and agents
that inherit storage from their Mastra or configure it directly on
`Memory` are unaffected.
([#30164](https://github.com/mastra-ai/mastra/pull/30164))

- Experiments with a scorer or processor target now save their scores,
and workflow step scorers in experiments now save their step scores.
Previously these scores were silently discarded.
([#30145](https://github.com/mastra-ai/mastra/pull/30145))
## @mastra/mcp-apps-components@0.1.0-alpha.7

### Minor Changes

- Dashboards authored in chat now accept the same widgets as the
dashboard editor: KPIs that combine values (ratio, difference, max,
fallback), read trace, span or score aggregates (for example p95 span
duration) and use duration, percent or score formats; line charts of
scores; six more chart colors (blue, orange, pink, yellow, red, purple);
and optional KPI icon and detail, series color and table empty message.
([#30192](https://github.com/mastra-ai/mastra/pull/30192))

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
## @mastra/playground-ui@69.0.0-alpha.14

### Minor Changes

- Widened what dashboard widgets can show:
([#30192](https://github.com/mastra-ai/mastra/pull/30192))

- KPIs can combine values with `ratio`, `minus`, `max` and `coalesce`,
read trace and span aggregates (for example `duration.p95`) and score
aggregates, and are formatted as `duration`, `percent` or `score`.
Combined values are compared with the previous window.
- Charts accept six more colors: `blue`, `orange`, `pink`, `yellow`,
`red` and `purple`.
- KPI `icon` and `detail`, series `color` and table `emptyMessage` are
optional. Series without a color pick one from a palette, and tables
without an empty message show "No data".

### Patch Changes

- Fixed hover highlights on cards and other surfaces stopping short of
the edge. The highlight now covers the whole surface and follows its
rounded corners exactly, including the sidebar credits card and
clickable cards. Hover highlights on these surfaces now switch instantly
instead of fading.
([#30047](https://github.com/mastra-ai/mastra/pull/30047))

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`987566e`](987566e882),
[`72abae6`](72abae68eb),
[`987566e`](987566e882),
[`f071044`](f0710446e0)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/client-js@1.60.0-alpha.12
  - @mastra/react@1.15.0-alpha.12
## @mastra/server@1.83.0-alpha.12

### Minor Changes

- Support model and provider sorting in span queries.
([#30096](https://github.com/mastra-ai/mastra/pull/30096))

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
## @mastra/clickhouse@1.30.0-alpha.4

### Minor Changes

- Sort span queries by model or provider in ascending or descending
order. ([#30096](https://github.com/mastra-ai/mastra/pull/30096))

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
## @mastra/duckdb@1.19.0-alpha.5

### Minor Changes

- Sort span queries by model or provider in ascending or descending
order. ([#30096](https://github.com/mastra-ai/mastra/pull/30096))

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
## @mastra/pg@1.36.0-alpha.6

### Minor Changes

- Sort span queries by model or provider in ascending or descending
order. ([#30096](https://github.com/mastra-ai/mastra/pull/30096))

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
## @mastra/react@1.15.0-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`987566e`](987566e882),
[`72abae6`](72abae68eb),
[`987566e`](987566e882),
[`f071044`](f0710446e0)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/client-js@1.60.0-alpha.12
## @mastra/deployer-cloud@1.83.0-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/deployer@1.83.0-alpha.12
## @mastra/longmemeval@1.1.42-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/libsql@1.30.0-alpha.3
## @mastra/opencode@0.1.42-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/libsql@1.30.0-alpha.3
## create-factory@0.4.3-alpha.14

### Patch Changes

- Updated dependencies
[[`1fbc69a`](1fbc69aa9a),
[`4e378c3`](4e378c3e26),
[`1fbc69a`](1fbc69aa9a)]:
  - mastra@1.39.0-alpha.14
## @mastra/code-sdk@1.19.0-alpha.14

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`72abae6`](72abae68eb),
[`f071044`](f0710446e0),
[`f071044`](f0710446e0),
[`987566e`](987566e882),
[`72abae6`](72abae68eb),
[`987566e`](987566e882),
[`f071044`](f0710446e0),
[`f071044`](f0710446e0)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/observability@1.24.0-alpha.7
  - @mastra/duckdb@1.19.0-alpha.5
  - @mastra/client-js@1.60.0-alpha.12
  - @mastra/pg@1.36.0-alpha.6
  - @mastra/mcp@2.9.0-alpha.4
  - @mastra/libsql@1.30.0-alpha.3
## mastracode@0.50.0-alpha.13

### Patch Changes

- Fix `/settings` crashing when mouse preferences are missing from saved
settings by defaulting to Off.
([#30184](https://github.com/mastra-ai/mastra/pull/30184))

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`72abae6`](72abae68eb),
[`f071044`](f0710446e0),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882),
[`f071044`](f0710446e0)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/observability@1.24.0-alpha.7
  - @mastra/duckdb@1.19.0-alpha.5
  - @mastra/pg@1.36.0-alpha.6
  - @mastra/code-sdk@1.19.0-alpha.14
  - @mastra/mcp@2.9.0-alpha.4
  - @mastra/libsql@1.30.0-alpha.3
## @mastra/arize@1.3.30-alpha.7

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/otel-exporter@1.5.2-alpha.7
## @mastra/arthur@0.4.30-alpha.7

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/otel-exporter@1.5.2-alpha.7
## @mastra/braintrust@1.3.27-alpha.7

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`72abae6`](72abae68eb),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/observability@1.24.0-alpha.7
## @mastra/datadog@1.4.22-alpha.7

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`72abae6`](72abae68eb),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/observability@1.24.0-alpha.7
## @mastra/deepeval@0.1.24-alpha.7

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`72abae6`](72abae68eb),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/observability@1.24.0-alpha.7
## @mastra/laminar@1.3.32-alpha.7

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`72abae6`](72abae68eb),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/observability@1.24.0-alpha.7
## @mastra/langfuse@1.6.6-alpha.7

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`72abae6`](72abae68eb),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/observability@1.24.0-alpha.7
  - @mastra/otel-exporter@1.5.2-alpha.7
## @mastra/langsmith@1.4.3-alpha.7

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`72abae6`](72abae68eb),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/observability@1.24.0-alpha.7
## @mastra/otel-bridge@1.5.22-alpha.7

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`72abae6`](72abae68eb),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/observability@1.24.0-alpha.7
  - @mastra/otel-exporter@1.5.2-alpha.7
## @mastra/otel-exporter@1.5.2-alpha.7

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`72abae6`](72abae68eb),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/observability@1.24.0-alpha.7
## @mastra/posthog@1.4.7-alpha.7

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`72abae6`](72abae68eb),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/observability@1.24.0-alpha.7
## @mastra/sentry@1.2.32-alpha.7

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`72abae6`](72abae68eb),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/observability@1.24.0-alpha.7
  - @mastra/otel-exporter@1.5.2-alpha.7
## mastra@1.39.0-alpha.14

### Patch Changes

- Added `mastra api factory work-item starters` and `mastra api factory
work-item activity`. The first counts the cards behind each new-session
starter on a project's default board. The second lists when a project's
cards were created and completed since an instant:
([#30097](https://github.com/mastra-ai/mastra/pull/30097))

  ```bash
  mastra api factory work-item starters <project-id>
mastra api factory work-item activity <project-id>
'{"since":"2026-06-01T00:00:00.000Z"}'
  ```

- Added a "Join the issue's card instead" switch to intake routes in the
Factory UI. A route for pull requests that close an issue can now put
the pull request on that issue's card instead of giving it a card of its
own; until now only the route Factory seeds could do this. The switch
shows on new and saved routes whose conditions include "Source kind is
Pull request" and "Pull request closes an issue is Yes".
([#30197](https://github.com/mastra-ai/mastra/pull/30197))

- Improved the Factory new session page on large boards. Its starters
and its activity band now load the counts and dates they show instead of
downloading every card of the project. They show the same content as
before. ([#30097](https://github.com/mastra-ai/mastra/pull/30097))

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/deployer@1.83.0-alpha.12
## @mastra/deployer@1.83.0-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/server@1.83.0-alpha.12
## @mastra/mcp-docs-server@1.3.13-alpha.16

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
## @mastra/elysia@0.1.23-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/server@1.83.0-alpha.12
## @mastra/express@1.5.27-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/server@1.83.0-alpha.12
## @mastra/fastify@1.5.27-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/server@1.83.0-alpha.12
## @mastra/hono@1.7.25-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/server@1.83.0-alpha.12
## @mastra/koa@1.7.27-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/server@1.83.0-alpha.12
## @mastra/nestjs@0.3.0-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/server@1.83.0-alpha.12
## @mastra/next@0.2.41-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/server@1.83.0-alpha.12
  - @mastra/hono@1.7.25-alpha.12
## @mastra/tanstack-start@0.2.41-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/server@1.83.0-alpha.12
  - @mastra/hono@1.7.25-alpha.12
## @mastra/voice-openai-realtime@0.14.9-alpha.2

### Patch Changes

- Use gpt-realtime-2.1-mini by default for OpenAI Realtime voice
connections instead of the retired
gpt-4o-mini-realtime-preview-2024-12-17 model.
([#30183](https://github.com/mastra-ai/mastra/pull/30183))
## @mastra/inngest@1.11.2-alpha.8

### Patch Changes

- Support span-local error counts in Inngest workflows.
([#30088](https://github.com/mastra-ai/mastra/pull/30088))

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
## @mastra/temporal@0.6.0-alpha.12

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`72abae6`](72abae68eb),
[`987566e`](987566e882)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/deployer@1.83.0-alpha.12
## create-mastra@1.39.0-alpha.14


## @internal/playground@1.39.0-alpha.14

### Patch Changes

- Updated dependencies
[[`56f654f`](56f654fc0d),
[`f071044`](f0710446e0),
[`987566e`](987566e882),
[`72abae6`](72abae68eb),
[`f9088d8`](f9088d8510),
[`987566e`](987566e882),
[`f071044`](f0710446e0),
[`43d1e9c`](43d1e9c16d)]:
  - @mastra/core@1.83.0-alpha.12
  - @mastra/client-js@1.60.0-alpha.12
  - @mastra/playground-ui@69.0.0-alpha.14
  - @mastra/react@1.15.0-alpha.12

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-12 14:42:02 +01:00
dane-ai-mastra[bot]
a4258a989c
chore: version packages (alpha) (#30127)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-11 21:12:19 -08:00
dane-ai-mastra[bot]
055a8c3b82 chore: version packages 2026-11-12 04:17:40 +00:00
dane-ai-mastra[bot]
9e82af0237
chore: version packages (alpha) (#30074)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-11 14:21:14 -08:00
dane-ai-mastra[bot]
3a6ca42696
chore: version packages (alpha) (#30026)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-11 08:16:57 -08:00
Leo
8896651bd1
fix(server): stop custom route agent runs on client disconnect after GC (#29617)
## Description

### Summary

When a client disconnects from a custom API route that streams an agent
run (for example `chatRoute`), the run and its model request could keep
going. Server adapters re-dispatch custom routes through `new
Request(url, { signal })`. undici forwards the client abort to that
inner Request's own signal through a listener that holds the inner
controller only weakly (nodejs/undici#4068). Once the route returns its
streaming Response, nothing holds the inner Request, so a GC drops it
and the abort never reaches `c.req.raw.signal`.

The fix is in the shared `handleCustomRouteRequest` in `@mastra/server`,
so every custom route on every adapter gets it. The returned Response
gets a pass-through body whose closure holds the inner Request, and
drops it when the body is fully read, errors or is cancelled. Status,
status text and headers are unchanged; null-body responses are returned
as is.

```diff
 handleCustomRouteRequest(url, method, headers, body, requestContext, signal)
   const request = new Request(url, { ...init, signal })
   const response = await customRouteHandler(request, ...)
-  return response
+  return signal ? retainRequestWhileBodyIsOpen(response, request) : response
```

An earlier version of this PR used a `WeakMap<AbortSignal, Request>`
keyed by the client signal. Factory found it leaked every request whose
signal never aborts, which includes every normal Express response.
Cause: undici's `Request` constructor calls
`requestFinalizer.register(ac, { signal, abort })`, and a
FinalizationRegistry holds that held value (with the outer signal)
strongly while the inner controller lives, so signal -> WeakMap ->
request -> controller -> registry -> signal is a cycle the GC never
breaks. Holding the request from the body avoids the cycle: the body is
reachable exactly while an adapter is still sending the response.

```mermaid
flowchart LR
  A[client socket close] --> B[outer AbortController.abort]
  B --> C[undici listener on outer signal]
  C -. WeakRef .-> D[inner Request's controller]
  D --> E[c.req.raw.signal -> agent.stream abortSignal]
  G[adapter reading response body] ==> H[pass-through body]
  H == holds until done / error / cancel ==> F[inner Request]
  F --> D
```

### Evidence

Shared conformance suite `createCustomRouteDisconnectTestSuite`
(`@mastra/server-adapters-test-suite`), wired into Hono
(`@hono/node-server`), Express, Fastify, Koa and Elysia, over real HTTP:

1. Disconnect: a real `Agent` streams from a fake OpenAI-compatible
server, the route passes `c.req.raw.signal` as `abortSignal` (the same
wiring as `chatRoute`), the test forces GC, destroys the client socket,
and asserts the model request is aborted.
2. Release (new): a custom route streams a 201 response that completes,
or fails mid-stream; the test registers the inner `c.req.raw` and its
signal with a `FinalizationRegistry`, forces GC, and asserts both are
finalized.

| Server code | Disconnect | Release, completes | Release, fails
mid-stream |
|---|---|---|---|
| `origin/main` style, no retention | fails 5/5 adapters (`expected
'model request still running' to be 'model request aborted'`) | passes
5/5 | passes 5/5 |
| previous PR head 02fada0 (WeakMap) | passes 5/5 | fails 5/5 (`expected
[] to deeply equal [ 'request', 'request signal' ]`) | fails on Elysia;
others abort the signal on a broken body |
| this head | passes 5/5 | passes 5/5 | passes 5/5 |

- **Stability:** with the fix, 40/40 adapter suite runs passed (5 runs
of the 2-test suite plus 3 runs of the 3-test suite, on each adapter).
An independent reviewer ran Express and Hono 20 times each, all passing.
- **Factory's measurement, reproduced** (`new Request(url, { signal })`,
80 forced GCs, `FinalizationRegistry`):

| Node (undici) | No map | `WeakMap.set(signal, request)` | WeakMap +
abort |
  |---|---|---|---|
| v24.22.1 (7.30.1) | both finalized | neither finalized | both
finalized |
  | v22.22.1 | both finalized | neither finalized | both finalized |

- **Issue repro script** (`chatRoute` + `createNodeServer`, `node
--expose-gc`): `aborted after disconnect: false` before, `true` after,
on Node 24.22.1 and 22.22.1. CI runs Node 24.22.1, where the bug
reproduces.
- **No regressions:** `@mastra/server` `src/server/server-adapter` unit
tests 434/434. `tsc --noEmit` for `@mastra/server` and the test suite,
`oxfmt --check` and `oxlint --deny-warnings` are clean on the changed
files. The reviewer also checked status, status text, multiple
`set-cookie`, mutable headers (Fastify merges plugin headers into the
returned Response), explicit `content-length`, and Hono's node-server
`Response` override.
- **Not covered:** native Bun (Elysia's test runs on a Node HTTP shim;
Bun's `Request` isn't undici). `@mastra/nestjs` custom routes don't
forward a client abort signal at all, which is a separate gap this PR
doesn't touch.

### Merge Danger

**Door:** two-way. One helper in `server-adapter/index.ts` plus tests
and changesets; a revert undoes it.

**Blast radius:** every custom API route response with a body, on every
adapter. The body now passes through one extra `ReadableStream`: one
extra async read per chunk, and no BYOB reads of the route's body. On
Hono, `@hono/node-server` can no longer infer `content-length` for a
small non-streamed custom route body (for example `c.json(...)`), so it
goes out chunked unless the handler sets `content-length` itself.
Express, Fastify and Koa already pipe custom route bodies as chunked. A
body an adapter keeps but never reads or cancels keeps its request until
the body is collected; no adapter does that today. Conflicts: none with
#29549 (`feat(ai-sdk): add reconnectable chat routes`), which rewrites
`client-sdks/ai-sdk/src/chat-route.ts`; this PR does not touch that
file.

## Related issue(s)

Closes #29154

## Type of change

- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [x] Test update

## Checklist

- [x] I have linked the related issue(s) in the description above
- [ ] I have made corresponding changes to the documentation (if
applicable)
- [x] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have addressed all Coderabbit comments on this PR

## Council review

Rounds: 3

| Seat | Round 1 | Round 2 | Round 3 (request release follow-up) |
| --- | --- | --- | --- |
| Claude Opus 5.5 | not run | 9/10 (Correctness 9, Tests 9, Scope 10,
Code quality 9) | not run |
| GPT-6.1 Sol | 9/10 (Correctness 9, Tests 9, Scope 10, Code quality 9)
| 9/10 (Correctness 9, Tests 9, Scope 10, Code quality 9) | 9/10
(Correctness 9, Tests 9, Scope 10, Code quality 9), no findings |
| Grok 4.7 | empty seat | empty seat | empty seat |

Created with Claude Opus 5.5 in T3 Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

When a client disconnects during a streamed response, the server keeps
the request alive until the response ends, fails, or is cancelled. This
allows the disconnect to stop the agent and model request after garbage
collection.

## Changes

- Updated `handleCustomRouteRequest` to retain the re-dispatched
`Request` while a response body is active.
- Preserved response status, status text, and headers.
- Left null-body responses unchanged.
- Added shared tests for disconnect handling and request release.
- Added test setups for Hono, Express, Fastify, Koa, and Elysia.
- Exported the shared test suite and configuration type.
- Added patch changesets for `@mastra/server` and
`@mastra/server-adapters-test-suite`.

**Diff size:** 10 files; 504 lines added and 1 removed.  
**CI, build, and test results:** not available.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 03:34:38 -05:00
dane-ai-mastra[bot]
8bce7717eb
chore: version packages (alpha) (#29986)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-10 20:51:40 -08:00
dane-ai-mastra[bot]
23cc34a9c5
chore: version packages (alpha) (#29938)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases

> The changelog information of each package has been omitted from this
message, as the content exceeds the size limit.

## @mastra/factory@0.28.0-alpha.6


## @mastra/code-sdk@1.19.0-alpha.6


## @mastra/playground-ui@69.0.0-alpha.7


## @mastra/client-js@1.60.0-alpha.6


## @mastra/react@1.15.0-alpha.6


## @mastra/deployer-cloud@1.83.0-alpha.6


## @mastra/longmemeval@1.1.42-alpha.6


## @mastra/opencode@0.1.42-alpha.6


## create-factory@0.4.3-alpha.6


## mastracode@0.50.0-alpha.6


## @mastra/agent-builder@1.2.1-alpha.3


## mastra@1.39.0-alpha.6


## @mastra/core@1.83.0-alpha.6


## @mastra/deployer@1.83.0-alpha.6


## @mastra/editor@0.17.1-alpha.4


## @mastra/mcp@2.9.0-alpha.3


## @mastra/mcp-docs-server@1.3.13-alpha.9


## @mastra/memory@1.41.1-alpha.3


## @mastra/rag@2.7.3-alpha.2


## @mastra/schema-compat@1.3.18-alpha.0


## @mastra/server@1.83.0-alpha.6


## @mastra/elysia@0.1.23-alpha.6


## @mastra/express@1.5.27-alpha.6


## @mastra/fastify@1.5.27-alpha.6


## @mastra/hono@1.7.25-alpha.6


## @mastra/koa@1.7.27-alpha.6


## @mastra/nestjs@0.3.0-alpha.6


## @mastra/next@0.2.41-alpha.6


## @mastra/server-adapters-test-suite@0.3.0-alpha.3


## @mastra/tanstack-start@0.2.41-alpha.6


## @mastra/upstash@1.6.1-alpha.0


## @mastra/vectorize@1.1.5-alpha.0


## @mastra/voice-google-gemini-live@0.14.19-alpha.0


## @mastra/voice-openai-realtime@0.14.9-alpha.0


## @mastra/voice-xai-realtime@0.2.18-alpha.0


## @mastra/inngest@1.11.2-alpha.4


## @mastra/temporal@0.6.0-alpha.6


## create-mastra@1.39.0-alpha.6


## @internal/playground@1.39.0-alpha.6

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-10 15:51:29 -08:00
Daniel Lew
2dbb9c83b3
test(server): harden the Observational Memory ownership tests and correct the changeset (#29955)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-10 16:12:20 -05:00
Daniel Lew
94bf8761f4
fix(server): enforce thread ownership on gateway Observational Memory routes (#29926)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-10 12:36:51 -08:00
Arthur Fiorette
d50e8b275d
fix(elysia): accept empty JSON bodies and end failed streams cleanly (#29944) 2026-11-10 12:22:09 -08:00
dane-ai-mastra[bot]
779d2875b1
chore: version packages (alpha) (#29912)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases

> The changelog information of each package has been omitted from this
message, as the content exceeds the size limit.

## @mastra/auth-studio@1.4.0-alpha.1


## @mastra/factory@0.28.0-alpha.5


## @mastra/mcp-apps-components@0.1.0-alpha.5


## @mastra/playground-ui@69.0.0-alpha.6


## @mastra/client-js@1.60.0-alpha.5


## @mastra/react@1.15.0-alpha.5


## @mastra/deployer-cloud@1.83.0-alpha.5


## @mastra/longmemeval@1.1.42-alpha.5


## @mastra/opencode@0.1.42-alpha.5


## create-factory@0.4.3-alpha.5


## @mastra/code-sdk@1.19.0-alpha.5


## mastracode@0.50.0-alpha.5


## @mastra/agent-builder@1.2.1-alpha.2


## mastra@1.39.0-alpha.5


## @mastra/core@1.83.0-alpha.5


## @mastra/deployer@1.83.0-alpha.5


## @mastra/editor@0.17.1-alpha.3


## @mastra/mcp@2.9.0-alpha.2


## @mastra/mcp-docs-server@1.3.13-alpha.8


## @mastra/memory@1.41.1-alpha.2


## @mastra/rag@2.7.3-alpha.1


## @mastra/server@1.83.0-alpha.5


## @mastra/elysia@0.1.23-alpha.5


## @mastra/express@1.5.27-alpha.5


## @mastra/fastify@1.5.27-alpha.5


## @mastra/hono@1.7.25-alpha.5


## @mastra/koa@1.7.27-alpha.5


## @mastra/nestjs@0.3.0-alpha.5


## @mastra/next@0.2.41-alpha.5


## @mastra/server-adapters-test-suite@0.3.0-alpha.2


## @mastra/tanstack-start@0.2.41-alpha.5


## @mastra/libsql@1.30.0-alpha.2


## @mastra/turso@0.1.21-alpha.2


## @mastra/inngest@1.11.2-alpha.3


## @mastra/temporal@0.6.0-alpha.5


## create-mastra@1.39.0-alpha.5


## @internal/playground@1.39.0-alpha.5

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-10 10:50:08 -08:00
shreyas-mastra
ce76df95d5
fix(server): check auth against the custom route that handles the request (#29325) 2026-11-10 09:21:04 -08:00
dane-ai-mastra[bot]
7c4dd88400
chore: version packages (alpha) (#29889)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-10 15:48:17 +01:00
dane-ai-mastra[bot]
6deb16047f
chore: version packages (alpha) (#29719)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases

> The changelog information of each package has been omitted from this
message, as the content exceeds the size limit.

## @mastra/slack@1.9.0-alpha.0


## @mastra/factory@0.28.0-alpha.3


## @mastra/code-sdk@1.19.0-alpha.3


## mastracode@0.50.0-alpha.3


## @mastra/observability@1.24.0-alpha.2


## @mastra/core@1.83.0-alpha.3


## @mastra/mcp-apps-components@0.1.0-alpha.3


## @mastra/playground-ui@69.0.0-alpha.4


## @mastra/server@1.83.0-alpha.3


## @mastra/server-adapters-test-suite@0.3.0-alpha.1


## @mastra/platform-workspace@1.13.0-alpha.0


## @mastra/auth-better-auth@1.1.11-alpha.1


## @mastra/client-js@1.60.0-alpha.3


## @mastra/react@1.15.0-alpha.3


## @mastra/deployer-cloud@1.83.0-alpha.3


## @mastra/longmemeval@1.1.42-alpha.3


## @mastra/opencode@0.1.42-alpha.3


## create-factory@0.4.3-alpha.3


## @mastra/arize@1.3.30-alpha.2


## @mastra/arthur@0.4.30-alpha.2


## @mastra/braintrust@1.3.27-alpha.2


## @mastra/datadog@1.4.22-alpha.2


## @mastra/deepeval@0.1.24-alpha.2


## @mastra/laminar@1.3.32-alpha.2


## @mastra/langfuse@1.6.6-alpha.2


## @mastra/langsmith@1.4.3-alpha.2


## @mastra/otel-bridge@1.5.22-alpha.2


## @mastra/otel-exporter@1.5.2-alpha.2


## @mastra/posthog@1.4.7-alpha.2


## @mastra/sentry@1.2.32-alpha.2


## @mastra/agent-builder@1.2.1-alpha.1


## mastra@1.39.0-alpha.3


## @mastra/connect@1.3.2-alpha.2


## @mastra/deployer@1.83.0-alpha.3


## @mastra/editor@0.17.1-alpha.2


## @mastra/fastembed@1.3.7-alpha.0


## @mastra/mcp-docs-server@1.3.13-alpha.6


## @mastra/memory@1.41.1-alpha.1


## @mastra/elysia@0.1.23-alpha.3


## @mastra/express@1.5.27-alpha.3


## @mastra/fastify@1.5.27-alpha.3


## @mastra/hono@1.7.25-alpha.3


## @mastra/koa@1.7.27-alpha.3


## @mastra/nestjs@0.3.0-alpha.3


## @mastra/next@0.2.41-alpha.3


## @mastra/tanstack-start@0.2.41-alpha.3


## @mastra/convex@1.8.1-alpha.0


## @mastra/pg@1.36.0-alpha.2


## @mastra/inngest@1.11.2-alpha.2


## @mastra/temporal@0.6.0-alpha.3


## create-mastra@1.39.0-alpha.3


## @internal/playground@1.39.0-alpha.3

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-10 10:33:29 +01:00
mastra-platform[bot]
4854e36419
fix(core, server): stop a peer server from approving an aborted parked durable run (#29799)
> Opened by @user_01KNA8J74D4RF84RXSDRX26BS9

## Problem
A durable agent run that is waiting for tool approval (with no thread)
can be aborted over HTTP. The abort returns `200 {"aborted":true}`, but
that was only recorded in memory on the server that handled the abort.
When the app runs on more than one server, approving the tool call on a
different server still resumed the run and **ran the tool**. When the
abort and approval happened on the same server, the approval was
rejected with a `500` rather than a clear error code. Fixes COR-1518.

## Fix
- **Abort saves the cancellation in storage before it is acknowledged**
(`packages/core/src/agent/durable/durable-agent.ts`):
- Stores that support concurrent updates: a guarded
`updateWorkflowState({ status: 'canceled', expectedStatus: 'suspended'
})`.
- Stores without `updateWorkflowState` (snapshot-only, e.g. LanceDB) and
stores without concurrent updates (e.g. Redis): reread the run, then
rewrite its snapshot as `canceled` with `persistWorkflowSnapshot(...,
expectedStatus: 'suspended')`, keeping `resourceId`.
- Storage errors propagate. The abort does not report success while the
run can still be resumed.
- If a resume has already claimed the run (status `running`), the
guarded write makes no change, and the existing abort of a running run
applies.
- **Resume on any server rejects runs canceled in storage** with
`AGENT_RESUME_ABORTED_RUN`, before it claims the run. The in-flight
resume marker is still taken synchronously before the first `await`
(#27365); the storage check runs right after it and releases the marker
when it rejects the run.
- **Observers of a canceled run are closed on every server**: the abort
that wins the `suspended → canceled` write publishes the abort event
right away on the shared pubsub, so `observe` streams on all servers end
and their history/listeners are cleaned up; the `canceled` row is kept.
If that publish fails, the abort still succeeds (the cancel is stored)
and a later refused approval/resume on that server retries the publish.
- **Docs and changeset**: `docs/.../agents/resumable-streams.mdx` and
`reference/agents/durable-agent.mdx` now point parked runs in
multi-server apps at `POST /agents/:agentId/runs/:runId/abort`, describe
the stored cancellation and the `409 Conflict`
(`AGENT_RESUME_ABORTED_RUN`) refusal, and qualify `abortRunStream` as
process-local. The changeset is scoped to
`DurableAgent`/`createDurableAgent` (evented agents inherit it; Inngest
agents are not covered) and states the best-effort limit on stores
without concurrent updates.
- **Approve route** (`packages/server/src/server/handlers/agents.ts`): a
`canceled` snapshot is treated as final instead of waiting 10s for a
suspension. The resource, thread and agent ownership checks still run
first, so other callers get `403` and learn nothing about the abort.
- **API contract** (`packages/server/src/server/handlers/error.ts`):
`AGENT_RESUME_ABORTED_RUN` now maps to **`409 Conflict`**, joining the
existing resume-claim conflict codes. It used to fall through to a
`500`.

## Proof
**Lifecycle regressions found in review and fixed in this PR** (final
head `1e0af6b5e8`):
1. *Healthy-lifecycle regression* (found by independent review at
`635c8837e3`): after a same-server abort and refused approval, an
attached observer stayed open and the run's history/listeners were
retained, because the `canceled` row skipped the old abort event. Fixed
in `c4cbdb987a`.
2. *Failed-first-publish recovery* (found by independent review at
`c4cbdb987a`): if publishing that abort event failed once, later
refusals never retried it and the observer stayed open. Fixed in
`7a856a33a3`, which also restores the #27365 marker ordering.
3. *Cross-server observer gap* (found by review at `7a856a33a3`): when
the abort and the refused approval landed on different servers,
observers stayed open because only the refusing server's local fence
published the abort event. Fixed in `6d444bee4f` by publishing at abort
time from the cancel winner.
4. *Human review (NikAiyer)*: docs, changeset scope, and a test that
pins the guarded write — addressed in `1e0af6b5e8`.

**Author: in-repo tests at final head `1e0af6b5e8`**
-
`server-adapters/hono/src/__tests__/parked-run-abort-across-servers.test.ts`:
two Hono servers over real TCP. They share a store and cache, and each
has its own pubsub and runtime state. 10/10 pass:
  - No abort, approve on the other server: `200`, tool runs once.
- Abort on the executing server, approve on the other server: `409`,
tool runs 0. **On main this returns 200 and the tool runs once (the
bug).**
- Abort on the other server, approve there: `409`, tool runs 0. Abort
and approve on the executing server: `409`, tool runs 0. On main both
return `500`.
- In all three abort rows, observers attached on **both** servers close
within 2s with exactly one abort frame each. With core from `7a856a33a3`
the executor-abort/other-approve row fails (observers stay open);
removing the abort-time publish makes it fail again.
- Another user's approval of an aborted run gets `403`, and so does
approval through another agent. In both cases the abort is not revealed.
- Race: a run that a resume has already claimed stays `running` after
the abort.
- Race inside the abort: a resume claims the run between the abort's
status read and its guarded write → the abort returns `200
{aborted:false}` and the run stays `running`. Removing `expectedStatus:
'suspended'` from the write makes this test fail.
- Observer: observe → abort → two refused approvals (409, 409) → the
observer closes within 2s, exactly one abort event is published, the row
stays `canceled`, and a peer approval still gets 409 with tool runs 0.
At `635c8837e3` the observer stays open; removing the once-guard
publishes 2.
- Failed first publish: the abort's own publish rejects, then the broker
recovers → the next refused approval on that server republishes → the
observer closes, one abort published, tool runs 0. Removing the
reservation release makes it fail (observer open, 0 published).
- `stores/lance/src/storage/parked-run-abort.test.ts`: real LanceDB with
two peers. After the abort, status is `canceled` and the peer's approval
is rejected with `AGENT_RESUME_ABORTED_RUN`, tool runs 0. Running it
with only the first commit fails with `updateWorkflowState is not
implemented`.
- `packages/server/src/server/handlers/error.test.ts`: 27/27 pass,
including the new 409 mapping.
- Revert checks: undoing the core change brings back `200`/1 tool run;
undoing the error mapping gives `500`; undoing the approve-route change
makes the approval wait out the 10s timeout.

**Author: real Redis, two processes — run on earlier heads
(`635c8837e3`/`c4cbdb987a`/`6d444bee4f`), NOT on the final head
`1e0af6b5e8`; this harness does not check observer closing** (two Node
processes running Hono, each sharing `RedisStore`, `RedisServerCache`
and `RedisStreamsPubSub` on a local Redis 7, using the public HTTP API)
| scenario | abort | approve on peer | tool commits |
|---|---|---|---|
| no abort | n/a | 200 | 1 |
| abort on executing server | 200 `{aborted:true}` | 409
`AGENT_RESUME_ABORTED_RUN` | 0 (main: 200, 1) |
| abort on peer | 200 | 409 `AGENT_RESUME_ABORTED_RUN` | 0 (main: 500,
0) |

**Independent reviewer** (separate session): approved the exact final
head `1e0af6b5e8`, including the `6d444bee4f` runtime change. Hono
10/10, HTTP ownership 4/4, Lance 1/1, resume-claim tests 37, build and
tsc. Failed-first-publish recovery and observer cleanup on both peers
were proven with real-TCP probes. Earlier rounds approved `635c8837e3`
(Lance 1/1, Hono 7/7; a LanceDB abort that returned `500` on the first
commit now returns `200` and the canceled snapshot keeps its other
fields) and `7a856a33a3` (concurrent refusals publish one terminal;
resume-marker release).

**Measured caveat (independent reviewer):** with simultaneous aborts,
the single CAS winner publishes one terminal and that closes the
observers on both servers; each original observer sees exactly one
abort, every approval gets `409`, and the tool runs 0 times. But a
**later** approval on the server whose abort lost the race can publish a
**second** terminal, because the once-guard is a per-instance set; after
cleanup this leaves 1 history entry retained. This PR does **not**
guarantee a globally-once terminal or unconditionally empty history.

Checks: tsc passes for core, server and hono. Lance oxlint is clean.
Prettier is clean on the changed lines; `agents.ts` already fails
Prettier on `main`, and that existing drift is left alone.

## Self-review (board self-review, approved at `635c8837e3`; the later
lifecycle fixes were approved by the independent re-review above)
The run abort route now records the cancellation in shared storage, and
every later resume or approval checks it on any server before anything
runs. A blocked approval returns `409 AGENT_RESUME_ABORTED_RUN`.
Adversarial check: if the resume claims first, the abort's guarded write
fails and the run stays `running` (tested). If the abort writes first,
the resume either sees `canceled` and gets 409, or loses its own claim
and gets the existing claim-lost 409. Authorization runs before the
canceled state is revealed. Nothing blocking was found.

| Check | Result | Tests |
|---|---|---|
| Build `@mastra/hono...` + `@mastra/lance...` | ✅ | — |
| Hono two-server HTTP (`parked-run-abort-across-servers.test.ts`) | ✅ |
7/7 |
| LanceDB parked abort (`parked-run-abort.test.ts`) | ✅ | 1/1, plus 8
reruns including under CPU load (1 early failure that could not be
reproduced) |
| Server error mapping (`error.test.ts`) | ✅ | 27/27 |
| Core durable suite (both storage projects, type-check on) | ❌ | 3966
passed, 1 failed, 4 skipped; no type errors |
| That failing file rerun on its own
(`durable-agent-tool-call-resumed.test.ts`) | ✅ | 30/30 |

Not run by self-review: a revert of the production files to re-run the
Hono test against the old code (Linear's main repro stands in for it,
and the author's revert checks above cover it); a real two-process Redis
run (covered by the author's harness above); repo-wide lint/format.

## Unverified
- The full Hono adapter suite was not run to completion.
- In the core durable suite, `durable-agent-tool-call-resumed.test.ts >
applies the display transform…` failed once with
`AGENT_RESUME_ALREADY_CLAIMED` and passed when run on its own. It looks
like test-isolation contention, not a confirmed cause. Separately,
`durable-agent-crash-recovery.test.ts` runs out of memory on `main` too.
- The Redis two-process harness was not run on the final head, and it
does not check observer closing; the cross-server observer tests use an
in-process shared-emitter pubsub, not Redis.
- A truly concurrent abort and approval on stores without concurrent
updates was not tested.

## Risk
- On stores without concurrent updates (Redis, Valkey, Elasticsearch,
LanceDB, ClickHouse, Cloudflare KV/DO), the canceled write is
**best-effort, not atomic**: the status is checked and then the snapshot
rewritten. An approval that lands between the two can still go ahead.
This PR does **not** guarantee that a racing abort and approval resolve
cleanly on every store; it guarantees that an abort that has already
completed is honored on every server. No new `supportsConcurrentUpdates`
requirement is added.
- The abort-event dedupe is per process and bounded (1000 run ids). It
is not global: see the measured caveat above (a later approval on the
losing-abort peer can publish a second terminal and retain one history
entry).
- A failed abort-time publish is retried only by a later refused request
on the aborting server; a peer's refusal does not retry it, and there is
no background retry.
- Aborted parked runs now keep a `canceled` row instead of a `suspended`
one.
- The thread abort route (`__abortThreadStreamAcrossProcesses`) does not
write the storage fence. That is out of COR-1518's scope.
- An abort that arrives while the run is still executing and parks just
afterwards keeps the existing behavior.
- `AGENT_RESUME_ABORTED_RUN` is also thrown by the non-durable `Agent`,
which now also gets `409` instead of `500`.



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

When a run pauses for tool approval, canceling it now records that
decision so another server cannot approve the run and start the tool.
This helps prevent canceled work from continuing elsewhere.

## Summary

- Persist cancellation for parked `DurableAgent` runs before confirming
the abort. Use a guarded status update when the storage adapter supports
concurrent updates. Otherwise, save the updated snapshot. On adapters
without concurrent updates, an approval that overlaps the save may still
proceed.
- Reject approval or resume attempts for canceled runs with
`AGENT_RESUME_ABORTED_RUN`. Check ownership before returning `409
Conflict`.
- Publish an abort event after cancellation so observers can close. If
publication fails, a later refused resume can retry it.
- Add cross-server integration tests and a LanceDB regression test.
Update the documentation to describe the behavior and clarify that it
applies to `DurableAgent`, not Inngest agents.

## Validation

Reported final-head results: the Hono two-server test passed 10/10, the
LanceDB test passed 1/1, and the server error-mapping test passed 27/27.
Core, server, and Hono type checks passed. The core durable suite
reported 3,966 passed and 1 failed; the failed test passed when rerun
alone. The full Hono suite was not completed. The Redis two-process
harness ran on earlier heads, not the final head. Repository-wide lint
and format results are not available.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastra-platform[bot] <mastra-platform[bot]@users.noreply.github.com>
Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-09 20:49:41 -08:00
mastra-platform[bot]
8a10dfe648
fix(core): allow authorized finished durable replay across servers (#29791)
## Summary

Fix finished `DurableAgent` and evented-agent output replay returning
404 on a different server while the executing server can still replay
the same retained output.

- Publish shared, read-only replay ownership before execution starts;
remove it alongside replay-history cleanup.
- Consult that ownership only for observation when persisted workflow
ownership is missing. Explicit denials and unverifiable workflow rows
remain authoritative, and existing resource, RequestContext, thread and
FGA checks still apply.
- Keep abort/write authorization separate: replay ownership never
permits stopping a finished run.
- Add real-TCP Hono regressions for durable/evented replay, ownership
denial, thread-read denial, anonymous access, finished abort, unknown
runs and post-cleanup 404; include core/server patch changesets.

Fixes COR-1512. Independent branch from main; no COR-1518 cancellation
or COR-1517 snapshot changes.

## Proof

Reviewed candidate: `c412839fb8`, based on
`6bc7614a8f`.

Author verification:
- Real local Redis, two HTTP processes: baseline owner replay was 200 on
executor / 404 on peer for durable and evented agents; candidate returns
200 / 200. Foreign users receive 403 / 403, anonymous callers 401 / 401,
and both servers return 404 after cleanup. Finished abort remains `{
aborted: false }`. The Redis ownership key is present during the replay
window and removed after cleanup.
- Reverting the production changes makes both committed durable/evented
regressions fail with peer 404.
- Core/server/Hono typechecks, changed-file lint/format, 290 server
agent tests, full Hono suite and 62 affected durable test files passed.

Independent exact-head review:
- Fresh core/server builds and core build typecheck passed; verified
candidate module resolution rather than stale distributions.
- 381 committed tests passed: 8 TCP replay/access tests, 315 server
ownership/agent tests and 58 focused core lifecycle/cleanup tests.
- Additional handler-level probes verified RequestContext-dependent
memory, denied/unverified workflow rows never consulting shared
ownership, cache-read failure returning 503, WRITE never using replay
ownership, and owner-publication failure preserving live completion
while remote access fails closed.

## Unverified

- The committed TCP tests share in-memory objects within one process.
The author's two-process Redis harness is uncommitted and was not
independently rerun; Redis results above are author evidence, not
independent proof.
- No hosted Redis, cluster/TLS/failover, load, browser, full-repository
CI or real Inngest replay qualification. The separate Inngest proxy does
not acquire the new replay-owner capability in this patch.
- Fresh GitHub CI and maintainer review remain pending.

## Risk

Adds one bounded shared ownership record per durable run. Its TTL is 24
hours; normal deletion follows existing replay cleanup and ownership
guards. Cleanup remains best effort/asynchronous, not a transaction
promising retention under backend failure. Cache expiry/eviction can
shorten access, and failed owner publication can leave peer replay
unavailable while the initiating response succeeds. Existing
unique-run-ID requirements remain unchanged; this is not a new
namespace, reuse protocol, durable event log or write/cancellation
authority.

Co-authored-by: mastra-platform[bot] <mastra-platform[bot]@users.noreply.github.com>
Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-09 12:32:03 -08:00
Arthur Fiorette
efa3999a21
fix(server-adapters): stop reading route streams after the client disconnects (#29669)
## Description

Server adapters now cancel the stream a route returned once the client
disconnects, including a client that left before the route handler
returned. For agents with resumable streams, that cancel is the only
signal that the HTTP observer left. Without it, NestJS returned 404 "Run
not found" from `/observe` after a dropped `untilIdle` stream, the same
failure #29636 fixed for Express.

| Adapter | Before |
|---|---|
| Koa | `datastream-response` never cancelled; both route types missed
an early drop |
| Fastify | missed an early drop |
| NestJS | never cancelled |
| Hono | an early drop left the body open |
| Elysia | `datastream-response` never cancelled |

Also in this PR:

- **Backpressure (not part of the cancellation bug).** Express, Koa,
Fastify, NestJS and Elysia now wait for a slow client instead of
buffering the whole stream in memory. This is the only change for
Express.
- The route abort signal now fires when the client left while earlier
middleware ran (Express, Koa, Fastify, NestJS, Elysia).
- The agent controller session stream and the empty background task
stream close right away if the request was already aborted.
- `@mastra/server/server-adapter` exports `cancelReaderOnResponseClose`
and `writeWithBackpressure` for custom adapters, documented in the
custom adapter guide along with `createStreamDisconnectTestSuite`.

## Related issue(s)

Fixes #29640
Fixes #28480

Follow-up to #29636. Elysia durable-disconnect failures are tracked in
#29667.

## Type of change

- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [ ] Test update

## Checklist

- [x] I have linked the related issue(s) in the description above
- [x] I have made corresponding changes to the documentation (if
applicable)
- [x] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have addressed all Coderabbit comments on this PR


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

When a client disconnects, the server now stops reading data that the
client cannot receive. When a client reads slowly, several adapters wait
before sending more data instead of buffering the whole stream.

## Summary

- Added shared helpers to cancel stream readers when a Node.js response
closes and to wait for socket capacity before writing.
- Updated Express, Koa, Fastify, and NestJS stream handlers to cancel on
disconnect and apply backpressure. Their request-context handling also
detects disconnects that occur before close listeners are attached.
- Updated Hono and Elysia stream handling to respond to aborts and
process stream data incrementally.
- Updated the agent-controller session stream and background-task stream
to close when their abort signal is already set.
- Added a shared real-HTTP test suite for disconnects, early
disconnects, normal completion, and slow clients, with adapter-specific
test setups. Added durable-disconnect test setups for Koa and NestJS.
- Updated custom adapter documentation with stream-cancellation and
backpressure helpers, plus guidance for running the disconnect test
suite.
- Hono returns `datastream-response` bodies unchanged and cancels an
unread body on request abort.

## Change size and checks

- **Files changed:** 35
- **Lines added / removed:** 1,278 / 264
- **CI, build, and test results:** not available
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-09 09:59:22 -08:00
dane-ai-mastra[bot]
009f632534 chore: version packages 2026-11-09 04:19:07 +00:00
mastra-platform[bot]
5b03e9ce69
refactor(server): share authorization for observing and aborting agent runs (#29600)
## Summary

Route agent-run observation and cancellation through one shared
authorization policy so ownership and thread-permission checks do not
drift between the two endpoints.

- Observe continues to require `MEMORY_READ`; abort continues to require
`MEMORY_WRITE`.
- Preserve resource ownership, RequestContext/Studio FGA selection,
thread access checks, and fail-closed handling of missing or
unverifiable ownership.
- Preserve existing route responses and cancellation acknowledgement:
authorization alone never means a run was stopped.
- Add real HTTP regressions for plain and durable agents, including
access during the first model call, and a server PATCH changeset.

This is the independent server authorization lane of the stream-layer
work. It is based directly on `main`, does not contain the core/Inngest
session-extraction branch, and imports no new core APIs. No peer-floor
changes are needed. Production changes are limited to
`packages/server/src/server/handlers/agents.ts`.

## Behavior deliberately preserved

Plain runs resolve ownership through shared run records and the existing
published-owner compatibility fallback. Durable observation can use the
local run owner before falling back to persisted workflow ownership.
Durable cancellation still requires verifiable workflow ownership; the
retained observation registry is not evidence that a finished run
remains cancellable.

Unknown observation returns 404. Unknown plain cancellation returns 404;
unknown/unverifiable durable cancellation returns `{ aborted: false }`.
Finished plain runs return `{ aborted: false }`. Existing 403/501/503
handling, recovery, and acknowledged-abort dispatch remain unchanged.

## Proof

Implementation candidate: `8b5c87e319`.
Release-metadata candidate `f46b980ef7`
adds only the server PATCH changeset; the test-only follow-up below is
the current head.

- Author verification: **281/281** server agent-handler tests and
**98/98** Hono run-access, durable-disconnect, and recovery-checkpoint
tests passed. Server TypeScript and changed-file lint passed.
- New real-TCP access cases cover owner/read-only viewer/foreign
tenant/anonymous requests, unknown runs, wrong-agent targeting,
confirmed tool cancellation, and first-model-call cancellation for plain
and durable agents. They also pass on unchanged baseline, as expected
for a behavior-preserving refactor.
- Mutation proof: authorizing cancellation with READ instead of WRITE
fails four cases; removing durable ownership validation fails two cases.
- Independent review found no actionable defect. It reran **281/281**
handler tests and **4/4** new TCP cases, rebuilt the candidate server,
verified the new helper in the generated runtime, and reran **4/4** TCP
cases against that fresh runtime. These repeat checks are not additional
unique test counts.
- Prior verified base `f46b980ef7`: **8/8
real Redis two-process tests passed**, no skips. Two HTTP server
processes shared Redis Streams/cache and LibSQL, with AIMock only at the
model HTTP boundary. Coverage includes cross-server owner
replay/approval/finish, confirmed abort with replay enabled/disabled,
tenant/anonymous/unknown-run denial, parked abort nonconfirmation, and
ownership expiry/cleanup. Candidate core/server builds succeeded;
runtime source maps matched candidate sources.
- Parent review verified independent ancestry and disjoint production
files from the core/Inngest extraction. The changeset-only follow-up
passed package-target/frontmatter validation and `git diff --check`; it
changes no runtime or tests.

## Test-only read-denial follow-up

Current head: `71d868c384`, a +7-line
change confined to
`server-adapters/hono/src/__tests__/run-access-http.test.ts`. Production
sources and existing read grants/write restrictions are unchanged.

- Add a same-resource caller denied `memory:read` and require HTTP
observe **403** for both plain and durable agents.
- Candidate core/server rebuilt; **4/4 real-TCP tests passed**. After
restoring and rebuilding the server following mutation, **4/4 passed**
again.
- Causal mutation: bypass only `MEMORY_READ` thread enforcement while
retaining resource-ownership and write controls. Both new plain/durable
assertions fail with **200 instead of 403**; the two first-model-call
write-control cases still pass. The mutation was removed before
committing.
- Formatting, type-aware lint, Hono `tsc --noEmit` (package config
excludes tests), and `git diff --check` passed.
- The earlier **8/8 Redis two-process proof remains evidence for base
`f46b980ef7` only**; it was not rerun for
this test-only follow-up. Fresh CI for
`71d868c384` is pending.

## Unverified

- Full monorepo CI and eventual combined execution with the
still-in-progress core/Inngest session extraction.
- Hosted Redis, cluster/TLS/failover, production load, real
Inngest/evented authorization, and browser flows were not independently
exercised in this lane.
- Malformed persisted snapshots and existing compatibility fallbacks
were not redesigned.

## Risk

This changes security-sensitive control flow even though route behavior
is intended to remain identical. The shared helper retains the
established READ/WRITE distinction and existing ownership-store
fallbacks rather than introducing new authorization or liveness rules.
Abort confirmation remains a separate operation after authorization.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

The observe and abort routes now use the same rules to check who owns a
run and who can access its thread. Watching needs read permission, while
stopping needs write permission.

## Changes

- Added `authorizeRunAccess` in
`packages/server/src/server/handlers/agents.ts` and used it for both
routes.
- Kept route-specific responses for unknown, finished, and unverifiable
runs.
- Added an agent-handler regression test. It confirms an in-process
owner record alone does not authorize aborting a durable run.
- Added HTTP-over-TCP tests for plain and durable agents. They cover
access permissions, unknown runs, and aborting during a tool call or the
first model call.
- Added a patch changeset for `@mastra/server`.

**Diff:** 4 files changed; 275 lines added and 34 removed.  
**Test results:** The author reports 4/4 real-TCP tests passed. Fresh CI
for the current head is pending.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastra-platform[bot] <mastra-platform[bot]@users.noreply.github.com>
Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-08 09:57:03 -08:00
dane-ai-mastra[bot]
f21e0742ce chore: version packages 2026-11-07 04:18:11 +00:00
mastra-platform[bot]
d6a5f98df3
fix: index observe chunks for resume (COR-1506) (#29520)
> Opened by @user_01KNA8J74D4RF84RXSDRX26BS9

Linear:
[COR-1506](https://linear.app/kepler-crm/issue/COR-1506/observe-offset-cant-be-used-to-resume-it-counts-log-events-but-clients)

## Problem

`observe({ runId, offset })` takes `offset` as a position in the run
log. Clients can't compute that position:
- Some log entries never reach the client. These include
iteration-complete records after every step and ownership markers.
- Updates on the wire carried no index.

A client that resumes at "number of updates received" lands too early
and gets repeated updates. The drift grows by one per completed step, so
every tool-using run that reconnects after its first step is affected.
On a 3-step tool loop, 16 of 28 cut points repeated 1–2 updates on both
durable and evented engines.

## Fix

- **Index on updates:** every update now carries `index`, the run-log
position it came from. This covers:
  - `/observe` on every agent
  - `/stream` on durable and evented agents
- core `stream()`/`observe()` chunks and client-js
`observe()`/`stream()`
- **Resuming:** pass `index + 1` of the last received update that has an
index as `offset`. Gaps in the numbering are expected; they're log
entries that send nothing.
- **Unindexed updates:** the synthesized `abort` update carries no
index. Its log position is on the `finish` sent beside it. Client-built
structured-output `object` chunks have no index either. An
`object-result` logged by a structuring-model run carries one. Unindexed
updates don't move the resume point. A client that reconnects between
`abort` and `finish` gets the `abort` again.
- **`offset` is unchanged:** it still means a run-log position.
- Core no longer strips `index` in
`DurableAgent.__subscribeToRunStream`. The stream adapter and the
server's `toAgentStreamChunks` copy the envelope's index onto each chunk
and drop any index a forwarded sub-agent chunk carried. `index` is
optional on `BaseChunkType` and `DataChunkType`.
- **Also fixed:** on plain agents, `/observe` (HTTP and core
`agent.observe()`) with an offset past the end of a finished run used to
wait for the idle timeout or hang. It now closes immediately. It reads
the log from just before the offset and only falls back to a full read
when that window is empty. The check runs in the background, so it never
delays returning the stream or its cancel handle. A trailing `error`
chunk doesn't count as the end of the run.

## Migration

`index` is a new field and `offset` keeps its meaning:
- Callers that pass a log position need no change.
- Callers that replay from `offset: 0` need no change. They get the same
updates in the same order, now with `index` set.
- Only callers that passed a count of updates received need to change.
They were already getting repeats after step boundaries; switch them to
`index + 1` of the last indexed update.

## Evidence

| Check | Result |
| --- | --- |
| Red/green | With `main`'s core and server, 15 tests on numbering and
`/stream`–`/observe` matching fail; with this change all pass. |
| Cut points | Every cut point of a 3-step tool loop on durable and
evented engines resumes from the first `/stream` connection at last
index + 1. Covers the HTTP route and client-js `stream()` → `observe()`.
|
| `/stream` vs `/observe` match | Frames are identical JSON, including
`index`. Replay from 0 equals the first `/stream`. |
| End of run | Resume after finish or past the end returns the rest and
closes, including far past the end (offset 100). |
| Adapters | Hono 98/98, Fastify 98/98, Express 90 passed + 8 skipped
(see bug 1 below). The shared suite is now wired into Express and
Fastify. |
| Redis restart | Real-Redis split-deploy test (in
`pubsub/redis-streams/src/observe-cross-process.test.ts`) passes on both
engines. The client resumes on a freshly booted API process at last
index + 1 with nothing repeated or missing. Evented: the worker executes
the run and the API is killed with SIGKILL. Durable runs execute in the
API that started them, so that API stays up; the client drops its
connection and resumes on a second API. |
| Suspend | After tool approval, indexes keep increasing. Observers
parked mid-suspend and every cut across the suspend resume correctly on
both engines. |
| Unit suites | server `agents.test.ts` 289, core `src/stream` +
`src/agent/streams` 481 |
| Static | tsc clean on core, server, client-js, the test suite, the
Hono/Express/Fastify adapters and redis-streams. oxlint 0 warnings. |

## Scope

Plain (non-durable) agents' `/stream` updates aren't numbered yet. The
caller receives each update before the cache assigns its number. That's
tracked in COR-1510. Plain agents' `/observe` is covered here.

## Existing bugs found (not fixed here)

1. **Express untilIdle 404:** after a client drops an untilIdle stream
on a durable or evented agent, Express answers `/observe` with 404 "Run
not found". It fails the same way on `main`. Those 8 cases are skipped
on Express only, via `skipUntilIdleDisconnectReplay`.
2. **Finished durable run, other API:** a finished durable run returns
404 on `/observe` from any API process except the one that executed it
(`authorizeDurableRun`, `handlers/agents.ts`). Resuming while the run is
live works from any API.
3. **Plain replay mismatch:** on plain agents, replayed
`step-finish`/`finish` payloads differ from the live ones (for example
`timestamp` and `processorRetryCount`). Related to COR-1510.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

When a connection drops, clients need to know which updates they already
received. This change adds positions to many updates so clients can
resume from the right place. It also closes observations of finished
runs when the requested position is past the end.

## Summary

- Added optional `index` values to chunks from durable and evented agent
streams, `observe()` streams, and corresponding HTTP routes. Clients can
resume by passing the last indexed chunk’s `index + 1`.
- Preserved run-log indexes through core stream adapters and server
frame conversion. Sub-agent data chunks do not carry a child run’s index
into the parent stream.
- Some chunks remain unindexed, including synthesized `abort` chunks and
client-built structured-output `object` chunks. Failed cache writes and
non-atomic custom-cache indexing can affect replay.
- Updated API schemas and documentation to explain index gaps, replay
limits, and resumption.
- Added past-end handling for finished plain-agent observations in core
and HTTP `/observe`. History checks do not delay stream return or
prevent cancellation.
- Added tests for indexed replay, past-end closure, cancellation during
history reads, sub-agent index isolation, and observation across API
restarts.

**Validation:** Current-head CI, build, and test results are not
available.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastra-platform[bot] <mastra-platform[bot]@users.noreply.github.com>
Co-authored-by: mastra-platform[bot] <284800079+mastra-platform[bot]@users.noreply.github.com>
Co-authored-by: NikAiyer <nick.aiyer@gmail.com>
2026-11-06 11:40:46 -08:00
dane-ai-mastra[bot]
675caf0613
chore: version packages (alpha) (#29336)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases

> The changelog information of each package has been omitted from this
message, as the content exceeds the size limit.

## @mastra/client-js@1.60.0-alpha.0


## @mastra/react@1.15.0-alpha.0


## @mastra/factory@0.28.0-alpha.0


## @mastra/code-sdk@1.19.0-alpha.0


## mastra@1.39.0-alpha.0


## @mastra/core@1.83.0-alpha.0


## @mastra/mcp@2.9.0-alpha.0


## @mastra/mcp-apps-components@0.1.0-alpha.0


## @mastra/playground-ui@69.0.0-alpha.0


## @mastra/server@1.83.0-alpha.0


## @mastra/nestjs@0.3.0-alpha.0


## @mastra/clickhouse@1.30.0-alpha.0


## @mastra/duckdb@1.19.0-alpha.0


## @mastra/libsql@1.30.0-alpha.0


## @mastra/pg@1.36.0-alpha.0


## @mastra/temporal@0.6.0-alpha.0


## @mastra/auth-better-auth@1.1.11-alpha.0


## @mastra/deployer-cloud@1.83.0-alpha.0


## @mastra/deployer-cloudflare@1.2.42-alpha.0


## @mastra/deployer-netlify@1.2.42-alpha.0


## @mastra/deployer-sandbox@0.3.27-alpha.0


## @mastra/deployer-vercel@1.2.42-alpha.0


## @mastra/longmemeval@1.1.42-alpha.0


## @mastra/opencode@0.1.42-alpha.0


## create-factory@0.4.3-alpha.0


## mastracode@0.49.1-alpha.0


## @mastra/arize@1.3.30-alpha.0


## @mastra/arthur@0.4.30-alpha.0


## @mastra/braintrust@1.3.27-alpha.0


## @mastra/datadog@1.4.22-alpha.0


## @mastra/deepeval@0.1.24-alpha.0


## @mastra/laminar@1.3.32-alpha.0


## @mastra/langfuse@1.6.6-alpha.0


## @mastra/langsmith@1.4.3-alpha.0


## @mastra/observability@1.23.2-alpha.0


## @mastra/otel-bridge@1.5.22-alpha.0


## @mastra/otel-exporter@1.5.2-alpha.0


## @mastra/posthog@1.4.7-alpha.0


## @mastra/sentry@1.2.32-alpha.0


## @mastra/agent-builder@1.2.1-alpha.0


## @mastra/connect@1.3.2-alpha.0


## create-mastra@1.39.0-alpha.0


## @mastra/deployer@1.83.0-alpha.0


## @mastra/editor@0.17.1-alpha.0


## @mastra/mcp-docs-server@1.3.13-alpha.0


## @mastra/memory@1.41.1-alpha.0


## @mastra/rag@2.7.3-alpha.0


## @mastra/redis-streams@0.8.1-alpha.0


## @mastra/elysia@0.1.23-alpha.0


## @mastra/express@1.5.27-alpha.0


## @mastra/fastify@1.5.27-alpha.0


## @mastra/hono@1.7.25-alpha.0


## @mastra/koa@1.7.27-alpha.0


## @mastra/next@0.2.41-alpha.0


## @mastra/tanstack-start@0.2.41-alpha.0


## @mastra/spanner@1.11.2-alpha.0


## @mastra/turso@0.1.21-alpha.0


## @mastra/inngest@1.11.2-alpha.0


## @mastra/gcs@0.3.6-alpha.0


## @internal/playground@1.39.0-alpha.0

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-04 14:40:27 -08:00
Eric Pinzur
a7c4069df2
fix(observability): require trace IDs on feedback and score POSTs (#29287)
Requires a nonblank `feedback.traceId` and `score.traceId` on the OSS
observability POST endpoints, with `spanId` still optional. Missing,
null, empty, whitespace-only, and span-only requests return 400 before
storage is called. The generated JavaScript client types now require the
trace ID too.

Previously accepted:
```ts
await client.createFeedback({ feedback: { feedbackType: 'thumbs', value: 1 } });
```

Now:
```ts
await client.createFeedback({
  feedback: { traceId: 'trace-123', feedbackType: 'thumbs', value: 1 },
});
await client.createScore({
  score: { traceId: 'trace-123', scorerId: 'accuracy', score: 0.9 },
});
```

This tightens the HTTP/type contract and uses minor changesets for core,
server, and client. Callers that previously omitted the trace ID must
now supply it. It does not add a trace-existence lookup or change
storage/batch APIs, historical nullable records, generated IDs, server
timestamps, or response shapes. The existing React feedback caller
already supplies a trace ID. Documentation describes the required trace
ID and optional span ID. Client types and CLI metadata were regenerated,
with no CLI metadata diff.

Validation: 398 tests pass, including shared real-HTTP regressions
across Hono, Express, Fastify, Koa, and NestJS, plus schema and existing
server/client tests. The new rejection cases failed before the fix with
200 responses. Focused client route-type checks, package builds,
type-aware lint, formatting, and documentation checks pass. The broader
client type suite still reports four errors in
`type-tests/trace-query.test-d.ts`; these were reproduced with the
unchanged main files.

Fixes
[OBS-788](https://linear.app/kepler-crm/issue/OBS-788/require-trace-ids-on-oss-score-and-feedback-posts).
Part of [OBS-792](https://linear.app/kepler-crm/issue/OBS-792); aligns
the required trace-ID contract with
[platform#3752](https://github.com/mastra-ai/platform/pull/3752).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

Feedback and score requests must now identify the trace they belong to.
This prevents new requests without a usable trace ID from being saved,
while older records remain readable.

## Summary

- Require a nonblank `traceId` in feedback and score HTTP POST bodies.
Keep `spanId` optional.
- Reject requests with missing, null, empty, or whitespace-only
`traceId` values before calling storage.
- Keep nullable `traceId` values valid in storage and record schemas so
historical records remain readable.
- Update client request types, documentation, and the CLI score-create
example to include the required `traceId`.
- Add shared HTTP contract tests for the Hono, Express, Fastify, Koa,
and NestJS adapters.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-04 15:25:20 +01:00
mastra-platform[bot]
aa6777693d
feat(core): load storage v2 workflow result steps lazily (#29362)
Co-authored-by: Tony Kovanen <rase-@users.noreply.github.com>
2026-11-04 07:32:39 +01:00
dane-ai-mastra[bot]
6e8dfcb83f chore: version - exit prerelease mode 2026-11-03 23:45:58 +00:00
dane-ai-mastra[bot]
4bc3aa672f
chore: version packages (alpha) (#29255)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases

> The changelog information of each package has been omitted from this
message, as the content exceeds the size limit.

## @mastra/factory@0.27.0-alpha.3


## @mastra/agent-builder@1.2.0-alpha.3


## @mastra/core@1.82.0-alpha.3


## @mastra/mcp@2.8.0-alpha.2


## @mastra/memory@1.41.0-alpha.3


## @mastra/playground-ui@68.0.0-alpha.3


## @mastra/ring-signals@0.1.0-alpha.0


## @mastra/libsql@1.29.0-alpha.2


## @mastra/mongodb@1.26.0-alpha.2


## @mastra/mysql@0.16.0-alpha.3


## @mastra/pg@1.35.0-alpha.3


## @mastra/discord@1.3.3-alpha.0


## @mastra/slack@1.8.1-alpha.0


## @mastra/teams@0.1.4-alpha.0


## @mastra/telegram@0.2.5-alpha.0


## @mastra/client-js@1.59.0-alpha.3


## @mastra/react@1.14.1-alpha.3


## @mastra/deployer-cloud@1.82.0-alpha.3


## @mastra/longmemeval@1.1.41-alpha.3


## @mastra/opencode@0.1.41-alpha.3


## create-factory@0.4.2-alpha.3


## @mastra/code-sdk@1.18.0-alpha.3


## mastracode@0.49.0-alpha.3


## @mastra/arize@1.3.29-alpha.2


## @mastra/arthur@0.4.29-alpha.2


## @mastra/laminar@1.3.31-alpha.2


## @mastra/langfuse@1.6.5-alpha.2


## @mastra/otel-bridge@1.5.21-alpha.2


## @mastra/otel-exporter@1.5.1-alpha.2


## @mastra/sentry@1.2.31-alpha.3


## mastra@1.38.0-alpha.3


## @mastra/connect@1.3.1-alpha.1


## @mastra/deployer@1.82.0-alpha.3


## @mastra/editor@0.17.0-alpha.3


## @mastra/evals@1.10.11-alpha.0


## @mastra/mcp-docs-server@1.3.12-alpha.4


## @mastra/server@1.82.0-alpha.3


## @mastra/elysia@0.1.22-alpha.3


## @mastra/express@1.5.26-alpha.3


## @mastra/fastify@1.5.26-alpha.3


## @mastra/hono@1.7.24-alpha.3


## @mastra/koa@1.7.26-alpha.3


## @mastra/nestjs@0.2.41-alpha.3


## @mastra/next@0.2.40-alpha.3


## @mastra/tanstack-start@0.2.40-alpha.3


## @mastra/turso@0.1.20-alpha.2


## @mastra/inngest@1.11.1-alpha.2


## @mastra/temporal@0.5.0-alpha.3


## create-mastra@1.38.0-alpha.3


## @internal/playground@1.38.0-alpha.3

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-03 13:59:38 -07:00
Dane - AI (Mastra)
47a6cd82e5
chore(deps): update ai sdk (#29242)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-11-03 16:12:54 +01:00
dane-ai-mastra[bot]
886679eb10
chore: version packages (alpha) (#29205)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases

> The changelog information of each package has been omitted from this
message, as the content exceeds the size limit.

## @mastra/client-js@1.59.0-alpha.2


## @mastra/factory@0.27.0-alpha.2


## @mastra/code-sdk@1.18.0-alpha.2


## mastra@1.38.0-alpha.2


## @mastra/core@1.82.0-alpha.2


## @mastra/editor@0.17.0-alpha.2


## @mastra/server@1.82.0-alpha.2


## @mastra/clickhouse@1.29.0-alpha.1


## @mastra/duckdb@1.18.0-alpha.1


## @mastra/pg@1.35.0-alpha.2


## @mastra/platform-workspace@1.12.0-alpha.1


## @mastra/react@1.14.1-alpha.2


## @mastra/deployer-cloud@1.82.0-alpha.2


## @mastra/deployer-sandbox@0.3.26-alpha.1


## @mastra/longmemeval@1.1.41-alpha.2


## @mastra/opencode@0.1.41-alpha.2


## @mastra/parallel@0.1.5-alpha.0


## create-factory@0.4.2-alpha.2


## mastracode@0.49.0-alpha.2


## @mastra/arize@1.3.29-alpha.1


## @mastra/arthur@0.4.29-alpha.1


## @mastra/braintrust@1.3.26-alpha.1


## @mastra/datadog@1.4.21-alpha.1


## @mastra/deepeval@0.1.23-alpha.1


## @mastra/laminar@1.3.31-alpha.1


## @mastra/langfuse@1.6.5-alpha.1


## @mastra/langsmith@1.4.2-alpha.1


## @mastra/observability@1.23.1-alpha.1


## @mastra/otel-bridge@1.5.21-alpha.1


## @mastra/otel-exporter@1.5.1-alpha.1


## @mastra/posthog@1.4.6-alpha.1


## @mastra/sentry@1.2.31-alpha.2


## @mastra/agent-builder@1.1.33-alpha.2


## @mastra/deployer@1.82.0-alpha.2


## @mastra/mcp@2.8.0-alpha.1


## @mastra/mcp-docs-server@1.3.12-alpha.3


## @mastra/memory@1.41.0-alpha.2


## @mastra/playground-ui@68.0.0-alpha.2


## @mastra/rag@2.7.2-alpha.0


## @mastra/elysia@0.1.22-alpha.2


## @mastra/express@1.5.26-alpha.2


## @mastra/fastify@1.5.26-alpha.2


## @mastra/hono@1.7.24-alpha.2


## @mastra/koa@1.7.26-alpha.2


## @mastra/nestjs@0.2.41-alpha.2


## @mastra/next@0.2.40-alpha.2


## @mastra/tanstack-start@0.2.40-alpha.2


## @mastra/dsql@1.5.6-alpha.0


## @mastra/libsql@1.29.0-alpha.1


## @mastra/mongodb@1.26.0-alpha.1


## @mastra/mssql@1.11.1-alpha.0


## @mastra/mysql@0.16.0-alpha.2


## @mastra/oracledb@0.5.6-alpha.0


## @mastra/spanner@1.11.1-alpha.0


## @mastra/turso@0.1.20-alpha.1


## @mastra/voice-google@0.14.5-alpha.0


## @mastra/inngest@1.11.1-alpha.1


## @mastra/temporal@0.5.0-alpha.2


## @mastra/e2b@0.16.1-alpha.1


## create-mastra@1.38.0-alpha.2


## @internal/playground@1.38.0-alpha.2

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-02 20:29:47 -07:00
dane-ai-mastra[bot]
30046969ad
chore: version packages (alpha) (#29146)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`main` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `main`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @mastra/client-js@1.59.0-alpha.1

### Minor Changes

- Added the `aggregateTimeToFirstMeasures` observability capability.
Trace and span aggregate requests for `timeToFirstToken.*` or
`timeToFirstChunk.*` measures now return `501` against stores that can't
compute them, and field discovery omits those measures for such stores.
([#29055](https://github.com/mastra-ai/mastra/pull/29055))

  ```typescript
const { capabilities } = await
mastraClient.getObservabilityCapabilities();

if (capabilities.traceAggregate &&
capabilities.aggregateTimeToFirstMeasures) {
    const { rows } = await mastraClient.aggregateTraces({
timeRange: { from: '2026-08-01T00:00:00.000Z', to:
'2026-08-02T00:00:00.000Z' },
      groupBy: ['entityName'],
      measures: ['timeToFirstChunk.p95', 'timeToFirstChunk.count'],
    });
  }
  ```

### Patch Changes

- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
## @mastra/factory@0.27.0-alpha.1

### Minor Changes

- The same Jira, Linear or incident.io item can now be filed in more
than one Factory project. Before, the first project to file an item held
it for the whole org, and other projects that ingested it got no card.
Each project now keeps its own card. Within a project the card is still
reused when the item is seen again, after the card finishes and when the
issue reopens. A Linear card is also found after the issue's identifier
changes, for example when the issue moves to another team.
([#29059](https://github.com/mastra-ai/mastra/pull/29059))

When intake routing sends an item to a different project, the new
project files its own card and the previous project's card stays where
it is.

  **Breaking changes**

- `claimKey` is removed from the `upsertLinkedWorkItem` decision type.
Rules that still return it, and decisions saved before this release,
keep working: the field is accepted and ignored.
- `WorkItemClaimConflictError`, `getByClaimKey`, `claimWorkItem`,
`releaseProjectClaims` and `WorkItemRow.claimKey` are removed.

  Drop `claimKey` from linked-item decisions your rules return:

  ```ts
  // Before
  return {
    type: 'upsertLinkedWorkItem',
    source: 'jira-issue',
    sourceKey: issue.id,
    claimKey: `jira:issue:${issue.id}` /* … */,
  };

  // After
return { type: 'upsertLinkedWorkItem', source: 'jira-issue', sourceKey:
issue.id /* … */ };
  ```

Remove calls to `getByClaimKey`, `claimWorkItem` and
`releaseProjectClaims`. To find a project's card for an item, use
`getByProjectSource`.

The `claim_key` column stays in the database. Values already stored
there are left in place and no longer affect anything.

### Patch Changes

- Fixed shell commands that exit with a failure code reading as
successful in the Factory transcript. The command now reads as failed
while the run streams, after a dropped stream reconnects, and after a
reload. Stopping a process with `kill_process` still reads as a success.
([#28963](https://github.com/mastra-ai/mastra/pull/28963))

A system reminder that loads project instructions (`AGENTS.md`,
`CLAUDE.md` or `CONTEXT.md`) now reads "Project instructions" and names
the file by its path in the working directory, such as
`packages/core/AGENTS.md`, instead of a bare "System reminder".

- A board tool rule that moves a work item back into its current stage
with `reenter: true` now runs that stage's entry rules, as documented.
Previously the entry rules were skipped, so no new agent run started.
([#29104](https://github.com/mastra-ai/mastra/pull/29104))

- Updated dependencies
[[`5735a50`](5735a50c6c),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/platform-workspace@1.11.1-alpha.0
  - @mastra/core@1.82.0-alpha.1
  - @mastra/code-sdk@1.18.0-alpha.1
## @mastra/core@1.82.0-alpha.1

### Minor Changes

- Added time to first token and time to first chunk measures to trace
and span aggregates, so dashboards can chart streaming latency next to
duration. ([#29055](https://github.com/mastra-ai/mastra/pull/29055))

The new measures are `timeToFirstToken.avg`, `.min`, `.max`, `.p50`,
`.p90`, `.p95`, `.p99`, and `.count`, plus the same set for
`timeToFirstChunk`. Traces and spans without a recorded value are
skipped instead of counted as 0, and `.count` reports how many had one.
Stores opt in through the `aggregate-time-to-first-measures` feature.

### Patch Changes

- Fixed durable agents (`durable: true`) ending the `model_generation`
trace span without `responseId` and `responseModel`. Durable runs now
record the provider's response id and model on the span, the same as
non-durable agents, so a trace can be linked back to the provider's own
response log. Fixes #29053.
([#29180](https://github.com/mastra-ai/mastra/pull/29180))

- Fixed metadata filters in the in-memory store returning records whose
nested metadata had different keys from the filter when one side
contained an `undefined` value.
([#29101](https://github.com/mastra-ai/mastra/pull/29101))

- Fixed directly resumed nested workflows in the evented engine so they
continue suspended parent runs.
([#25979](https://github.com/mastra-ai/mastra/pull/25979))
## @mastra/playground-ui@68.0.0-alpha.1

### Minor Changes

- Toolbar and filter bar controls now share one look: the same paddings,
icon gaps, chevron and spacing between controls.
([#28818](https://github.com/mastra-ai/mastra/pull/28818))

**Time range.** A filter bar's time range is now the
`DateTimeRangePicker` itself, so it looks and behaves the same on every
page: a calendar icon, the range and a chevron, with no separate "Time"
label. Pass `defaultPreset` to show a × that resets a custom range; it
replaces the chevron while a custom range is applied.

Added `FilterBar.TimeRange` with `FILTER_BAR_TIME_RANGE_FIELD`,
`FILTER_BAR_TIME_RANGE_ITEM` and `FILTER_BAR_TIME_RANGE_FIELD_ID`. They
replace `TraceTimeRangeChip` and the `TRACE_TIME_RANGE_*` names from
`domains/traces/components/trace-time-range-chip`, which are removed.

  ```tsx
  import {
    FilterBar,
    FILTER_BAR_TIME_RANGE_FIELD,
    FILTER_BAR_TIME_RANGE_FIELD_ID,
    FILTER_BAR_TIME_RANGE_ITEM,
  } from '@mastra/playground-ui/components/FilterBar';

  <FilterBar
    fields={[FILTER_BAR_TIME_RANGE_FIELD, ...fields]}
    operators={operators}
    value={[FILTER_BAR_TIME_RANGE_ITEM, ...items]}
// The time range item is synthetic: keep it out of the stored filters.
onValueChange={next => setItems(next.filter(item => item.fieldId !==
FILTER_BAR_TIME_RANGE_FIELD_ID))}
  >
    <FilterBar.Chips
      renderChip={item =>
        item.fieldId === FILTER_BAR_TIME_RANGE_FIELD_ID ? (
          <FilterBar.TimeRange
            preset={preset}
// A preset, including the × reset, drops the applied custom dates.
            onPresetChange={next => {
              setPreset(next);
              if (next !== 'custom') setRange({});
            }}
            dateFrom={range.from}
            dateTo={range.to}
            onDateRangeChange={(from, to) => setRange({ from, to })}
            defaultPreset="last-7d"
          />
        ) : (
          <FilterBar.Chip item={item} />
        )
      }
    />
    <FilterBar.Input />
  </FilterBar>;
  ```

`DateTimeRangePicker` gains `size`, `defaultPreset` and `ref` (the
trigger button).

  **Migrating removed APIs.**

- `TraceTimeRangeChip` → `FilterBar.TimeRange` (same props), and
`TRACE_TIME_RANGE_FIELD` / `_ITEM` / `_FIELD_ID` →
`FILTER_BAR_TIME_RANGE_FIELD` / `_ITEM` / `_FIELD_ID`, imported from
`@mastra/playground-ui/components/FilterBar`.

    ```tsx
    // Before
import { TraceTimeRangeChip, TRACE_TIME_RANGE_FIELD_ID } from
'@mastra/playground-ui/domains/traces/components/trace-time-range-chip';
item.fieldId === TRACE_TIME_RANGE_FIELD_ID ? <TraceTimeRangeChip
preset={preset} onPresetChange={setPreset} /> : …

    // After
import { FilterBar, FILTER_BAR_TIME_RANGE_FIELD_ID } from
'@mastra/playground-ui/components/FilterBar';
item.fieldId === FILTER_BAR_TIME_RANGE_FIELD_ID ? <FilterBar.TimeRange
preset={preset} onPresetChange={setPreset} /> : …
    ```

- `DateTimeRangePicker`'s `renderTrigger` → remove it: the trigger is
always the shared calendar button. Pass `size` for another rung and
`ref` to reach the trigger.
- `comboboxStyles.chevron` on a hand-built trigger → `<ButtonChevron
size={size} />` from `@mastra/playground-ui/components/Button`.

  **Other controls.**

- Added `ClearFiltersButton`, a round reset icon button with a tooltip,
used for every toolbar's "clear filters".
- Added `TriggerChevron` and `ButtonChevron`, the one chevron every
dropdown trigger (`Select`, `Combobox`, the date picker) shows.
  - `ComboboxTrigger` uses that chevron instead of the up-down one.
- Icons in every interactive control (buttons, fields, search inputs,
filter chips, menu and command rows) follow one rule: muted at rest,
brighter on hover. Two new theme tokens, `--control-icon-rest` and
`--control-icon-hover`, set those colours; menus retune them, and
icon-only controls always brighten. Search fields and combobox fields
now brighten their icons on hover like buttons do.
- Icons take their size from the control they sit in, as in a Button:
filter chips and search inputs no longer size their own icons.
- `ListSearch` defaults to the `sm` toolbar size, and `SearchInput`'s
icon sits at the same inset as a button's.
  - `ActionRow` and `FilterBar` space their controls 6px apart.

### Patch Changes

- Updated dependencies
[[`489d829`](489d8295c8),
[`0900c20`](0900c20592),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`e1e64f0`](e1e64f072c),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/memory@1.41.0-alpha.1
  - @mastra/client-js@1.59.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
  - @mastra/ai-sdk@1.11.3
  - @mastra/react@1.14.1-alpha.1
## @mastra/server@1.82.0-alpha.1

### Minor Changes

- Added the `aggregateTimeToFirstMeasures` observability capability.
Trace and span aggregate requests for `timeToFirstToken.*` or
`timeToFirstChunk.*` measures now return `501` against stores that can't
compute them, and field discovery omits those measures for such stores.
([#29055](https://github.com/mastra-ai/mastra/pull/29055))

  ```typescript
const { capabilities } = await
mastraClient.getObservabilityCapabilities();

if (capabilities.traceAggregate &&
capabilities.aggregateTimeToFirstMeasures) {
    const { rows } = await mastraClient.aggregateTraces({
timeRange: { from: '2026-08-01T00:00:00.000Z', to:
'2026-08-02T00:00:00.000Z' },
      groupBy: ['entityName'],
      measures: ['timeToFirstChunk.p95', 'timeToFirstChunk.count'],
    });
  }
  ```

### Patch Changes

- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
## @mastra/clickhouse@1.29.0-alpha.0

### Minor Changes

- Added support for `timeToFirstToken.*` and `timeToFirstChunk.*`
measures in trace and span aggregates. Rows without a recorded value are
skipped, never counted as 0.
([#29055](https://github.com/mastra-ai/mastra/pull/29055))

  ```typescript
  import { planSpanAggregate } from '@mastra/core/storage';

  const observability = await storage.getStore('observability');

if
(observability?.getFeatures().includes('aggregate-time-to-first-measures'))
{
    const { rows } = await observability.aggregateSpans(
      planSpanAggregate({
timeRange: { from: '2026-08-01T00:00:00.000Z', to:
'2026-08-02T00:00:00.000Z' },
where: { op: 'eq', left: { path: 'spanType' }, right: { literal:
'model_inference' } },
        measures: ['timeToFirstToken.p50', 'timeToFirstToken.p95'],
      }),
    );
  }
  ```

### Patch Changes

- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
## @mastra/duckdb@1.18.0-alpha.0

### Minor Changes

- Added support for `timeToFirstToken.*` and `timeToFirstChunk.*`
measures in trace and span aggregates. Rows without a recorded value are
skipped, never counted as 0.
([#29055](https://github.com/mastra-ai/mastra/pull/29055))

  ```typescript
  import { planSpanAggregate } from '@mastra/core/storage';

  const observability = await storage.getStore('observability');

if
(observability?.getFeatures().includes('aggregate-time-to-first-measures'))
{
    const { rows } = await observability.aggregateSpans(
      planSpanAggregate({
timeRange: { from: '2026-08-01T00:00:00.000Z', to:
'2026-08-02T00:00:00.000Z' },
where: { op: 'eq', left: { path: 'spanType' }, right: { literal:
'model_inference' } },
        measures: ['timeToFirstToken.p50', 'timeToFirstToken.p95'],
      }),
    );
  }
  ```

### Patch Changes

- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
## @mastra/pg@1.35.0-alpha.1

### Minor Changes

- Added support for `timeToFirstToken.*` and `timeToFirstChunk.*`
measures in trace and span aggregates. Rows without a recorded value are
skipped, never counted as 0.
([#29055](https://github.com/mastra-ai/mastra/pull/29055))

  ```typescript
  import { planSpanAggregate } from '@mastra/core/storage';

  const observability = await storage.getStore('observability');

if
(observability?.getFeatures().includes('aggregate-time-to-first-measures'))
{
    const { rows } = await observability.aggregateSpans(
      planSpanAggregate({
timeRange: { from: '2026-08-01T00:00:00.000Z', to:
'2026-08-02T00:00:00.000Z' },
where: { op: 'eq', left: { path: 'spanType' }, right: { literal:
'model_inference' } },
        measures: ['timeToFirstToken.p50', 'timeToFirstToken.p95'],
      }),
    );
  }
  ```

### Patch Changes

- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
## @mastra/react@1.14.1-alpha.1

### Patch Changes

- Updated dependencies
[[`0900c20`](0900c20592),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/client-js@1.59.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
## @mastra/deployer-cloud@1.82.0-alpha.1

### Patch Changes

- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
  - @mastra/deployer@1.82.0-alpha.1
## @mastra/longmemeval@1.1.41-alpha.1

### Patch Changes

- Updated dependencies
[[`489d829`](489d8295c8),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`e1e64f0`](e1e64f072c),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/memory@1.41.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
  - @mastra/libsql@1.29.0-alpha.0
## @mastra/opencode@0.1.41-alpha.1

### Patch Changes

- Updated dependencies
[[`489d829`](489d8295c8),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`e1e64f0`](e1e64f072c),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/memory@1.41.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
  - @mastra/libsql@1.29.0-alpha.0
## create-factory@0.4.2-alpha.1

### Patch Changes

- Updated dependencies:
  - mastra@1.38.0-alpha.1
## @mastra/code-sdk@1.18.0-alpha.1

### Patch Changes

- Updated dependencies
[[`489d829`](489d8295c8),
[`0900c20`](0900c20592),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`e1e64f0`](e1e64f072c),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/memory@1.41.0-alpha.1
  - @mastra/client-js@1.59.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
  - @mastra/pg@1.35.0-alpha.1
  - @mastra/duckdb@1.18.0-alpha.0
  - @mastra/libsql@1.29.0-alpha.0
## mastracode@0.49.0-alpha.1

### Patch Changes

- Updated dependencies
[[`489d829`](489d8295c8),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`e1e64f0`](e1e64f072c),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/memory@1.41.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
  - @mastra/pg@1.35.0-alpha.1
  - @mastra/duckdb@1.18.0-alpha.0
  - @mastra/code-sdk@1.18.0-alpha.1
  - @mastra/libsql@1.29.0-alpha.0
## @mastra/sentry@1.2.31-alpha.1

### Patch Changes

- dependencies updates:
([#29123](https://github.com/mastra-ai/mastra/pull/29123))
- Updated dependency [`@sentry/node@^11.10.0`
↗︎](https://www.npmjs.com/package/@sentry/node/v/11.10.0) (from
`^10.76.2`, in `dependencies`)
- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
## @mastra/agent-builder@1.1.33-alpha.1

### Patch Changes

- Updated dependencies
[[`489d829`](489d8295c8),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`e1e64f0`](e1e64f072c),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/memory@1.41.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
## mastra@1.38.0-alpha.1

### Patch Changes

- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
  - @mastra/deployer@1.82.0-alpha.1
## @mastra/deployer@1.82.0-alpha.1

### Patch Changes

- Updated dependencies
[[`0900c20`](0900c20592),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/server@1.82.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
## @mastra/editor@0.16.7-alpha.1

### Patch Changes

- Updated dependencies
[[`489d829`](489d8295c8),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`e1e64f0`](e1e64f072c),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/memory@1.41.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
## @mastra/mcp-docs-server@1.3.12-alpha.2

### Patch Changes

- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
## @mastra/memory@1.41.0-alpha.1

### Patch Changes

- dependencies updates:
([#29124](https://github.com/mastra-ai/mastra/pull/29124))
- Updated dependency [`diff@^9.0.0`
↗︎](https://www.npmjs.com/package/diff/v/9.0.0) (from `^8.0.4`, in
`dependencies`)

- Observational Memory now tells the Observer who sent each user signal.
In a thread shared by several people, messages sent with
`agent.sendMessage({ contents, attributes: { name: 'Alice' } }, ...)`
are labeled `User (name="Alice")` when observed, so observations can say
who said what instead of attributing everything to "User". Messages
without attributes keep the plain `User` label.
([#29176](https://github.com/mastra-ai/mastra/pull/29176))

- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
## @mastra/google-cloud-pubsub@1.1.7-alpha.0

### Patch Changes

- dependencies updates:
([#29113](https://github.com/mastra-ai/mastra/pull/29113))
- Updated dependency [`@google-cloud/pubsub@^6.3.1`
↗︎](https://www.npmjs.com/package/@google-cloud/pubsub/v/6.3.1) (from
`^5.3.1`, in `dependencies`)
- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
## @mastra/elysia@0.1.22-alpha.1

### Patch Changes

- Updated dependencies
[[`0900c20`](0900c20592),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/server@1.82.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
## @mastra/express@1.5.26-alpha.1

### Patch Changes

- Updated dependencies
[[`0900c20`](0900c20592),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/server@1.82.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
## @mastra/fastify@1.5.26-alpha.1

### Patch Changes

- Updated dependencies
[[`0900c20`](0900c20592),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/server@1.82.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
## @mastra/hono@1.7.24-alpha.1

### Patch Changes

- Updated dependencies
[[`0900c20`](0900c20592),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/server@1.82.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
## @mastra/koa@1.7.26-alpha.1

### Patch Changes

- Updated dependencies
[[`0900c20`](0900c20592),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/server@1.82.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
## @mastra/nestjs@0.2.41-alpha.1

### Patch Changes

- Updated dependencies
[[`0900c20`](0900c20592),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/server@1.82.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
## @mastra/next@0.2.40-alpha.1

### Patch Changes

- Updated dependencies
[[`0900c20`](0900c20592),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/server@1.82.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
  - @mastra/hono@1.7.24-alpha.1
## @mastra/tanstack-start@0.2.40-alpha.1

### Patch Changes

- Updated dependencies
[[`0900c20`](0900c20592),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/server@1.82.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
  - @mastra/hono@1.7.24-alpha.1
## @mastra/mysql@0.16.0-alpha.1

### Patch Changes

- Fixed experiment result writes putting plaintext back over a purged
dataset item. When a purge committed while a result was being written,
the writer could miss the purge marker and overwrite the redacted input,
output, ground truth, error and metadata.
([#29106](https://github.com/mastra-ai/mastra/pull/29106))

- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
## @mastra/inngest@1.11.1-alpha.0

### Patch Changes

- Fixed `InngestRun.watch()` crashing the process with an unhandled
rejection when the Inngest realtime subscription fails to connect (for
example `fetch failed` or a WebSocket error). The failure is now logged
as a warning and the run still completes through polling. Unwatching now
also closes the realtime connection instead of leaving it open.
([#29103](https://github.com/mastra-ai/mastra/pull/29103))

- Fixed Inngest durable agents ending the `model_generation` trace span
without `responseId` and `responseModel`. The span now carries the
provider's response id and model, the same as non-durable agents. Fixes
#29053. ([#29180](https://github.com/mastra-ai/mastra/pull/29180))

- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
## @mastra/temporal@0.5.0-alpha.1

### Patch Changes

- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
  - @mastra/deployer@1.82.0-alpha.1
## @mastra/e2b@0.16.1-alpha.0

### Patch Changes

- dependencies updates:
([#27993](https://github.com/mastra-ai/mastra/pull/27993))
- Updated dependency [`e2b@^2.62.0`
↗︎](https://www.npmjs.com/package/e2b/v/2.62.0) (from `^2.61.0`, in
`dependencies`)
- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
## @mastra/e2b-desktop@0.1.12-alpha.0

### Patch Changes

- dependencies updates:
([#27993](https://github.com/mastra-ai/mastra/pull/27993))
- Updated dependency [`e2b@^2.62.0`
↗︎](https://www.npmjs.com/package/e2b/v/2.62.0) (from `^2.61.0`, in
`dependencies`)
- Updated dependencies
[[`5735a50`](5735a50c6c),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/e2b@0.16.1-alpha.0
  - @mastra/core@1.82.0-alpha.1
## @mastra/platform-workspace@1.11.1-alpha.0

### Patch Changes

- dependencies updates:
([#27993](https://github.com/mastra-ai/mastra/pull/27993))
- Updated dependency [`e2b@^2.62.0`
↗︎](https://www.npmjs.com/package/e2b/v/2.62.0) (from `^2.61.0`, in
`dependencies`)
- Updated dependencies
[[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/core@1.82.0-alpha.1
## create-mastra@1.38.0-alpha.1


## @internal/playground@1.38.0-alpha.1

### Patch Changes

- Updated dependencies
[[`0900c20`](0900c20592),
[`8751dd7`](8751dd7f56),
[`682e8f3`](682e8f3e44),
[`3314289`](33142896c1),
[`0900c20`](0900c20592),
[`ebf8a9a`](ebf8a9a137)]:
  - @mastra/client-js@1.59.0-alpha.1
  - @mastra/core@1.82.0-alpha.1
  - @mastra/playground-ui@68.0.0-alpha.1
  - @mastra/react@1.14.1-alpha.1

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-02 16:03:13 +01:00
Daniel Lew
0900c20592
feat(observability): time to first token and chunk measures in trace and span aggregates (#29055)
Part of OBS-773

## What

`aggregateTraces()` and `aggregateSpans()` can now compute streaming
latency, not just duration. Adds 16 measures:

- `timeToFirstToken.{avg,min,max,p50,p90,p95,p99,count}`
- `timeToFirstChunk.{avg,min,max,p50,p90,p95,p99,count}`

Previously `timeToFirstTokenMs` / `timeToFirstChunkMs` could be filtered
and sorted in `queryTraces()` but not charted or compared across groups.

## Semantics

- **Traces** read the root span's value, the same value `queryTraces()`
returns. An agent run copies both values from the first model generation
of its own loop, so trace TTFC is measured from the agent run's start
(includes input processors, memory recall, etc.). Workflow-rooted traces
have neither value and contribute nothing.
- **Spans** read each span's own value. Filter `spanType` to
`model_generation` for per-model-call latency or `agent_run` for
caller-perceived latency.
- **Nulls are skipped, never read as 0.** `avg`/`min`/`max`/percentiles
are `null` for a group with no values; `.count` is the number of rows
that have one. `having` / `orderBy` follow the existing null rules (null
fails comparisons, sorts last).
- Percentiles are approximate where `duration.p*` already is (ClickHouse
`quantileDeterministic`, seeded the same way).

## Gating

- New store feature `aggregate-time-to-first-measures`, declared by
`@mastra/pg`, `@mastra/clickhouse`, `@mastra/duckdb` only when the
installed core has the measures.
- New server capability `aggregateTimeToFirstMeasures`.
- Against a store without the feature, a request using any of these
measures returns `501` (`TRACE_AGGREGATE_UNSUPPORTED` /
`SPAN_AGGREGATE_UNSUPPORTED`) before storage runs, and field discovery
omits them.

## Out of scope / follow-ups

- **Experiments**: recording/summarizing TTFT/TTFC per experiment item
and showing it on the compare page is a follow-up.
- **Platform mobs-query** support (and its benchmark) lands in a
separate Platform PR after a snapshot of this one.

## Test plan

- Core registry/planner unit tests: measure list, rules, approximate
flags, `having`/`orderBy` on new measures.
- Shared conformance cases (fixtures with mixed present/absent values, a
superseded root copy carrying outlier values to prove dedup, percentiles
with tolerance, groups with no values → null/0, ordering of null groups)
run against:
  - DuckDB: `stores/duckdb` `src/storage` — 554/554
  - PostgreSQL: `index.vnext.test.ts` — 276/276
  - ClickHouse: `v-next` — 726 passed, 1 skipped
- Server: 501 for each new measure on stores without the feature,
success with it, capability derivation, discovery filtering.
- `@mastra/client-js` route types regenerated and typechecked.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

This PR lets trace and span reports show how long it takes to produce
the first token or chunk. Supported storage systems can calculate these
measures; unsupported systems tell clients that the measures are
unavailable.

## Summary

- Adds average, minimum, maximum, p50, p90, p95, p99, and count measures
for `timeToFirstToken` and `timeToFirstChunk` in `aggregateTraces()` and
`aggregateSpans()`.
- Trace measures use root-span values. Span measures use each span’s own
values.
- Calculations skip null values. Groups without values return `null` for
statistical measures and `0` for counts.
- PostgreSQL, ClickHouse, and DuckDB advertise support when the core
measure registry provides the required measures.
- Adds the `aggregateTimeToFirstMeasures` server capability. When a
store lacks support, the server returns `501` for requests using these
measures and omits them from field discovery.

## Testing

The PR description reports passing tests for DuckDB (554/554),
PostgreSQL (276/276), and ClickHouse (726 passed, 1 skipped). It also
reports tests for capability gating and field discovery, plus
regenerated and typechecked `@mastra/client-js` route types.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-11-02 15:35:38 +01:00
dane-ai-mastra[bot]
eed9cc214e chore: version packages 2026-11-01 04:20:58 +00:00
Tyler Barnes
ba602f5f46
feat(server): read-only Knowledge routes and client methods so Studio can browse a Knowledge instance (#29069)
Replaces #28363, which the triage bot closed.

> Stacked on #28362 (core Knowledge page readers), which is stacked on
#28361 (shared Knowledge explorer UI), on the Knowledge alpha branch
(#28353). Experimental: depends on the alpha's schema-4 page store.

## What this adds

**Read-only Knowledge routes in `@mastra/server`**, opt-in via
`KNOWLEDGE_ROUTES`:

| Route | Returns |
| - | - |
| `GET /knowledge` | Instances the caller can read |
| `GET /knowledge/:key/tree` | Root scopes, or child scopes and pages
under `parentId` (paged) |
| `GET /knowledge/:key/pages/:pageId` | Page with ancestors, notes, pin,
referenced pages, mentioned-by |
| `GET /knowledge/:key/graph` | Bounded page graph with parent and
mention edges |
| `GET /knowledge/:key/search` | Pages and notes matching a query |
| `GET /knowledge/:key/activity` | Recent changes, optionally per scope
or page |

Matching `listKnowledge()` / `getKnowledge(key)` methods in
`@mastra/client-js`.

**A Knowledge page in Studio**: page tree beside the graph with synced
selection, a detail pane for the selected page, search, and a Tree/Graph
toggle below 1024px. When the routes aren't registered the page explains
how to enable them.

## Access model

What a caller reads depends on whether the app configures auth
(`server.auth` or `studio.auth`).

- **No auth** (a local or test project): the routes read the whole
instance (`read: 'all'`).
- **Auth:** the routes read only what the signed-in caller can read. The
app maps the user to Knowledge principals in `authorize` by setting the
reserved request-context key `MASTRA_KNOWLEDGE_PRINCIPALS_KEY` (or
`'all'` for an admin). The instance resolves them with `readScopeFor`,
and every reader gets the resulting read scope. A caller with no mapping
gets 403. A malformed mapping, or a principal that matches no declared
scope type, returns 500 because it's a host configuration error.

On top of that: `knowledge:read`, and with FGA, per-instance checks
keyed by the registered Knowledge key (`GET /knowledge` filtered, other
routes 403 for other instances).

## Known limits

- `GET /knowledge` has no route FGA metadata, like every other list
route (`GET /agents`, `/workflows`, `/tools`), so
`requireForProtectedRoutes` refuses it and `auditProtectedRoutes` lists
it; the handler still filters instances per caller.

This replaces the earlier caller-supplied scope tags and
`MASTRA_KNOWLEDGE_SCOPE_KEY` binding. The `authorize` context change
from that work stays (adapters now expose `requestContext` to
`authorize`, and Elysia keeps repeated query values).

## Tests

- Server suite 3,098 passed; permission generator check passes.
- Shared adapter suite (`knowledge-routes`) on Hono, Express, Fastify,
Koa, Elysia: 200 with `knowledge:read`, 403 without, 401 with no token,
repeated `scopeId` honoured.
- Studio page MSW tests 10/10; 7 of them fail against the previous
scope-form page.
- Playground and server `tsc` clean; oxlint clean.




<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

This PR lets Studio browse Knowledge data without changing it. It adds
optional server routes, matching client methods, and a Studio page to
view and search that data.

## What changed

- Added opt-in, read-only Knowledge routes for listing instances,
browsing trees and pages, viewing graphs, searching, reading activity,
and receiving change events. These routes are not mounted by default.
- Added `MastraClient.listKnowledge()` and
`MastraClient.getKnowledge(key)`, plus Knowledge methods for read
requests and event streams.
- Added a Studio Knowledge page with instance selection, tree and graph
views, page details, search, and live updates. Polling is the fallback
when streaming is unavailable.
- Added `knowledge:read` permission handling and auth-based access
controls. When auth is configured, the host must map callers to
Knowledge principals.
- Updated route tooling to include opt-in routes. Updated the Elysia
adapter to preserve repeated query parameters and authorization context
handling so `authorize` can access `requestContext` and `mastra`.
- Added documentation, changesets, and tests for Knowledge routes,
client methods, Studio behavior, and server adapters.

## Tests

The PR description reports 3,098 server tests and 10/10 Studio MSW tests
passing. It also reports that the permission-generator check, Playground
and server TypeScript checks, and oxlint completed cleanly.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: remy-builder[bot] <324360501+remy-builder[bot]@users.noreply.github.com>
Co-authored-by: avis-reader[bot] <332681745+avis-reader[bot]@users.noreply.github.com>
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-30 23:38:07 -07:00
dane-ai-mastra[bot]
77076a1012 chore: version - exit prerelease mode 2026-10-30 23:02:25 +00:00
dane-ai-mastra[bot]
582ef17a2b
chore: version packages (alpha) (#28888)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-30 14:56:53 -07:00
Daniel Lew
b89557e0cc
Group span aggregates by model and provider (#28908)
Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-30 11:22:10 -07:00
Daniel Lew
80f2f21133
feat: show MCP tasks in Studio (server Tasks panel and tool-call task chip) (#28629)
> **Targets `main`.** #28343, #28521, and #28619, which this builds on,
are merged, so the diff shows only the Studio work.

## What this adds

MCP servers with `tasks` enabled run some tool calls (and, with the
workflows/agents PR, `run_<workflow>` / `ask_<agent>` calls) as
long-running MCP tasks. Until now Studio showed nothing about them: the
server page didn't say which tools run as tasks or list any tasks, and a
chat tool-call card for a task-backed tool showed only the final result,
with no task id, status or running time.

**Server page (`/mcps/:serverId`)**
- Tools list gets a **Task** column: `always` / `auto`, `required` when
clients without task support are refused for that tool, and `recover`
when the call is retried after a restart.
- New **Tasks** panel: surface, status, created, updated, expiry, open
input requests, a short task key and the **client** that sent the task.
It refreshes every 2s while any task is still running.
- Filter by status, surface or client (filters live in the URL).
Clicking a client in a row filters to that client, so you can see which
client's tasks keep failing.
  - Shows 50 tasks at a time with **Load more** for older ones.
- **Find by MCP task id**: paste the id a client shows (e.g. from the
chat chip) to open that task.
- Opening a task shows its metadata and result or error. You can answer
an `elicitation/create` request with a form built from its
`requestedSchema`: Accept is the primary action, Decline the secondary
one. Cancel task is a quieter red action below the form. Other input
methods are shown read-only.

**Chat tool-call card**
- A chip `task · working · 0:42` → `completed` / `failed` / `cancelled`,
with a button that copies the **MCP** task id. The Mastra
background-task id is a different id.

## How it's built

The layering is the same as the MCP events Studio PR: core contract →
`@mastra/mcp` → `@mastra/server` → `@mastra/client-js` → Studio.

- **`@mastra/core`**: experimental, optional `getTasksInfo()` /
`getTasksInspector()` on `MCPServer`, the same pattern as
`getEventsInfo` / `getEventsInspector`. Each task surface reports its
own `mode`, `required`, `recover` and `ttlMs`. Nothing new goes into
`tools/list` or onto the wire.
- **`@mastra/mcp`**: the protocol store still can't list tasks. A
separate optional `MCPTaskStoreAdmin` (`list`, `updateByKey`,
`cancelByKey`) is keyed by the stored task key, which is a hash of the
task id. `get/update/cancel` now go through the same key-based paths, so
Studio's cancel and answer run the exact code that `tasks/cancel` and
`tasks/update` run, with the same fencing and persist-before-ack. The
in-memory and background-task stores implement it. Custom stores that
don't implement it get "this store can't be listed". The MCP client
writes an `mcp-task` progress entry (`MCPTaskProgress`) to the tool's
output stream when the task is created and on each status change.
- **`@mastra/server`**:
- `GET /mcp/:serverId/tasks`: newest first, `limit` 50 by default and at
most 200; filters `status`, `surface`, `client` (the hashed client key)
and `key`; returns `nextCursor` for the next page. The background-task
store pushes surface, client and key into its query; status is checked
after reading, because an expired running row reads as failed.
- `POST /mcp/:serverId/tasks/find`: body `{ taskId }`, hashed on the
server, so raw ids never land in URLs or access logs
  - `POST /mcp/:serverId/tasks/:taskKey/cancel`
  - `POST /mcp/:serverId/tasks/:taskKey/input`
  - `tasks_capability` on server list/detail.
- **`@mastra/client-js`**: `getMcpServerTasks` (filters + cursor),
`findMcpServerTask`, `cancelMcpServerTask`, `answerMcpServerTaskInput`.

### Access and privacy
- Responses carry hashed task keys, hashed caller keys and, since #28521
(`ebcfb2bbe96`), the caller's `clientLabel`: client id plus token
subject or user id, or plus a short prefix of the token's hash for
token-only callers. The label is never a credential and is never used to
authorize. Raw task ids and tokens never reach Studio. The client filter
matches the hashed key, not the label. Tasks stored before labels
existed show a short form of the key.
- Only operators see this view: the routes need Mastra auth,
resource-scoped sessions get nothing, and MCP itself has no list method.
- **Permissions:** listing and finding tasks need `mcp:read` (same model
as `/background-tasks`). Cancelling and answering need `mcp:write`,
because they act on another client's task. With the default roles,
`admin` can act on tasks, while `member` and `viewer` can only see them.
Studio hides Cancel, Accept and Decline for users without `mcp:write`
and says why.
- Since #28521 (`19dbb7732b0`), task rows store only a hash of the
caller's principal, so neither the store nor `/background-tasks` holds
the raw principal.
- **Resource-scoped Studio sessions fail closed.** They get no list and
a 404 on cancel/answer, because Mastra resource ids and MCP principals
have no defined mapping. Only unscoped sessions see a server's tasks.
- Unknown or expired keys return 404.

### Known limits
- **The chip's task id is live-only.** Progress isn't saved with the
thread, so a reloaded thread shows only the final result.
- **Deferred calls:**
- Background-task progress and completion chunks don't reach the
tool-call card after the chat turn ends.
- The server-side SSE has them, but the thread stream never delivers
them to the browser. This looks like an existing stream/association gap
and isn't fixed here.
- The chip works around it: until progress shows the task ended, it
polls `GET /background-tasks/:id` to learn how the task ended.
- The agent still quotes the Mastra background-task id in its reply.
Changing what the model is told is out of scope.
- Answering client-side `inputRequests` from chat is out of scope.

## Test plan
- `@mastra/mcp`:
- admin contract suite against both stores: list, filters (status,
surface, client, key), cursor paging over every task exactly once,
idempotent cancel/answer, cross-principal, raw id rejected;
- inspector `find` by raw id (a task key or unknown id finds nothing)
and `clientLabel` on listed tasks for both stores;
- the background store fills a full page even when newer rows can't be
read as tasks;
- `getTasksInfo` / `getTasksInspector` on `MCPServer`, checking that
`tools/list` doesn't change;
  - client `onStatus` and progress writes.
- All existing 3c task tests are green before and after the `*ByKey`
refactor.
- `@mastra/server`: handler tests for `tasks_capability`, unscoped list,
default limit and `nextCursor`, filters and cursor passed to the store,
unknown status rejected, limit cap, `clientLabel` kept, find by raw id
(id only in the body, 404 for unknown/scoped/not listable), scoped
callers failing closed (an empty-string resource id is also treated as
scoped), not-listable stores, and 404s. A mutation check confirmed the
scoping tests fail without the guard.
- `@mastra/client-js`: request shapes, including key URL-encoding,
filter/cursor query and the find body.
- Studio:
- MSW tests for the Tasks panel (every status, empty, not listable,
resource scoped, live refresh, cancel, answer form, Load more, URL
status filter, click-a-client filter showing its label, no-match state,
find by id (opens the task / says not found), drawer client label, tool
Task column with `required` per tool);
- chip tests (live progress, terminal states, polling the background
task for deferred calls, `readToolPart`).
  - Mutation checks confirmed the key tests fail without the change.
- Manual, in the showcase app:
- answering an elicitation and cancelling from the drawer both drive the
task to its end state;
- the chip goes from `working` to `completed · 0:12` on a live deferred
`slow_report`.
- Lint passes for every touched package, and typecheck passes for core,
mcp, client-js, playground-ui and playground. `@mastra/server` typecheck
shows only an existing `@mastra/agent-builder` resolution error.

## Screenshots

**Before: server page, no task information**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-before-server-mcp.png"
alt="Before: server page, no task information" width="720">

**Before: tool card shows only the result**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-before-client-slow-report-completed.png"
alt="Before: tool card shows only the result" width="720">

**After: Task column per surface (`required` only on `gated`)**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tools.png"
alt="After: Task column per surface (`required` only on `gated`)"
width="720">

**After: Tasks panel with filters, find box and Client column**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tasks.png"
alt="After: Tasks panel with filters, find box and Client column"
width="720">

**After: filtered to failed tasks from one client**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tasks-failing-client.png"
alt="After: filtered to failed tasks from one client" width="720">

**After: Load more under the first 50 tasks**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tasks-load-more.png"
alt="After: Load more under the first 50 tasks" width="720">

**After: a pasted task id opens its task**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tasks-find.png"
alt="After: a pasted task id opens its task" width="720">

**After: drawer, working**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-working.png"
alt="After: drawer, working" width="720">

**After: drawer, input required**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-input-required.png"
alt="After: drawer, input required" width="720">

**After: answering an elicitation from Studio**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-answer-form.png"
alt="After: answering an elicitation from Studio" width="720">

**After: answered**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-answered.png"
alt="After: answered" width="720">

**After: drawer, completed**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-completed.png"
alt="After: drawer, completed" width="720">

**After: drawer, failed**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-failed.png"
alt="After: drawer, failed" width="720">

**After: cancelled from Studio**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-drawer-cancelled-from-studio.png"
alt="After: cancelled from Studio" width="720">

**After: chat chip while the task runs**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-client-slow-report-running.png"
alt="After: chat chip while the task runs" width="720">

**After: chat chip when it completes**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-client-slow-report-completed.png"
alt="After: chat chip when it completes" width="720">

**After: chat chip for a failed task**

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-client-expiring-failed.png"
alt="After: chat chip for a failed task" width="720">

<details><summary>Tablet (768px) and phone (390px)</summary>

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tools-768.png"
alt="tools-768" width="720">

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tasks-768.png"
alt="tasks-768" width="720">

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tools-390.png"
alt="tools-390" width="720">

<img
src="https://raw.githubusercontent.com/mastra-ai/mastra/14d862b62c1d2aecb0810d6480fe6af96cd9fe8c/pr7/pr7-after-server-tasks-390.png"
alt="tasks-390" width="720">

</details>





<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## ELI5

Studio can now show tasks that run through MCP servers and their status.
Users with the right access can answer task requests or cancel tasks.
Chat tool calls can also show task progress.

## Summary

- Added MCP task listing and lookup in Studio, with status, surface, and
client filters, pagination, and lookup by MCP task ID.
- Added task details with status, timestamps, results or errors, and
supported input requests. Users with `mcp:write` can answer requests or
cancel tasks.
- Required `mcp:read` for listing and lookup. Resource-scoped sessions
cannot inspect tasks. Custom task stores need the `MCPTaskStoreAdmin`
interface to support listing.
- Added task capability metadata to MCP server responses and task-mode
metadata to the tools list.
- Added task progress updates and a chat chip that shows task status and
elapsed time, with a button to copy the MCP task ID. For deferred tool
calls, the chip polls the background-task endpoint for status updates.
- Added MCP task methods to `MastraClient` and experimental task types
and inspector hooks in core.

## Validation

The PR description reports tests for task stores, server routes, client
requests, and Studio behavior. It also reports lint checks and
typechecks for several packages. The `@mastra/server` typecheck reports
an existing `@mastra/agent-builder` resolution error. The PR description
reports manual checks for task answering, cancellation, and
deferred-task completion.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
2026-10-30 09:31:21 -04:00
mastra-platform[bot]
244ae5212a
test: fix unit tests failing on main (run abort ack, span model-field gate, midnight schedules) (#28930) 2026-10-29 18:08:37 -07:00
mastra-platform[bot]
4d77d96cfe
fix(server): return 400 when an agent's request context fails its schema (#28918) 2026-10-29 17:39:28 -07:00
dane-ai-mastra[bot]
2e62b365e4
chore: version packages (alpha) (#28869) 2026-10-29 20:09:33 +01:00
dane-ai-mastra[bot]
4f12792ed1
chore: version packages (alpha) (#28722)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-29 08:37:01 -07:00
dane-ai-mastra[bot]
6a191d46dc chore: version - exit prerelease mode 2026-10-28 13:15:52 +00:00
Damien Schneider
976fde7416
refactor(lint): enable no-else-return at root (#28601)
Enables `no-else-return: error` in the root Oxlint config and removes
186 redundant `else` branches across 111 source/test files. Existing
rule defaults are retained.

Reviewed every code diff for behavior preservation. An independent
TypeScript AST comparison confirms that changes are limited to removing
`else` after returning branches, with the same expressions, statement
order, return values, and `try`/`catch`/`finally` boundaries. All
181,158 identifier occurrences retain their bindings. The recorder
replay path keeps an explicit block: flattening it would shadow the
earlier request `body` with the response `body` and introduce a
temporal-dead-zone error.

Extends the existing monorepo optimized-dependency test to assert that a
raw TypeScript workspace package, including its enum and transitive
dependency, still executes in the production bundle.

Validation: the root rule-only scan passes on 15,273 files with zero
diagnostics; formatting and `git diff --check` pass. Schema
compatibility tests: 1,060 passed, 9 skipped. Recorder runtime tests: 21
passed. The core selection initially passed 3,513 tests; rerunning the
suites requiring local server/cache access passed 185 tests, with one
remaining cache-file assertion also reproduced on unchanged `main`.

Remaining validation limits: four asset-download cases cannot reach
`placehold.co`; the changed-file lint run reports six import-order
errors reproduced on unchanged files from `main`. Deployer unit tests
and the monorepo test could not run because this checkout lacks required
package dependencies (`fs-extra`/workspace links and `get-port`,
respectively). These limits are left visible for CI. No changeset is
included because this is a behavior-preserving lint cleanup.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## ELI5
This PR makes the code easier to read by removing `else` branches that
are not needed after a return. It also enables a rule that catches those
branches and adds a test for loading a raw TypeScript workspace package
in a production bundle.

## Summary
- Enables Oxlint’s `no-else-return` rule at error severity and removes
186 redundant `else` branches across 111 files.
- Extends the monorepo optimized-dependencies test to check a raw
TypeScript workspace package, its enum, and a transitive dependency.
- Updates the deployer’s transpile-package path pattern.
- In workflow event processing, a truthy branch index with no matching
child now falls through to publish a skipped-step end event. Previously,
this case published no event.
- Keeps the recorder replay block explicit to avoid request/response
`body` shadowing and a temporal-dead-zone error.

## Validation
Reported checks passed: the rule-only scan across 15,273 files,
formatting, `git diff --check`, schema compatibility tests (1,060
passed, 9 skipped), recorder runtime tests (21 passed), and an initial
core test selection (3,513 passed).

Some test limits remain. Four asset-download cases could not reach
`placehold.co`. Changed-file lint reported six import-order errors that
also occur on unchanged files from `main`. Deployer unit tests and the
monorepo test could not run because dependencies were unavailable. On
rerun, suites requiring local server/cache access had 185 passes; one
cache-file assertion also reproduced on unchanged `main`.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-10-28 12:30:27 +01:00