npm / @mastra/client-js
@mastra/client-js
What changed in @mastra/client-js 1, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
18 breaking1 security3 deprecations127 new APIs and options1 performance7 behavior and defaults25 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@mastra/client-js 1182 changes
Breaking changes 18
When a model calls several client tools in one step, all tools now run and their results are returned together; aborted requests start no further client tools.
The request type now requires
traceId; callers that omitted it must supply it.The request type now requires
traceId; callers that omitted it must supply it.Return types now include
{ accepted: true }for supporting Platform backends; acceptance means cleanup is queued, not completed, and callers must narrow before readingsuccess.Return types now include
{ accepted: true }for supporting Platform backends; acceptance means cleanup is queued, not completed, and callers must narrow before readingsuccess.Return types now include
{ accepted: true }for supporting Platform backends; acceptance means cleanup is queued, not completed, and callers must narrow before readingsuccess.The thread rows type returned by queryTraceThreads() no longer includes model or provider.
Pass the session ID to session() and provide resourceId to create(); the scope argument is removed. Creating without resourceId resumes the existing resource or uses the session ID for a new one.
Response types add context and parent/root entity fields and no longer include cost, inputTruncated, outputTruncated, or errorTruncated.
Adds thread rows, activity sorting, and direct filters; the request shape changes, and QueryTraceThreadsResult now describes full thread rows. Use QueryTraceThreadsResult<typeof request> for legacy identity results.
Supports mode: 'merge' for atomic working-memory merges; requests are rejected with HTTP 400 when the storage adapter does not support atomic merges.
Requests conflicting with a run's state now return 409 Conflict instead of 500.
With reconnect enabled, resubscribe failures with 4xx or 501 errors now reject with the original error instead of retrying; other documented retry cases remain.
AgentController switchModel no longer accepts an options argument; model selection persists to the active thread and remains active when its mode changes.
Now reports whether an approval was accepted, returning { ok: false, reason } for stale, duplicate, or no-longer-pending decisions; it no longer retries automatically.
Now reports whether a suspension response was accepted, returning { ok: false, reason } for stale, duplicate, or no-longer-pending decisions; it no longer retries automatically.
Streams emit one complete message_start payload, ID-addressed message_update events, and a message_end containing only the message ID; consumers must store and update messages by ID.
queryTraces() no longer supports thread-group responses; it accepts trace-only queries and returns trace records.
Security 1
The package no longer depends on @ai-sdk/ui-utils, which included a vulnerable version of @ai-sdk/provider-utils; streaming works as before.
Deprecations 3
experimentIdA and experimentIdB still support two-experiment comparisons but are deprecated in favor of experimentIds.
Grouped results from queryTraces() are deprecated but continue to work until the next major release; use queryTraceThreads() for new code.
Soft-deprecated in favour of messageHistory; it remains supported and can be combined with messageHistory.
New APIs and options 127
Stream chunks now carry their run-log position in
index, enabling clients to resumeobserve()after a dropped connection without repeated or missing chunks.Adds shared contracts for opt-in aggregated trace roots; OSS readers remain unsupported.
Adds support for OSS feedback replacement requests and the
feedbackReplacementcapability.Adds a method to read how the built-in MCP server is set up.
Adds typed single-record feedback reads; missing records return
{ feedback: null }, and IDs are passed unencoded for client-side URL encoding.Adds typed single-record score reads; missing records return
{ score: null }, and IDs are passed unencoded for client-side URL encoding.Adds a review status filter so callers can list experiment results with a specified review status.
Completed span queries can now order by
durationMsto find slowest spans.Span queries can now sort by
modelorprovider.Adds full-replacement feedback requests, with bounded cancellable retries for recognized missing-anchor responses and stable feedback IDs and timestamps across retries.
agent.generate()andagent.stream()now accept a plain-objectrequestContextin addition toRequestContext.Adds text-search request types and capability flags for Platform integration.
Adds an observability capability flag for stores that can compute time-to-first-token or time-to-first-chunk aggregates; unsupported stores return 501 for those requests and omit the measures from field discovery.
Adds an events stream on a Knowledge client resource; the server ends streams after five minutes, so reconnect when they end.
Adds a JS client method to access a Knowledge instance and its read-only routes.
Adds a Knowledge client method to retrieve link counts for page IDs.
Adds a JS client method to list Knowledge instances through the new read-only Knowledge routes.
Adds a Knowledge client method to retrieve a page's links in a specified direction.
Adds a client method to answer a suspended background task.
Adds this field to the observability capabilities response type.
Answers required input for a task belonging to an MCP server.
Cancels a task for an MCP server.
Workspace info reports when the filesystem comes from a resolver and is created per request, so developers can detect that file routes cannot browse it.
Dashboard definition types, including DashboardDefinition, DashboardWidget, and DashboardQuery, are exported.
Finds a task for an MCP server.
Lists tasks for an MCP server, with optional filters such as status.
Observability span and trace queries and aggregations support outcome filters and groupings, and results include outcome.
Saved view and filter types, including SavedViewState and FilterNode, are exported from the package.
Observability capabilities report whether aggregateSpans supports model and provider in groupBy and countDistinct.
Observability capabilities report whether querySpans supports model and provider filters, and aggregateSpans supports them when spanAggregate is also true.
Observability span and trace queries and aggregations support stopReason filters and groupings, and results include stopReason.
Observability query results now include stopReasonContext.
Supported query results include timeToFirstTokenMs, and queryTraces and querySpans accept it in orderBy; capabilities report availability and sort support.
Adds agent.abortRun(runId) to explicitly cancel durable execution without requiring a memory thread.
Adds grouped span measures, including agent-run counts by status per day and nested agent runs.
Accepts an optional abort signal so callers can cancel an aggregation that is no longer needed.
Provider catalogs can include optional model release dates for newest-first model selection.
Span types returned by trace and span endpoints now include native external parent, resume, model, provider, outcome, stop-reason, token timing, and error-count fields.
AgentController session subscriptions can set displayState to false to skip full display-state snapshots, including the initial snapshot, reducing SSE bandwidth and serialization work; snapshots remain enabled by default.
Setting withRunStatus to true delivers retained and live thread-run-status outcomes, and includes run statuses in callback types.
Accepts agentModel to run an agent experiment against a different model.
Adds typed support for POST /agent-controller/:controllerId/sessions/:resourceId/threads/:threadId/owner.
Tool approval accepts alwaysAllowCategory: true to approve the call and grant its tool category to the call's thread.
Approval and decline methods accept clientTools and clientToolsResolver so the model can call client tools after the decision; approveToolCall and declineToolCall also accept memory to save results and the final answer to the original thread.
Dataset listing accepts specific IDs in one request; all matches are returned on one page, up to 100 IDs.
Adds an experimental method to emit MCP server events; it is available under mastra dev only.
Classifier evaluation traces identify the classifier as their entity, and EntityType gains the classifier value so traces can be filtered and grouped like other entities.
Observability metric queries accept a batch of experiment IDs, allowing token usage and cost for many experiments to be requested together.
Adds an experimental method to retrieve events from an MCP server.
Agent controller session subscriptions treat streams with no data for the timeout as dropped, allowing reconnect callbacks or onError to run. The default is 60 seconds; set to 0 to disable.
Agent details expose whether model-list editing is supported, allowing clients to disable editing for dynamically resolved model lists.
Adds an experimental method to poll occurrences of an MCP server event, with optional arguments and a cursor.
Observability capability response types now include spanQueryContextFields.
Adds an experimental async stream for MCP server event occurrences, supporting a cursor and abort signal.
Trace and span results expose milliseconds from span start to the first streamed chunk; queryTraces and querySpans can also order by this field.
Observability capabilities report support for trace-scope root entityId queries; unsupported queries return 422 instead of 500, and field discovery omits the unsupported field.
Observability capabilities report support for trace-scope root name and spanType queries; unsupported queries return 422 instead of 500, and field discovery omits those fields.
Observability capabilities report whether timeToFirstChunkMs is available for trace and span query results.
queryTraces and querySpans accept timeToFirstChunkMs in orderBy, and observability capabilities report whether sorting by it is supported.
Adds a method for queuing a typed signal behind the active thread run.
Adds client-side trace aggregation by time range, grouping, and measures; check capabilities.traceAggregate before calling it.
Adds errorPreview to trace list rows and querySpans() rows.
Adds errorTruncated to querySpans() rows.
Adds outputPreview to trace list rows.
Adds an optional observability capability indicating how long traces are kept, so clients can avoid offering dates whose traces are gone.
An exported type describes the output stored for agent experiment targets, including preserved error details.
Compare two to ten experiments at once against a baseline by passing experimentIds and optionally baselineId.
An exported type describes experiment result output by target.
The /steer and /follow-up routes accept the files field and limits already supported by /messages.
AgentController followUp accepts file attachments, including when the message is queued behind an active run.
Generated Agent Controller tool-suspension route types now include an optional run id field.
An exported type describes the output stored for scorer experiment targets.
AgentController steer accepts file attachments, including when the message is queued behind an active run.
Experiment results include targetType, which lets TypeScript narrow output to typed agent or scorer results; workflow, processor, and caller-driven outputs remain unknown.
Gets an experiment by ID without requiring its dataset.
Added as a trace-query operator in the generated trace-query types.
The Client SDK recognizes this live session event, allowing web clients to respond immediately to the agent's task-completion verdict.
The getSystemPackages response types include an optional capability applications can use to discover recording review support.
Instruction blocks can include optional per-usage display conditions on prompt block references, allowing stored agents to save and preview them.
Lists completed spans matching a span filter, one row per span, with cursor pagination; check spanQuery capability before calling it.
MCP resource read results include optional mimeType and _meta fields in the MCPServerBase type and readMcpServerResource response.
Reconcile channel installations completed outside the app; the client method returns a fresh installation or null when reconciliation is unsupported.
The workspace client adds typed skills.sh registry methods for searching, listing popular skills, previewing, installing, removing, and updating skills.
Stored agent memory can reference a registered memory instance with an id or hold an inline config; existing inline configs remain accepted.
Controller session switchModel calls accept an optional thinking level.
Added withInitialHistory to HTTP thread subscriptions, sending stored thread messages as one thread-history chunk before live parts; completed runs no longer replay on reconnect.
Added a summary option to list workflow runs without downloading full snapshots.
Adds a feedback flag to the observability capabilities response so clients can check whether the configured store supports feedback endpoints.
Returns the optional observability features supported by the server's configured storage, so clients can check capabilities before calling endpoints.
Adds array as a value kind in the generated trace-query types.
Adds an API to cancel selected pending input without stopping the active run; requested signal IDs are propagated through shared PubSub, while the response reports only local cancellations.
Adds an option to clear pending input when calling abortThread() or subscription abort().
Adds the includes trace-query operator to the generated trace-query types.
Adds the notIncludes trace-query operator to the generated trace-query types.
Exposes the optional tool title on tool endpoints and in GetToolResponse, and copies it from tool-call chunks onto the tool-invocation message part in the useChat accumulator.
The client supports classifier workflow steps and their rendered workflow graph entries.
Use queryTraceThreads() instead of grouped queryTraces() results for new code.
Generated tracingOptions request types include rootSpanName, allowing per-run root span names to be sent from the client.
MCP server info responses include transports so consumers can tell which endpoints a server serves; MCP v2 reports streamable-http, while MCP 1.x also reports sse.
Adds a per-call abortSignal option to streaming, resuming, tool approval or decline, and generation methods; it merges with the client-wide signal, and aborted requests are not retried.
Adds expectedRunId support when aborting agent thread runs.
Memory configuration can send minMessages, emitEvent, and an optional model for title generation; the default model is the agent's model.
Adds a client method to discover fields available for bounded trace queries.
Adds a client method to discover values available for bounded trace queries.
Adds orderBy support to listDatasets, listDatasetItems, listExperiments, listDatasetExperiments, and listDatasetExperimentResults.
Accepts pagination parameters so clients can fetch previous chunks of conversation history.
Adds methods to create, get, list, and delete task push-notification configurations; list results include pagination metadata.
Is typed as the REST route response and accepts resumeData and suspendPayload so suspended tools can be continued.
Adds token-budgeted conversation history that trims oldest remembered messages in chunks while preserving the current turn and system messages; a persisted per-thread boundary keeps trimmed history out of later turns.
Adds an optional experiment item score result field so clients can distinguish a skipped run from a scorer error.
Adds delta polling inputs and response types, allowing queries to continue from the cursor returned with numbered pages.
Advanced trace queries accept page-based pagination, and paginated responses include total, page, perPage, and hasMore metadata.
Adds typed methods for querying thread identities across eligible traces; unlike queryTraces, results contain observability-derived thread identities.
Requests can override client-level retry settings; retry counts must be non-negative safe integers.
Requests can override client-level abort settings, and aborted requests stop without retrying.
Generate and stream params can resolve client tools at call time, with tools re-resolved before each execution and continuation round.
getAgent() accepts a stream option to override the agent stream route.
MastraClient adds a method that reports whether the Studio workflow builder is available.
listDatasetExperiments() accepts target filters to scope experiment listings to a target entity.
listDatasets() accepts target filters to scope dataset listings to a target entity.
listExperiments() accepts target filters to scope experiment listings to a target entity.
Transfer an existing thread to a different resourceId from the client.
Adds a client method to remove observability feedback records by id.
Adds a client method to remove observability score records by id.
Adds a tags option to restrict results to those carrying every listed tag.
Agent Controller message listing gains storage-backed pagination, ordering, filtering, and message includes; Session and numeric client APIs still return message arrays for compatibility.
Supports feedback predicates in trace queries, allowing developers to filter traces by feedback fields.
Performance 1
Parsing of large streamed events is faster.
Behavior and default changes 7
UI messages from newer
aiv7 releases, including messages withsteering-messageparts, can now be passed toagent.generate()andagent.stream(); Mastra does not process those new part types yet.Agents that opt into Editor ownership can persist model-list edits through the existing reorder and update APIs.
Trace query requests no longer retry a server query execution timeout (504 with code TRACE_QUERY_EXECUTION_TIMEOUT); other 5xx errors, including proxy or gateway 504s, are still retried.
The experimental annotation was removed from Agent signal APIs now that signals are stable.
The processors API now reports an llmRequest phase for processors that only implement processLLMRequest, making them visible in Studio; direct execution of this phase returns a 400 error.
Requests that fail with 501 Not Implemented are no longer retried, avoiding repeated failed requests and server error logs when storage does not support an API.
Accepts PascalCase method names when the A2A-Version header is 1.0, while preserving legacy slash-style methods.
Fixes and other changes 25
When a model calls several client tools in one step, all tools now run and their results are returned together; aborted requests start no further client tools.
With
experimental_output,result.textis available again.With
output,result.objectnow has the type of the supplied schema.Zod v3
structuredOutputschemas now type-check in clientagent.generate()andagent.stream()without the complex-union error.Request headers differing from client headers only by case now replace them; explicit Content-Type also replaces the JSON default.
Per-call cancellation now stops durable runs when streaming, resuming, or approving or declining tool calls; cancelling response.body or the client-wide signal only stops updates.
Streamed client tool results now include their original arguments.
The generate approval and decline methods now execute client tools called after the decision and continue the conversation; memory can save that continuation to the thread.
Durable and evented agents without memory retain the conversation after client-tool approval or decline, and the tool no longer reruns after suspension.
The schedules HTTP API now preserves ifIdle.requireClaimedOwner when creating or updating agent schedules instead of dropping the flag.
Resuming after tool approval or decline no longer logs the tool_result ordering error, and client tools called after the resumed tool call run as expected.
Failed agent runs now store error.message and error.stack instead of an empty object.
Session streams send the current display state as their first event; merge currentMessage by message ID rather than appending it.
nestUnderParent is no longer dropped from agent and workflow requests sent over HTTP, preserving the run's parent-child trace relationship.
Forwards options, including speaker, to the voice provider; options.speaker takes precedence over the top-level speakerId when both are sent.
MCP resource reads preserve mimeType and _meta metadata, matching listResources() and the MCP resources/read request.
Schedules with no future cron occurrence report completed when fetched by id; listings include them only when filtered by completed, while updates still accept only active or paused.
Lightweight trace list rows now include resourceId so the Resource ID column renders when the trace query API is unavailable.
Lightweight trace list rows now include threadId so the Thread ID column renders when the trace query API is unavailable.
Workflow run methods now URL-encode run IDs, preventing 404 errors when IDs contain characters such as +, &, #, or /.
Agent controller tool-approval requests resume the stored suspended run when no approval is waiting in the session, allowing approval cards restored from thread history after a restart to be answered.
Cancelling a returned agent stream aborts the underlying HTTP request and stops pending client-tool executions and follow-up requests.
Sends PascalCase A2A v1 JSON-RPC method names for message and task operations to interoperate with v1-compliant servers; the v0.3 client is unchanged.
subscribe() now honors unsubscribe() at every await and dispatch boundary, preventing stale session state and response body leaks.
Accumulated arguments from streamed partial tool calls are merged before onToolCall fires, so handlers receive complete arguments.