@mantyx/sdk 2026.9.2 → 2026.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,8 +7,14 @@ and new releases use calendar versions (`YYYY.M.RELEASE`). Historical versions r
7
7
 
8
8
  ### Added
9
9
 
10
+ - Configure a fallback model for ephemeral runs and sessions. MANTYX preserves
11
+ completed tool results during failover and keeps switched sessions on the fallback.
12
+
10
13
  - Cursor-based session pagination and bounded session event pages (SDK PR #9).
11
- - Explicit new-loop opt-in for runs, sessions, session turns, evals and A2A server wrappers.
14
+
15
+ ### Removed
16
+
17
+ - Experimental `newLoop` opt-in for the reviewed harness loop. Agent runs use the existing loop.
12
18
 
13
19
  ### Changed
14
20
 
package/README.md CHANGED
@@ -24,10 +24,6 @@ and the messaging-layer reference in [`docs/wire-protocol.md`](./docs/wire-proto
24
24
  resolved data structures (`a2a_local` Agent Card, `mcp_local` `Tool[]`)
25
25
  that this SDK ships.
26
26
 
27
- ## Harness loop selection
28
-
29
- Pass `newLoop: true` when running an agent, creating a session, or starting an eval to opt into the reviewed harness loop. Omission keeps external runs on the existing loop. Session turns inherit the session setting; an explicit false overrides it for that turn. Use `session.send(prompt, { newLoop: false })`.
30
-
31
27
  ## Install
32
28
 
33
29
  ```bash
@@ -348,7 +348,6 @@ function specForRun(spec) {
348
348
  if (spec.systemPrompt) out.systemPrompt = spec.systemPrompt;
349
349
  if (spec.modelId) out.modelId = spec.modelId;
350
350
  if (spec.tools) out.tools = spec.tools;
351
- if (spec.newLoop !== void 0) out.newLoop = spec.newLoop;
352
351
  if (spec.reasoningLevel !== void 0) out.reasoningLevel = spec.reasoningLevel;
353
352
  if (spec.outputSchema !== void 0) out.outputSchema = spec.outputSchema;
354
353
  if (spec.metadata) out.metadata = spec.metadata;
@@ -362,7 +361,6 @@ function specForSession(spec, contextId) {
362
361
  if (spec.systemPrompt) out.systemPrompt = spec.systemPrompt;
363
362
  if (spec.modelId) out.modelId = spec.modelId;
364
363
  if (spec.tools) out.tools = spec.tools;
365
- if (spec.newLoop !== void 0) out.newLoop = spec.newLoop;
366
364
  if (spec.reasoningLevel !== void 0) out.reasoningLevel = spec.reasoningLevel;
367
365
  if (spec.outputSchema !== void 0) out.outputSchema = spec.outputSchema;
368
366
  const meta = { ...spec.metadata ?? {} };
@@ -58,8 +58,6 @@ export interface MantyxAgentSpec {
58
58
  systemPrompt?: string;
59
59
  modelId?: string;
60
60
  tools?: ToolRef[];
61
- /** Opt into the verified loop; omission preserves legacy behavior or session inheritance. */
62
- newLoop?: boolean;
63
61
  reasoningLevel?: ReasoningLevel;
64
62
  /**
65
63
  * Constrains the model's final assistant text to a JSON document matching
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MantyxError,
3
3
  MantyxRunError
4
- } from "./chunk-XMNAWLMF.js";
4
+ } from "./chunk-ZGBSE23M.js";
5
5
 
6
6
  // src/a2a-server.ts
7
7
  var MantyxAgentExecutor = class {
@@ -256,7 +256,6 @@ function specForRun(spec) {
256
256
  if (spec.systemPrompt) out.systemPrompt = spec.systemPrompt;
257
257
  if (spec.modelId) out.modelId = spec.modelId;
258
258
  if (spec.tools) out.tools = spec.tools;
259
- if (spec.newLoop !== void 0) out.newLoop = spec.newLoop;
260
259
  if (spec.reasoningLevel !== void 0) out.reasoningLevel = spec.reasoningLevel;
261
260
  if (spec.outputSchema !== void 0) out.outputSchema = spec.outputSchema;
262
261
  if (spec.metadata) out.metadata = spec.metadata;
@@ -270,7 +269,6 @@ function specForSession(spec, contextId) {
270
269
  if (spec.systemPrompt) out.systemPrompt = spec.systemPrompt;
271
270
  if (spec.modelId) out.modelId = spec.modelId;
272
271
  if (spec.tools) out.tools = spec.tools;
273
- if (spec.newLoop !== void 0) out.newLoop = spec.newLoop;
274
272
  if (spec.reasoningLevel !== void 0) out.reasoningLevel = spec.reasoningLevel;
275
273
  if (spec.outputSchema !== void 0) out.outputSchema = spec.outputSchema;
276
274
  const meta = { ...spec.metadata ?? {} };
@@ -1427,7 +1427,6 @@ var AgentSession = class {
1427
1427
  }
1428
1428
  if (this.tools.length > 0) body.tools = serializeToolRefs(this.tools);
1429
1429
  if (opts.metadata && Object.keys(opts.metadata).length > 0) body.metadata = opts.metadata;
1430
- if (opts.newLoop !== void 0) body.newLoop = opts.newLoop;
1431
1430
  if (opts.reasoningLevel !== void 0) {
1432
1431
  body.reasoningLevel = normalizeReasoningLevel(opts.reasoningLevel);
1433
1432
  }
@@ -1513,7 +1512,7 @@ function serializeAgentSpec(spec, extra = {}) {
1513
1512
  if (spec.agentId) body.agentId = spec.agentId;
1514
1513
  if (spec.name) body.name = spec.name;
1515
1514
  if (spec.modelId) body.modelId = spec.modelId;
1516
- if (spec.newLoop !== void 0) body.newLoop = spec.newLoop;
1515
+ if (spec.fallbackModelId) body.fallbackModelId = spec.fallbackModelId;
1517
1516
  if (spec.reasoningLevel !== void 0) {
1518
1517
  body.reasoningLevel = normalizeReasoningLevel(spec.reasoningLevel);
1519
1518
  }
@@ -1553,7 +1552,6 @@ function serializeCreateEvalRunRequest(spec) {
1553
1552
  throw new MantyxError("createEvalRun accepts only one of `agentId` or `agent`");
1554
1553
  }
1555
1554
  const body = {};
1556
- if (spec.newLoop !== void 0) body.newLoop = spec.newLoop;
1557
1555
  if (spec.datasetId) body.datasetId = spec.datasetId;
1558
1556
  if (spec.dataset) body.dataset = spec.dataset;
1559
1557
  if (spec.agentId) body.agentId = spec.agentId;
package/dist/client.d.ts CHANGED
@@ -102,7 +102,6 @@ export interface AgentEvalOverrides {
102
102
  }
103
103
  /** Body for `POST /eval-runs`. Exactly one of `datasetId`/`dataset` and `agentId`/`agent`. */
104
104
  export interface CreateEvalRunRequest {
105
- newLoop?: boolean;
106
105
  datasetId?: string;
107
106
  dataset?: InlineEvalDatasetSpec;
108
107
  agentId?: string;
@@ -342,9 +341,9 @@ export interface AgentSpecBase {
342
341
  /** Required unless `agentId` is set. */
343
342
  systemPrompt?: string;
344
343
  modelId?: string;
344
+ /** Alternate model for provider outages; remains active for the session after switching. */
345
+ fallbackModelId?: string;
345
346
  tools?: ToolRef[];
346
- /** Opt into the verified loop; omission preserves legacy behavior or session inheritance. */
347
- newLoop?: boolean;
348
347
  /**
349
348
  * Provider thinking strength: a string anchor (`"off" | "low" | "medium" |
350
349
  * "high"`) or an integer in `0..100` (where `0` explicitly disables provider
@@ -753,6 +752,8 @@ export interface ThinkingDeltaEvent extends RunEventBase {
753
752
  }
754
753
  export interface AssistantMessageEvent extends RunEventBase {
755
754
  type: "assistant_message";
755
+ /** Actual model that produced this invocation. */
756
+ model?: RunModelInfo;
756
757
  /**
757
758
  * Full assistant text for this turn (concatenation of every preceding
758
759
  * `assistant_delta` for the turn, plus any non-streaming snapshot the
@@ -1024,7 +1025,14 @@ export interface UserMessageEvent extends RunEventBase {
1024
1025
  /** Present on session-event replay when the user turn carried file inputs. */
1025
1026
  attachments?: AttachmentMetadata[];
1026
1027
  }
1027
- export type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | TaskPlanEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1028
+ export interface ModelFallbackEvent extends RunEventBase {
1029
+ type: "model_fallback";
1030
+ errorClass: string;
1031
+ model: RunModelInfo;
1032
+ primaryModelId?: string | null;
1033
+ fallbackModelId: string;
1034
+ }
1035
+ export type RunEvent = AssistantDeltaEvent | ThinkingDeltaEvent | AssistantMessageEvent | ModelFallbackEvent | UserMessageEvent | ServerToolResultEvent | LocalToolCallEvent | LocalToolResultInEvent | LoopDetectedEvent | ToolBudgetExceededEvent | SupervisorEvent | TaskPlanEvent | ResultEvent | ErrorEvent | CancelledEvent | (RunEventBase & {
1028
1036
  type: string;
1029
1037
  [key: string]: unknown;
1030
1038
  });
@@ -1035,7 +1043,9 @@ export interface SessionInfo {
1035
1043
  createdAt: string;
1036
1044
  lastUsedAt: string;
1037
1045
  endedAt: string | null;
1038
- agentSpec: AgentSpecBase;
1046
+ agentSpec: AgentSpecBase & {
1047
+ activeModelId?: string;
1048
+ };
1039
1049
  messages: ConversationMessage[];
1040
1050
  /** Metadata that was attached to the session at create time, returned for observability. */
1041
1051
  metadata: Record<string, string>;
@@ -1259,8 +1269,6 @@ export declare class AgentSession {
1259
1269
  * Per-message override for `reasoningLevel`. Applies only to this run
1260
1270
  * and does not mutate the session's stored value.
1261
1271
  */
1262
- /** Opt into the verified loop; omission preserves legacy behavior or session inheritance. */
1263
- newLoop?: boolean;
1264
1272
  reasoningLevel?: ReasoningLevel;
1265
1273
  /**
1266
1274
  * Per-message override for `outputSchema`. Applies only to this run
@@ -1294,8 +1302,6 @@ export declare class AgentSession {
1294
1302
  signal?: AbortSignal;
1295
1303
  attachments?: MessageAttachment[];
1296
1304
  metadata?: Record<string, string>;
1297
- /** Opt into the verified loop; omission preserves legacy behavior or session inheritance. */
1298
- newLoop?: boolean;
1299
1305
  reasoningLevel?: ReasoningLevel;
1300
1306
  outputSchema?: OutputSchema;
1301
1307
  loopDetection?: LoopDetection | false;
@@ -1311,8 +1317,6 @@ export declare class AgentSession {
1311
1317
  onAssistantDelta?: (s: string) => void;
1312
1318
  signal?: AbortSignal;
1313
1319
  metadata?: Record<string, string>;
1314
- /** Opt into the verified loop; omission preserves legacy behavior or session inheritance. */
1315
- newLoop?: boolean;
1316
1320
  reasoningLevel?: ReasoningLevel;
1317
1321
  outputSchema?: OutputSchema;
1318
1322
  loopDetection?: LoopDetection | false;
package/dist/index.cjs CHANGED
@@ -1501,7 +1501,6 @@ var AgentSession = class {
1501
1501
  }
1502
1502
  if (this.tools.length > 0) body.tools = serializeToolRefs(this.tools);
1503
1503
  if (opts.metadata && Object.keys(opts.metadata).length > 0) body.metadata = opts.metadata;
1504
- if (opts.newLoop !== void 0) body.newLoop = opts.newLoop;
1505
1504
  if (opts.reasoningLevel !== void 0) {
1506
1505
  body.reasoningLevel = normalizeReasoningLevel(opts.reasoningLevel);
1507
1506
  }
@@ -1587,7 +1586,7 @@ function serializeAgentSpec(spec, extra = {}) {
1587
1586
  if (spec.agentId) body.agentId = spec.agentId;
1588
1587
  if (spec.name) body.name = spec.name;
1589
1588
  if (spec.modelId) body.modelId = spec.modelId;
1590
- if (spec.newLoop !== void 0) body.newLoop = spec.newLoop;
1589
+ if (spec.fallbackModelId) body.fallbackModelId = spec.fallbackModelId;
1591
1590
  if (spec.reasoningLevel !== void 0) {
1592
1591
  body.reasoningLevel = normalizeReasoningLevel(spec.reasoningLevel);
1593
1592
  }
@@ -1627,7 +1626,6 @@ function serializeCreateEvalRunRequest(spec) {
1627
1626
  throw new MantyxError("createEvalRun accepts only one of `agentId` or `agent`");
1628
1627
  }
1629
1628
  const body = {};
1630
- if (spec.newLoop !== void 0) body.newLoop = spec.newLoop;
1631
1629
  if (spec.datasetId) body.datasetId = spec.datasetId;
1632
1630
  if (spec.dataset) body.dataset = spec.dataset;
1633
1631
  if (spec.agentId) body.agentId = spec.agentId;
@@ -2747,7 +2745,7 @@ async function runComputerUse(opts) {
2747
2745
  }
2748
2746
 
2749
2747
  // src/version.ts
2750
- var SDK_VERSION = "2026.9.2";
2748
+ var SDK_VERSION = "2026.10.1";
2751
2749
  // Annotate the CommonJS export names for ESM import in node:
2752
2750
  0 && (module.exports = {
2753
2751
  AgentSession,
package/dist/index.d.ts CHANGED
@@ -34,7 +34,7 @@
34
34
  * console.log(result.text);
35
35
  */
36
36
  export { MantyxClient, AgentSession, DEFAULT_BASE_URL, parseRunOutput, planOnly, taskPlanFromEventData, inputFileAttachment, inputFileUrlAttachment, } from "./client.js";
37
- export type { MantyxClientOptions, ModelInfo, ModelCatalog, AgentSpecBase, RunSpec, SessionSpec, OutputSchema, OutputSchemaValue, LoopDetection, ToolBudget, ToolBudgets, Supervisor, SupervisorAction, SupervisorPhase, ReasoningTrigger, PlanOptions, PlanMode, PlanSpec, TaskPlan, TaskPlanStep, TaskPlanStepStatus, TaskPlanTransition, RunResult, RunTokenUsage, RunModelInfo, RunEvent, RunEventBase, AssistantDeltaEvent, ThinkingDeltaEvent, AssistantMessageEvent, UserMessageEvent, InputFileAttachment, InputFileUrlAttachment, MessageAttachment, InputFileAttachmentMetadata, InputFileUrlAttachmentMetadata, AttachmentMetadata, ConversationMessage, ServerToolResultEvent, LocalToolCallEvent, LocalToolResultInEvent, LoopDetectedEvent, ToolBudgetExceededEvent, SupervisorEvent, TaskPlanEvent, ResultEvent, ErrorEvent, CancelledEvent, SessionInfo, SessionSummary, SessionListResult, SessionEventsPage, LocalHandlers, RunFeedbackVerdict, RunFeedbackInput, RunFeedbackResult, EvalRunStatus, InlineEvalCaseSpec, InlineEvalDatasetSpec, AgentEvalOverrides, CreateEvalRunRequest, EvalDatasetSummary, EvalDatasetList, EvalCase, EvalDatasetDetail, EvalRunAccepted, EvalRunSummary, EvalCaseResult, EvalRunDetail, EvalRunList, EvalRunCompareSide, EvalRunCompareCase, EvalRunCompare, EvalRunEvent, ListEvalRunsOptions, RunEvalOptions, } from "./client.js";
37
+ export type { MantyxClientOptions, ModelInfo, ModelCatalog, AgentSpecBase, RunSpec, SessionSpec, OutputSchema, OutputSchemaValue, LoopDetection, ToolBudget, ToolBudgets, Supervisor, SupervisorAction, SupervisorPhase, ReasoningTrigger, PlanOptions, PlanMode, PlanSpec, TaskPlan, TaskPlanStep, TaskPlanStepStatus, TaskPlanTransition, RunResult, RunTokenUsage, RunModelInfo, RunEvent, RunEventBase, AssistantDeltaEvent, ThinkingDeltaEvent, AssistantMessageEvent, ModelFallbackEvent, UserMessageEvent, InputFileAttachment, InputFileUrlAttachment, MessageAttachment, InputFileAttachmentMetadata, InputFileUrlAttachmentMetadata, AttachmentMetadata, ConversationMessage, ServerToolResultEvent, LocalToolCallEvent, LocalToolResultInEvent, LoopDetectedEvent, ToolBudgetExceededEvent, SupervisorEvent, TaskPlanEvent, ResultEvent, ErrorEvent, CancelledEvent, SessionInfo, SessionSummary, SessionListResult, SessionEventsPage, LocalHandlers, RunFeedbackVerdict, RunFeedbackInput, RunFeedbackResult, EvalRunStatus, InlineEvalCaseSpec, InlineEvalDatasetSpec, AgentEvalOverrides, CreateEvalRunRequest, EvalDatasetSummary, EvalDatasetList, EvalCase, EvalDatasetDetail, EvalRunAccepted, EvalRunSummary, EvalCaseResult, EvalRunDetail, EvalRunList, EvalRunCompareSide, EvalRunCompareCase, EvalRunCompare, EvalRunEvent, ListEvalRunsOptions, RunEvalOptions, } from "./client.js";
38
38
  export { defineLocalTool, mantyxTool, mantyxPluginTool, mantyxA2A, defineLocalA2A, mantyxMcp, defineLocalMcp, isLocalTool, isLocalA2ATool, isLocalMcpServer, } from "./tools.js";
39
39
  export type { LocalTool, LocalToolResult, LocalToolOutput, ToolResultFile, MantyxToolRef, MantyxPluginToolRef, ToolRef, ZodLikeObject, DefineLocalToolOptions, ReasoningLevel, A2AToolRef, LocalA2ATool, McpToolRef, LocalMcpServer, LocalMcpHttpTransport, LocalMcpStdioTransport, MantyxA2AOptions, DefineLocalA2AOptions, MantyxMcpOptions, DefineLocalMcpOptions, } from "./tools.js";
40
40
  export { MantyxError, MantyxAuthError, MantyxNetworkError, MantyxParseError, MantyxScopeError, MantyxToolError, MantyxRunError, } from "./errors.js";
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  taskPlanFromEventData,
28
28
  toToolParametersWire,
29
29
  zodToJsonSchema
30
- } from "./chunk-XMNAWLMF.js";
30
+ } from "./chunk-ZGBSE23M.js";
31
31
 
32
32
  // src/oauth.ts
33
33
  var DEFAULT_OAUTH_BASE_URL = "https://app.mantyx.io";
@@ -603,7 +603,7 @@ async function runComputerUse(opts) {
603
603
  }
604
604
 
605
605
  // src/version.ts
606
- var SDK_VERSION = "2026.9.2";
606
+ var SDK_VERSION = "2026.10.1";
607
607
  export {
608
608
  AgentSession,
609
609
  COMPUTER_USE_ACTIONS,
package/dist/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Release version — synced from sdk/VERSION (`pnpm run sync-version`).
3
3
  */
4
- export declare const SDK_VERSION = "2026.9.2";
4
+ export declare const SDK_VERSION = "2026.10.1";
@@ -1,7 +1,5 @@
1
1
  # Agent Runs — wire protocol
2
2
 
3
- See [harness loop opt-in](#harness-loop-opt-in) for `newLoop: true` opt-in, session inheritance, A2A/MCP parameters, and completion-review events.
4
-
5
3
  This document specifies the public wire protocol that the MANTYX agent-runs API
6
4
  speaks with SDKs. It is the source of truth for anyone implementing a new
7
5
  client (Python, Rust, Java…) and is shipped with each first-party SDK so the
@@ -464,6 +462,35 @@ not re-sent to the model (text only); only the current turn's files reach the
464
462
  LLM. Whether the model can interpret an accepted file depends on the selected
465
463
  model and provider.
466
464
 
465
+ ### 4.0.2 `fallbackModelId` (provider availability failover)
466
+
467
+ Set optional `fallbackModelId` on a run or session spec using the same model
468
+ selector grammar as `modelId`. TypeScript uses `fallbackModelId`, Python uses
469
+ `fallback_model_id`, and Go uses `FallbackModelID`. The fallback must resolve
470
+ to a different provider/model pair from the primary.
471
+
472
+ During agent execution (including approval and shutdown resumes), after normal
473
+ retries are exhausted, MANTYX switches the failed model invocation
474
+ for retryable overload, provider server, unreachable-provider, or upstream
475
+ timeout errors. It does not switch for authentication, invalid requests, quota
476
+ errors, cancellation, or after answer text has streamed from that invocation.
477
+ The fallback gets its own retry budget; there is no bounce back to the primary.
478
+
479
+ The same run and session continue with the system prompt, conversation, tools,
480
+ and completed tool results. Tools already executed are not replayed. Opaque
481
+ provider reasoning is removed and portable context compaction uses the fallback
482
+ model's context window. Native opaque compaction is disabled while failover is
483
+ configured.
484
+
485
+ A switched session stays on the fallback for later messages. New sessions start
486
+ with the primary. The original `agentSpec.modelId` and `fallbackModelId` remain
487
+ visible; server-owned `agentSpec.activeModelId` identifies the active selection.
488
+ Clients cannot set `activeModelId`. Terminal `model` identifies the actual model;
489
+ `assistant_message.model` identifies each completed model invocation. The
490
+ non-terminal `model_fallback` SSE event carries `{ errorClass, model,
491
+ primaryModelId, fallbackModelId }`. Session details expose each call's actual
492
+ `model`, including failed calls that switched.
493
+
467
494
  ### 4.1 Triggering a persisted MANTYX agent (`agentId`)
468
495
 
469
496
  Set `agentId` to the `id` of a workspace `Agent` to run that agent instead of
@@ -1826,7 +1853,3 @@ A reference SDK should:
1826
1853
  The npm package [`@mantyx/sdk`](https://www.npmjs.com/package/@mantyx/sdk) and the Go module
1827
1854
  [`github.com/mantyx/mantyx-go-sdk`](https://github.com/mantyx/mantyx-go-sdk) are reference implementations of this protocol
1828
1855
  (maintained in the official **mantyx-sdk** repositories).
1829
-
1830
- ## Harness loop opt-in
1831
-
1832
- External agent runs and new sessions use the existing loop unless `newLoop: true` is supplied. The same optional boolean is supported by eval creation. Session messages inherit the stored session setting when omitted; explicit `false` selects the existing loop for that turn. A2A server wrappers forward the configured selection. Harness events such as `completion_review` and `harness_decision` are available through normal event callbacks.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantyx/sdk",
3
- "version": "2026.9.2",
3
+ "version": "2026.10.1",
4
4
  "description": "MANTYX as a hosted agent runtime: define ephemeral agents, mix server-side MANTYX tools with locally-executed tools, run them remotely.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",