@mantyx/sdk 0.24.0 → 2026.9.2
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 +28 -1
- package/LICENSE +201 -0
- package/README.md +35 -12
- package/dist/a2a-server.cjs +11 -1
- package/dist/a2a-server.d.ts +2 -1
- package/dist/a2a-server.js +3 -2
- package/dist/{chunk-OUK6ZZ5H.js → chunk-XMNAWLMF.js} +75 -2
- package/dist/client.d.ts +59 -7
- package/dist/computer-use.d.ts +0 -1
- package/dist/errors.d.ts +13 -1
- package/dist/index.cjs +76 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -3
- package/dist/local-resolver.d.ts +0 -1
- package/dist/oauth.d.ts +0 -1
- package/dist/playwright.cjs +0 -1
- package/dist/playwright.d.ts +0 -1
- package/dist/playwright.js +0 -1
- package/dist/sse.d.ts +0 -1
- package/dist/structured-output.d.ts +11 -0
- package/dist/tools.d.ts +0 -1
- package/dist/version.d.ts +2 -3
- package/dist/zod-to-json-schema.d.ts +0 -1
- package/docs/agent-runs-protocol.md +238 -89
- package/docs/wire-protocol.md +201 -82
- package/package.json +17 -18
- package/CONTRIBUTING.md +0 -72
- package/EXTRACT.md +0 -70
- package/dist/a2a-server.cjs.map +0 -1
- package/dist/a2a-server.d.ts.map +0 -1
- package/dist/a2a-server.js.map +0 -1
- package/dist/chunk-OUK6ZZ5H.js.map +0 -1
- package/dist/client.d.ts.map +0 -1
- package/dist/computer-use.d.ts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/local-resolver.d.ts.map +0 -1
- package/dist/oauth.d.ts.map +0 -1
- package/dist/playwright.cjs.map +0 -1
- package/dist/playwright.d.ts.map +0 -1
- package/dist/playwright.js.map +0 -1
- package/dist/sse.d.ts.map +0 -1
- package/dist/tools.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/dist/zod-to-json-schema.d.ts.map +0 -1
|
@@ -1,5 +1,7 @@
|
|
|
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
|
+
|
|
3
5
|
This document specifies the public wire protocol that the MANTYX agent-runs API
|
|
4
6
|
speaks with SDKs. It is the source of truth for anyone implementing a new
|
|
5
7
|
client (Python, Rust, Java…) and is shipped with each first-party SDK so the
|
|
@@ -24,15 +26,15 @@ but is not editable from the dashboard.
|
|
|
24
26
|
**Tool refs.** Seven flavours, all carried inside the agent spec's `tools`
|
|
25
27
|
array:
|
|
26
28
|
|
|
27
|
-
| `kind` | Resolved by | Notes
|
|
28
|
-
| --------------- | ----------- |
|
|
29
|
-
| `mantyx` | server | A workspace `Tool` row referenced by id (HTTP / Code / Plugin).
|
|
30
|
-
| `mantyx_plugin` | server | A platform plugin tool referenced by name.
|
|
31
|
-
| `local` | client | A custom tool defined and executed in the SDK's process. Carries `parameters` (input JSON Schema) plus optional `outputSchema` (return-value JSON Schema), `longRunning`, `readOnly` (parallel-batch), and `retain` (cross-turn replay) flags — see §4.1.1.
|
|
32
|
-
| `a2a` | server | A _remote_ Agent2Agent peer MANTYX can reach; invoked via `message/send` and the reply is surfaced as the tool result.
|
|
33
|
-
| `a2a_local` | client | An A2A peer MANTYX **cannot** reach. SDK resolves the [Agent Card](https://google.github.io/A2A/specification/#agent-card) locally and ships it inline; MANTYX uses it for the model description and routes calls back to the SDK over SSE.
|
|
34
|
-
| `mcp` | server | A _remote_ MCP server (Streamable HTTP). At run start MANTYX lists the catalog and exposes every tool as `<server>_<tool>` (subject to `toolFilter`).
|
|
35
|
-
| `mcp_local` | client | An MCP server MANTYX **cannot** reach. SDK runs `Initialize` + `tools/list` locally and ships the resolved `Tool[]` (with `inputSchema`); MANTYX exposes them to the model with the SDK-declared names and routes calls back over SSE.
|
|
29
|
+
| `kind` | Resolved by | Notes |
|
|
30
|
+
| --------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
31
|
+
| `mantyx` | server | A workspace `Tool` row referenced by id (HTTP / Code / Plugin). |
|
|
32
|
+
| `mantyx_plugin` | server | A platform plugin tool referenced by name. |
|
|
33
|
+
| `local` | client | A custom tool defined and executed in the SDK's process. Carries `parameters` (input JSON Schema) plus optional `outputSchema` (return-value JSON Schema), `longRunning`, `readOnly` (parallel-batch), and `retain` (cross-turn replay) flags — see §4.1.1. |
|
|
34
|
+
| `a2a` | server | A _remote_ Agent2Agent peer MANTYX can reach; invoked via `message/send` and the reply is surfaced as the tool result. |
|
|
35
|
+
| `a2a_local` | client | An A2A peer MANTYX **cannot** reach. SDK resolves the [Agent Card](https://google.github.io/A2A/specification/#agent-card) locally and ships it inline; MANTYX uses it for the model description and routes calls back to the SDK over SSE. |
|
|
36
|
+
| `mcp` | server | A _remote_ MCP server (Streamable HTTP). At run start MANTYX lists the catalog and exposes every tool as `<server>_<tool>` (subject to `toolFilter`). |
|
|
37
|
+
| `mcp_local` | client | An MCP server MANTYX **cannot** reach. SDK runs `Initialize` + `tools/list` locally and ships the resolved `Tool[]` (with `inputSchema`); MANTYX exposes them to the model with the SDK-declared names and routes calls back over SSE. |
|
|
36
38
|
|
|
37
39
|
The split is deliberate:
|
|
38
40
|
|
|
@@ -119,6 +121,7 @@ two differences:
|
|
|
119
121
|
| ------------------------------------------------ | ---------------------- |
|
|
120
122
|
| `GET .../models` | `models:read` |
|
|
121
123
|
| `POST .../agent-runs` | `runs:write` |
|
|
124
|
+
| `GET .../agent-runs` | `runs:read` |
|
|
122
125
|
| `GET .../agent-runs/{runId}` | `runs:read` |
|
|
123
126
|
| `GET .../agent-runs/{runId}/stream` | `runs:read` |
|
|
124
127
|
| `POST .../agent-runs/{runId}/cancel` | `runs:write` |
|
|
@@ -352,6 +355,7 @@ The agent spec is the body shape used by `POST /agent-runs` and `POST
|
|
|
352
355
|
"outputSchema": {
|
|
353
356
|
// optional, see §4.5
|
|
354
357
|
"name": "weather_report",
|
|
358
|
+
"enforcement": "strict",
|
|
355
359
|
"schema": {
|
|
356
360
|
"type": "object",
|
|
357
361
|
"properties": {
|
|
@@ -407,11 +411,20 @@ append to the session).
|
|
|
407
411
|
"role": "user",
|
|
408
412
|
"content": "What's in this file?",
|
|
409
413
|
"attachments": [
|
|
410
|
-
{
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
414
|
+
{
|
|
415
|
+
"type": "input_file",
|
|
416
|
+
"mimeType": "application/pdf",
|
|
417
|
+
"filename": "report.pdf",
|
|
418
|
+
"data": "<base64>",
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
"type": "input_file_url",
|
|
422
|
+
"url": "https://example.com/image.png",
|
|
423
|
+
"mimeType": "image/png",
|
|
424
|
+
},
|
|
425
|
+
],
|
|
426
|
+
},
|
|
427
|
+
],
|
|
415
428
|
}
|
|
416
429
|
```
|
|
417
430
|
|
|
@@ -428,10 +441,10 @@ Rules:
|
|
|
428
441
|
|
|
429
442
|
**File attachments** (`attachments` on the last `user` message, max 20):
|
|
430
443
|
|
|
431
|
-
| `type`
|
|
432
|
-
|
|
|
433
|
-
| `input_file`
|
|
434
|
-
| `input_file_url`
|
|
444
|
+
| `type` | Fields | Notes |
|
|
445
|
+
| ---------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
446
|
+
| `input_file` | `mimeType`, `filename`, `data` (base64, no data-URL prefix) | Inline bytes. Total inline bytes per run are capped (currently 5 MB); larger files must use a URL. |
|
|
447
|
+
| `input_file_url` | `url` (https only), `mimeType?`, `filename?` | Publicly fetchable HTTPS URL. The provider fetches it directly. |
|
|
435
448
|
|
|
436
449
|
Allowed MIME types match the workspace chat allowlist:
|
|
437
450
|
|
|
@@ -483,15 +496,15 @@ the handler in its own process. MANTYX never executes the body — it
|
|
|
483
496
|
emits a `local_tool_call` event when the model picks the tool and waits
|
|
484
497
|
for the SDK to POST a tool-result.
|
|
485
498
|
|
|
486
|
-
| Field | Required | Notes
|
|
487
|
-
| -------------- | -------- |
|
|
488
|
-
| `kind` | yes | Discriminator literal `"local"`.
|
|
489
|
-
| `name` | yes | Model-facing tool name. Must match `/^[a-zA-Z0-9_]{1,64}$/`.
|
|
490
|
-
| `description` | no | Free-form. Empty when omitted (acceptable, but reduces tool-selection accuracy).
|
|
491
|
-
| `parameters` | no | JSON Schema for the tool's input. Must be a `type: "object"` schema with `properties`; non-object roots are coerced to an empty object schema server-side. Forwarded **verbatim** to the LLM provider so nested constraints (`array.items`, `enum`, `anyOf`, numeric formats, …) survive. Args that fail server-side validation produce a structured `tool_input_invalid` tool result the model can recover from instead of crashing the call.
|
|
492
|
-
| `outputSchema` | no | JSON Schema for the structured value the tool returns. When present, forwarded to providers that accept per-tool response schemas (Gemini's `responseJsonSchema` on the FunctionDeclaration); other engines surface it through the description and rely on host-side validation. Helps the model emit follow-up arguments that round-trip cleanly. Must be an object schema; non-object roots are dropped server-side.
|
|
493
|
-
| `longRunning` | no | When `true`, MANTYX appends a stable hint to the model-facing description so every provider treats the tool as long-running:<br>_"NOTE: This is a long-running operation. Do not call this tool again if it has already returned an intermediate or pending status."_<br>Useful for tools that return `pending` and rely on SDK-side polling — without the hint the model routinely fires repeat calls and burns turns. Pure declarative — MANTYX does not change scheduling.
|
|
494
|
-
| `readOnly` | no | When `true`, the tool may run **in parallel** with other read-only tools the model emits in the same turn — MANTYX publishes every such `local_tool_call` concurrently and resolves them together, instead of one-at-a-time in model-emit order. Set this only for side-effect-free tools whose results don't depend on each other, and make sure your SDK can service several outstanding `local_tool_call` events at once (each carries its own `toolUseId`; post a tool-result per id in any order). Mutating tools (the default, `false`) stay strictly sequential.
|
|
499
|
+
| Field | Required | Notes |
|
|
500
|
+
| -------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
501
|
+
| `kind` | yes | Discriminator literal `"local"`. |
|
|
502
|
+
| `name` | yes | Model-facing tool name. Must match `/^[a-zA-Z0-9_]{1,64}$/`. |
|
|
503
|
+
| `description` | no | Free-form. Empty when omitted (acceptable, but reduces tool-selection accuracy). |
|
|
504
|
+
| `parameters` | no | JSON Schema for the tool's input. Must be a `type: "object"` schema with `properties`; non-object roots are coerced to an empty object schema server-side. Forwarded **verbatim** to the LLM provider so nested constraints (`array.items`, `enum`, `anyOf`, numeric formats, …) survive. Args that fail server-side validation produce a structured `tool_input_invalid` tool result the model can recover from instead of crashing the call. |
|
|
505
|
+
| `outputSchema` | no | JSON Schema for the structured value the tool returns. When present, forwarded to providers that accept per-tool response schemas (Gemini's `responseJsonSchema` on the FunctionDeclaration); other engines surface it through the description and rely on host-side validation. Helps the model emit follow-up arguments that round-trip cleanly. Must be an object schema; non-object roots are dropped server-side. |
|
|
506
|
+
| `longRunning` | no | When `true`, MANTYX appends a stable hint to the model-facing description so every provider treats the tool as long-running:<br>_"NOTE: This is a long-running operation. Do not call this tool again if it has already returned an intermediate or pending status."_<br>Useful for tools that return `pending` and rely on SDK-side polling — without the hint the model routinely fires repeat calls and burns turns. Pure declarative — MANTYX does not change scheduling. |
|
|
507
|
+
| `readOnly` | no | When `true`, the tool may run **in parallel** with other read-only tools the model emits in the same turn — MANTYX publishes every such `local_tool_call` concurrently and resolves them together, instead of one-at-a-time in model-emit order. Set this only for side-effect-free tools whose results don't depend on each other, and make sure your SDK can service several outstanding `local_tool_call` events at once (each carries its own `toolUseId`; post a tool-result per id in any order). Mutating tools (the default, `false`) stay strictly sequential. |
|
|
495
508
|
| `retain` | no | When `true`, the tool's result is **persisted with the session and replayed to the model on later turns** of the same session — reconstructed as a `tool_use` + `tool_result` pair in its original place in the transcript. Ordinary tool results only live for the current run (session history keeps user/assistant text only); a retained result survives so a follow-up turn can reference a value it can no longer recompute (a freshly minted id, a one-shot lookup, etc.). Only meaningful for **session-scoped** runs. Keep outputs small — they are stored verbatim (text only; file parts dropped) and capped (~8 KB). Defaults to `false`. |
|
|
496
509
|
|
|
497
510
|
The `outputSchema`, `longRunning`, `readOnly`, and `retain` fields are
|
|
@@ -709,6 +722,15 @@ provider:
|
|
|
709
722
|
- **Anthropic / Bedrock-Anthropic** — extended thinking with a budget that
|
|
710
723
|
scales with strength (≈512 tokens at `low` → ≈8000 at `high`).
|
|
711
724
|
|
|
725
|
+
For direct OpenAI reasoning runs, MANTYX keeps `store: false` and carries the
|
|
726
|
+
Responses API's encrypted reasoning items across tool turns. Long-running
|
|
727
|
+
OpenAI contexts can additionally use provider-native compaction, which replaces
|
|
728
|
+
the earlier in-run prefix with an opaque retained-context item instead of
|
|
729
|
+
silently dropping it. These opaque items survive HITL and shutdown checkpoints,
|
|
730
|
+
but are intentionally not persisted into the next separate user chat message.
|
|
731
|
+
OpenRouter, Grok, and generic OpenAI-compatible providers do not receive these
|
|
732
|
+
OpenAI-specific request fields.
|
|
733
|
+
|
|
712
734
|
Two equivalent input shapes are accepted:
|
|
713
735
|
|
|
714
736
|
| Form | Values | Notes |
|
|
@@ -744,14 +766,27 @@ reply directly into downstream code without LLM-flavoured prose to parse out.
|
|
|
744
766
|
"temperature_c": { "type": "number" }
|
|
745
767
|
},
|
|
746
768
|
"required": ["city", "temperature_c"]
|
|
747
|
-
}
|
|
769
|
+
},
|
|
770
|
+
"enforcement": "strict" // optional; default "best_effort"
|
|
748
771
|
}
|
|
749
772
|
```
|
|
750
773
|
|
|
751
|
-
| Field
|
|
752
|
-
|
|
|
753
|
-
| `name`
|
|
754
|
-
| `schema`
|
|
774
|
+
| Field | Required | Notes |
|
|
775
|
+
| ------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
776
|
+
| `name` | no | Stable identifier passed to providers (OpenAI `text.format.name`, Anthropic synthetic-tool name). Defaults to `"output"`. Must match `/^[a-zA-Z0-9_-]{1,64}$/`. |
|
|
777
|
+
| `schema` | yes | JSON Schema describing the final assistant text. Root must be a JSON **object** (most providers reject array / scalar roots in structured-output mode). The schema is passed through verbatim — MANTYX does not validate its contents; the provider does. |
|
|
778
|
+
| `enforcement` | no | `"best_effort"` (default) preserves the historical provider-rejection fallback. `"strict"` forbids unconstrained fallback and requires evidence that a provider-native schema or synthetic final-result tool was actually used. |
|
|
779
|
+
|
|
780
|
+
`best_effort` is deliberately the default for backward compatibility. OpenAI
|
|
781
|
+
or Gemini schema rejection may be memoized and retried without the schema; the
|
|
782
|
+
terminal event reports that outcome rather than presenting it as enforcement.
|
|
783
|
+
`strict` never consults or writes that memo and never retries without the
|
|
784
|
+
schema. Provider rejection fails with
|
|
785
|
+
`errorClass: "structured_output_schema_rejected"` and preserves the provider's
|
|
786
|
+
message plus `apiStatus` / `apiCode` when available. An unsupported
|
|
787
|
+
provider/model fails as `structured_output_not_supported`; a final response
|
|
788
|
+
that bypasses its required synthetic tool fails as
|
|
789
|
+
`structured_output_not_enforced`.
|
|
755
790
|
|
|
756
791
|
Validation (server-side, `400 invalid_request` on violation):
|
|
757
792
|
|
|
@@ -770,7 +805,7 @@ Validation (server-side, `400 invalid_request` on violation):
|
|
|
770
805
|
| Gemini ≤ 2.5 (no-tools turn) | `responseMimeType: "application/json"` + `responseJsonSchema`. |
|
|
771
806
|
| Gemini ≤ 2.5 (with tools) | Synthetic `set_model_response` function declaration is injected; its `parametersJsonSchema` is the supplied schema. The system instruction is augmented to direct the model to call this tool with the final answer. The engine intercepts the call, hides it from the SDK, and surfaces the call's arguments as the assistant text (JSON-stringified). Sidesteps the API rejection ("Function calling with a response mime type: 'application/json' is unsupported") without round-tripping a 4xx. |
|
|
772
807
|
| Anthropic / Bedrock-Anthropic | Synthetic `final_report` tool whose `input_schema` is the supplied schema; `tool_choice` is forced on the no-tools finishing turn. The tool's input is surfaced as the assistant text. |
|
|
773
|
-
| xAI Grok, others |
|
|
808
|
+
| xAI Grok, others | Best effort may return plain text and reports no enforcement. Strict mode fails explicitly instead of returning an unconstrained success. |
|
|
774
809
|
|
|
775
810
|
The synthetic-tool paths (Gemini 2.5 + tools, Anthropic) are entirely
|
|
776
811
|
internal: the SDK never receives a `local_tool_call` for
|
|
@@ -783,6 +818,31 @@ The terminal `result` event still carries the reply as
|
|
|
783
818
|
against its own source-of-truth schema (Zod, Pydantic, …) so it keeps
|
|
784
819
|
control of error handling on malformed-but-rare provider outputs.
|
|
785
820
|
|
|
821
|
+
Every terminal `result` and `error` from a new server also carries actual
|
|
822
|
+
execution metadata:
|
|
823
|
+
|
|
824
|
+
```json
|
|
825
|
+
{
|
|
826
|
+
"structuredOutput": {
|
|
827
|
+
"schemaRequested": true,
|
|
828
|
+
"schemaEnforced": true,
|
|
829
|
+
"enforcementMechanism": "native_schema",
|
|
830
|
+
"unconstrainedFallbackOccurred": false
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
`enforcementMechanism` is `"native_schema"`, `"synthetic_tool"`, or `"none"`.
|
|
836
|
+
`unconstrainedFallbackOccurred` is run-level and remains `true` if any provider
|
|
837
|
+
call in the run fell back without the requested schema.
|
|
838
|
+
SDK result/error fields are optional so they remain compatible with older
|
|
839
|
+
servers. A strict compatibility test should require `schemaEnforced: true` and
|
|
840
|
+
`unconstrainedFallbackOccurred: false`.
|
|
841
|
+
|
|
842
|
+
`plan: { planOnly: true }` skips the agent execution loop, so it cannot enforce
|
|
843
|
+
a run-level output schema. Combining plan-only execution with strict
|
|
844
|
+
enforcement terminates as `structured_output_not_supported`.
|
|
845
|
+
|
|
786
846
|
**Inheritance for sessions:**
|
|
787
847
|
|
|
788
848
|
- `POST /agent-sessions { outputSchema }` — sets the session-default,
|
|
@@ -896,10 +956,9 @@ default research-tool surface is:
|
|
|
896
956
|
| ---------------------------------------------------------------------------------------- | ------------------ |
|
|
897
957
|
| `recall` (workspace memory hybrid search) | `4` |
|
|
898
958
|
| `traverse` (memory graph BFS) | `3` |
|
|
899
|
-
| `hive_consult_ontology` (per-hive ontology read; same name across
|
|
959
|
+
| `hive_consult_ontology` (per-hive ontology read; same name across both active hives) | `4` |
|
|
900
960
|
| `hive_search_deals` / `_meetings` / `_companies` / `_people` (Sales Hive general search) | `5` |
|
|
901
961
|
| `hive_search_tickets` / `_conversations` / `_accounts` (Customer Hive general search) | `5` |
|
|
902
|
-
| `hive_search_releases` / `_issues` (Product Hive general search) | `5` |
|
|
903
962
|
|
|
904
963
|
Pass `"toolBudgets": {}` to start from a clean slate (no defaults applied
|
|
905
964
|
on top — useful for runs that intentionally want unbounded research). When
|
|
@@ -963,13 +1022,13 @@ Reviews fire on two triggers:
|
|
|
963
1022
|
"supervisor": false // explicitly disable (same as omitting the field)
|
|
964
1023
|
```
|
|
965
1024
|
|
|
966
|
-
| Field
|
|
967
|
-
|
|
|
968
|
-
| (literal `true`)
|
|
969
|
-
| `interval`
|
|
970
|
-
| `modelId`
|
|
971
|
-
| `reasoningTrigger` | `false` \| `{ chars?, ms? }` | no
|
|
972
|
-
| (literal `false`)
|
|
1025
|
+
| Field | Type | Required | Notes |
|
|
1026
|
+
| ------------------ | ---------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1027
|
+
| (literal `true`) | `true` | no | Enables the run supervisor with platform defaults (`interval` 5, reasoning trigger 3000 chars / 30s, workspace judge model). |
|
|
1028
|
+
| `interval` | integer ≥ 1 | no | Defaults to **5** when the supervisor is enabled and `interval` is omitted. Capped at **100** server-side. |
|
|
1029
|
+
| `modelId` | string | no | Judge model selector (same grammar as `modelId`). Falls back to workspace `defaultSupervisorModelId`, then workspace default model. |
|
|
1030
|
+
| `reasoningTrigger` | `false` \| `{ chars?, ms? }` | no | Mid-turn reasoning trigger. Defaults to `{ chars: 3000, ms: 30000 }`. `chars` capped at 50000, `ms` at 600000. Pass `false` to only review at tool-round boundaries. |
|
|
1031
|
+
| (literal `false`) | `false` | no | Disables the run supervisor for this run. `loopDetection` and `toolBudgets` still apply. |
|
|
973
1032
|
|
|
974
1033
|
**Defaults.** When `supervisor` is **omitted** (or `false`), MANTYX does **not**
|
|
975
1034
|
run the platform LLM judge on ephemeral API runs. Pass `"supervisor": true`,
|
|
@@ -984,8 +1043,8 @@ on API/ephemeral runs only.
|
|
|
984
1043
|
|
|
985
1044
|
Validation (server-side, `400 invalid_request` on violation):
|
|
986
1045
|
|
|
987
|
-
| Constraint
|
|
988
|
-
|
|
|
1046
|
+
| Constraint | Limit |
|
|
1047
|
+
| ---------------------- | ----- |
|
|
989
1048
|
| `interval` upper bound | `100` |
|
|
990
1049
|
|
|
991
1050
|
**Inheritance for sessions.**
|
|
@@ -1026,19 +1085,19 @@ separate tracker LLM call.
|
|
|
1026
1085
|
"plan": false // (or omit) no planning — a plain run
|
|
1027
1086
|
```
|
|
1028
1087
|
|
|
1029
|
-
| Form | Behavior
|
|
1030
|
-
| ---------------------------- |
|
|
1031
|
-
| omitted / `false` | No planning. Default.
|
|
1032
|
-
| `true` / `"auto"` | Exposes `update_task_plan`; the executing agent decides during its normal first turn whether multi-step tracking is useful. No separate planning LLM call.
|
|
1033
|
-
| `"required"` | Requires `update_task_plan` before substantive tools and rejects premature final answers while required steps remain unfinished (bounded continuation guard).
|
|
1034
|
-
| `{ mode?, steps, brief? }` | Seeds an authoritative checklist. `mode` defaults to `auto`; use `required` to enforce initialization/execution.
|
|
1088
|
+
| Form | Behavior |
|
|
1089
|
+
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1090
|
+
| omitted / `false` | No planning. Default. |
|
|
1091
|
+
| `true` / `"auto"` | Exposes `update_task_plan`; the executing agent decides during its normal first turn whether multi-step tracking is useful. No separate planning LLM call. |
|
|
1092
|
+
| `"required"` | Requires `update_task_plan` before substantive tools and rejects premature final answers while required steps remain unfinished (bounded continuation guard). |
|
|
1093
|
+
| `{ mode?, steps, brief? }` | Seeds an authoritative checklist. `mode` defaults to `auto`; use `required` to enforce initialization/execution. |
|
|
1035
1094
|
| `{ planOnly: true, steps? }` | Produce the plan (classifier when `steps` omitted, otherwise the provided checklist) and **terminate without executing the agent loop**. The terminal `result` carries `data.plan` (see §7). |
|
|
1036
1095
|
|
|
1037
|
-
| Field | Type | Required | Notes
|
|
1038
|
-
| ---------- | -------- | -------- |
|
|
1039
|
-
| `planOnly` | boolean | no | When `true`, the run stops after producing the plan.
|
|
1040
|
-
| `mode` | string | no | `off`, `auto`, or `required`. Defaults to `auto`.
|
|
1041
|
-
| `brief` | string | no | One-line objective for a caller-provided plan. Clamped server-side.
|
|
1096
|
+
| Field | Type | Required | Notes |
|
|
1097
|
+
| ---------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------- |
|
|
1098
|
+
| `planOnly` | boolean | no | When `true`, the run stops after producing the plan. |
|
|
1099
|
+
| `mode` | string | no | `off`, `auto`, or `required`. Defaults to `auto`. |
|
|
1100
|
+
| `brief` | string | no | One-line objective for a caller-provided plan. Clamped server-side. |
|
|
1042
1101
|
| `steps` | string[] | no | Caller-provided checklist titles. Empty/omitted ⇒ auto-classify. Count + per-step length clamped server-side. |
|
|
1043
1102
|
|
|
1044
1103
|
Plan-only runs do **not** append an assistant turn to a session (the plan is
|
|
@@ -1090,6 +1149,7 @@ public `GET /agent-sessions` endpoint and the admin list endpoints; see
|
|
|
1090
1149
|
|
|
1091
1150
|
```
|
|
1092
1151
|
POST /api/v1/workspaces/{slug}/agent-runs
|
|
1152
|
+
GET /api/v1/workspaces/{slug}/agent-runs
|
|
1093
1153
|
GET /api/v1/workspaces/{slug}/agent-runs/{runId}
|
|
1094
1154
|
GET /api/v1/workspaces/{slug}/agent-runs/{runId}/stream
|
|
1095
1155
|
POST /api/v1/workspaces/{slug}/agent-runs/{runId}/tool-results
|
|
@@ -1108,6 +1168,52 @@ POST /api/v1/workspaces/{slug}/agent-runs/{runId}/feedback
|
|
|
1108
1168
|
|
|
1109
1169
|
`GET .../stream` is the canonical event channel; see §7.
|
|
1110
1170
|
|
|
1171
|
+
`GET /agent-runs` returns compact calls newest-first. Pass its opaque
|
|
1172
|
+
`nextCursor` value back as `cursor` for stable keyset pagination. Supported
|
|
1173
|
+
filters are `status`, `modelId`, `agentId`, and repeatable, AND-combined
|
|
1174
|
+
`metadata=key:value`; `limit` defaults to 50 (max 200). Exact counts are
|
|
1175
|
+
skipped by default; `includeTotal=1` adds `total`.
|
|
1176
|
+
|
|
1177
|
+
```json
|
|
1178
|
+
{
|
|
1179
|
+
"total": null,
|
|
1180
|
+
"limit": 50,
|
|
1181
|
+
"nextCursor": "eyJjcmVhdGVkQXQiOiIyMDI5…",
|
|
1182
|
+
"runs": [
|
|
1183
|
+
{
|
|
1184
|
+
"id": "run_abc",
|
|
1185
|
+
"sessionId": null,
|
|
1186
|
+
"status": "succeeded",
|
|
1187
|
+
"specName": "support-bot",
|
|
1188
|
+
"agentId": null,
|
|
1189
|
+
"modelId": "platform:demo",
|
|
1190
|
+
"inputPreview": "Where is my order?",
|
|
1191
|
+
"outputPreview": "It shipped on Tuesday.",
|
|
1192
|
+
"error": null,
|
|
1193
|
+
"tokens": {
|
|
1194
|
+
"inputTokens": 812,
|
|
1195
|
+
"cachedTokens": 0,
|
|
1196
|
+
"reasoningTokens": 0,
|
|
1197
|
+
"outputTokens": 96
|
|
1198
|
+
},
|
|
1199
|
+
"turns": 2,
|
|
1200
|
+
"durationMs": 4213,
|
|
1201
|
+
"toolCallCount": 1,
|
|
1202
|
+
"metadata": { "customer": "acme" },
|
|
1203
|
+
"createdAt": "2029-01-05T13:00:00.000Z",
|
|
1204
|
+
"completedAt": "2029-01-05T13:00:04.213Z"
|
|
1205
|
+
}
|
|
1206
|
+
]
|
|
1207
|
+
}
|
|
1208
|
+
```
|
|
1209
|
+
|
|
1210
|
+
The list is a projection, not a snapshot: `inputPreview` / `outputPreview` /
|
|
1211
|
+
`error` are truncated, and `total` is `null` unless `includeTotal=1`. Fetch
|
|
1212
|
+
`GET /agent-runs/{runId}` for full text, the spec, and `model`. `modelId`,
|
|
1213
|
+
`durationMs`, and `toolCallCount` are populated when the run reaches a
|
|
1214
|
+
terminal state; `agentId` is `null` for runs that did not target a saved
|
|
1215
|
+
workspace agent.
|
|
1216
|
+
|
|
1111
1217
|
`GET /agent-runs/{runId}` returns the run snapshot (status, final text, error,
|
|
1112
1218
|
spec, plus the cost-attribution triple `tokens` / `turns` / `model` —
|
|
1113
1219
|
see §7.1) without subscribing to live events. Useful for polling long
|
|
@@ -1138,12 +1244,14 @@ Lists the workspace's sessions, most-recently-used first. Supports paging
|
|
|
1138
1244
|
and metadata filtering so callers can find earlier sessions by the
|
|
1139
1245
|
application identifiers they attached at create time (see §4.9).
|
|
1140
1246
|
|
|
1141
|
-
| Query param | Notes
|
|
1142
|
-
| ----------- |
|
|
1247
|
+
| Query param | Notes |
|
|
1248
|
+
| ----------- | -------------------------------------------------------------------------------------------- |
|
|
1143
1249
|
| `metadata` | Repeatable `key:value` filter; AND-combined. Malformed entries return `400 invalid_request`. |
|
|
1144
1250
|
| `status` | Optional exact match (`active` / `ended`). |
|
|
1145
1251
|
| `limit` | Default `50`, max `200`. |
|
|
1146
|
-
| `
|
|
1252
|
+
| `cursor` | Opaque `nextCursor` from the prior page; preferred for deep paging. |
|
|
1253
|
+
| `offset` | Legacy fallback, default `0`; ignored when `cursor` is present. |
|
|
1254
|
+
| `includeTotal` | Defaults to true; set `0` to skip the exact count query. |
|
|
1147
1255
|
|
|
1148
1256
|
```http
|
|
1149
1257
|
GET /api/v1/workspaces/acme/agent-sessions?metadata=customer:acme&metadata=env:prod&limit=20
|
|
@@ -1154,16 +1262,17 @@ GET /api/v1/workspaces/acme/agent-sessions?metadata=customer:acme&metadata=env:p
|
|
|
1154
1262
|
"total": 1,
|
|
1155
1263
|
"limit": 20,
|
|
1156
1264
|
"offset": 0,
|
|
1265
|
+
"nextCursor": null,
|
|
1157
1266
|
"sessions": [
|
|
1158
1267
|
{
|
|
1159
1268
|
"sessionId": "ses_abc",
|
|
1160
|
-
"creationDate": "2026-06-08T17:00:00.000Z",
|
|
1269
|
+
"creationDate": "2026-06-08T17:00:00.000Z", // ISO 8601 — when created
|
|
1161
1270
|
"lastInteractionDate": "2026-06-08T17:42:10.000Z", // ISO 8601 — last message run
|
|
1162
|
-
"summary": "How do I reset my password?",
|
|
1271
|
+
"summary": "How do I reset my password?", // derived from the first user prompt
|
|
1163
1272
|
"metadata": { "customer": "acme", "env": "prod" },
|
|
1164
|
-
"status": "active"
|
|
1165
|
-
}
|
|
1166
|
-
]
|
|
1273
|
+
"status": "active",
|
|
1274
|
+
},
|
|
1275
|
+
],
|
|
1167
1276
|
}
|
|
1168
1277
|
```
|
|
1169
1278
|
|
|
@@ -1177,10 +1286,15 @@ Returns the session's stored conversation as realtime-style event frames so a
|
|
|
1177
1286
|
UI can restore the thread through the same handler it uses for the live SSE
|
|
1178
1287
|
stream (§7). Unknown session ids return `404 not_found`.
|
|
1179
1288
|
|
|
1180
|
-
| Query param | Notes
|
|
1181
|
-
| -------------- |
|
|
1182
|
-
| `full` | `1` / `true` returns
|
|
1183
|
-
| `lastMessages` |
|
|
1289
|
+
| Query param | Notes |
|
|
1290
|
+
| -------------- | ------------------------------------------------------------------------------- |
|
|
1291
|
+
| `full` | `1` / `true` returns the complete history and overrides paging parameters. |
|
|
1292
|
+
| `lastMessages` | Opt into paging and return the last `N` messages (max 500). |
|
|
1293
|
+
| `beforeSeq` | Page backward from an earlier message sequence (default page size 100). |
|
|
1294
|
+
|
|
1295
|
+
For backwards compatibility, omitting all three parameters returns the complete
|
|
1296
|
+
history. New clients should use `lastMessages` and follow `nextBeforeSeq` for
|
|
1297
|
+
bounded reads.
|
|
1184
1298
|
|
|
1185
1299
|
```http
|
|
1186
1300
|
GET /api/v1/workspaces/acme/agent-sessions/ses_abc/events?lastMessages=2
|
|
@@ -1189,22 +1303,25 @@ GET /api/v1/workspaces/acme/agent-sessions/ses_abc/events?lastMessages=2
|
|
|
1189
1303
|
```jsonc
|
|
1190
1304
|
{
|
|
1191
1305
|
"sessionId": "ses_abc",
|
|
1192
|
-
"total": 4,
|
|
1306
|
+
"total": 4, // total messages in the session (not the page size)
|
|
1193
1307
|
"events": [
|
|
1194
|
-
{ "seq": 3, "type": "user_message",
|
|
1195
|
-
{ "seq": 4, "type": "assistant_message", "text": "four" }
|
|
1196
|
-
]
|
|
1308
|
+
{ "seq": 3, "type": "user_message", "text": "three" },
|
|
1309
|
+
{ "seq": 4, "type": "assistant_message", "text": "four" },
|
|
1310
|
+
],
|
|
1311
|
+
"nextBeforeSeq": 3,
|
|
1312
|
+
"truncated": true,
|
|
1197
1313
|
}
|
|
1198
1314
|
```
|
|
1199
1315
|
|
|
1200
1316
|
Frames use the flattened wire shape clients already consume from SSE
|
|
1201
1317
|
(`{ seq, type, ...payload }`). `seq` is the message's position in the full
|
|
1202
|
-
conversation (stable across paging).
|
|
1318
|
+
conversation (stable across paging). `truncated` is true while older messages
|
|
1319
|
+
remain. Reconstructed turns map as:
|
|
1203
1320
|
|
|
1204
|
-
| Stored role | Frame `type`
|
|
1205
|
-
| ----------- |
|
|
1206
|
-
| `user` | `user_message`
|
|
1207
|
-
| `assistant` | `assistant_message`
|
|
1321
|
+
| Stored role | Frame `type` |
|
|
1322
|
+
| ----------- | ---------------------------------- |
|
|
1323
|
+
| `user` | `user_message` |
|
|
1324
|
+
| `assistant` | `assistant_message` |
|
|
1208
1325
|
| other | `message` (carries a `role` field) |
|
|
1209
1326
|
|
|
1210
1327
|
`user_message` is a **replay/restore-only** frame — the live SSE stream never
|
|
@@ -1353,6 +1470,12 @@ data: <utf-8 JSON>
|
|
|
1353
1470
|
{ "seq": 8, "type": "result", "data": {
|
|
1354
1471
|
"subtype": "success",
|
|
1355
1472
|
"text": "Final reply",
|
|
1473
|
+
"structuredOutput": {
|
|
1474
|
+
"schemaRequested": true,
|
|
1475
|
+
"schemaEnforced": true,
|
|
1476
|
+
"enforcementMechanism": "native_schema",
|
|
1477
|
+
"unconstrainedFallbackOccurred": false
|
|
1478
|
+
},
|
|
1356
1479
|
"tokens": { "inputTokens": 1283, "cachedTokens": 512, "reasoningTokens": 96, "outputTokens": 240 },
|
|
1357
1480
|
"turns": 3,
|
|
1358
1481
|
"model": { "id": "platform:demo", "provider": "openai", "vendorModelId": "gpt-5.4-mini", "reasoningEffort": "low" }
|
|
@@ -1554,9 +1677,9 @@ Request body:
|
|
|
1554
1677
|
|
|
1555
1678
|
```jsonc
|
|
1556
1679
|
{
|
|
1557
|
-
"verdict": "UP",
|
|
1680
|
+
"verdict": "UP", // "UP" | "DOWN" (required)
|
|
1558
1681
|
"explanation": "Nailed it", // optional free-text note (≤ 8000 chars)
|
|
1559
|
-
"contentSnapshot": "..."
|
|
1682
|
+
"contentSnapshot": "...", // optional; defaults to the run's finalText
|
|
1560
1683
|
}
|
|
1561
1684
|
```
|
|
1562
1685
|
|
|
@@ -1565,7 +1688,12 @@ repeated call updates the existing row (last-write-wins) and returns `200`; the
|
|
|
1565
1688
|
first call returns `201`. Response:
|
|
1566
1689
|
|
|
1567
1690
|
```jsonc
|
|
1568
|
-
{
|
|
1691
|
+
{
|
|
1692
|
+
"id": "fb_…",
|
|
1693
|
+
"verdict": "UP",
|
|
1694
|
+
"targetKind": "agent_run",
|
|
1695
|
+
"agentRunId": "run_…",
|
|
1696
|
+
}
|
|
1569
1697
|
```
|
|
1570
1698
|
|
|
1571
1699
|
The author is attributed to the calling workspace **API key** (`apiKeyId`); OAuth
|
|
@@ -1575,7 +1703,24 @@ tokens leave the author null. Recorded feedback surfaces in the workspace
|
|
|
1575
1703
|
only** — in-product chat and artifact feedback is workspace-admin only). Unknown
|
|
1576
1704
|
runs return `404 { "error": "Run not found" }`.
|
|
1577
1705
|
|
|
1578
|
-
## 10.
|
|
1706
|
+
## 10. Rate limits and errors
|
|
1707
|
+
|
|
1708
|
+
Developer API requests use fixed 60-second sliding windows keyed by workspace
|
|
1709
|
+
and credential. New run starts have their own bucket (default 120/min);
|
|
1710
|
+
tool-result callbacks, approvals, feedback, and cancellation use the lifecycle
|
|
1711
|
+
bucket (default 600/min); other mutations default to 120/min. Platform
|
|
1712
|
+
operators can override those three maxima per workspace. Reads, status checks,
|
|
1713
|
+
and SSE opens/reconnects use a separate high transport limit and never consume
|
|
1714
|
+
run-start capacity.
|
|
1715
|
+
|
|
1716
|
+
Metered responses include `X-RateLimit-Limit`, `X-RateLimit-Remaining`,
|
|
1717
|
+
`X-RateLimit-Reset`, and `X-RateLimit-Bucket`. A MANTYX limit returns HTTP
|
|
1718
|
+
`429`, `Retry-After`, and `code: "rate_limit_exceeded"`.
|
|
1719
|
+
|
|
1720
|
+
This is distinct from model-provider throttling. A provider 429 is classified
|
|
1721
|
+
as `errorClass: "rate_limit"` and retried by the agent pipeline. If retries are
|
|
1722
|
+
exhausted, it appears asynchronously in the run's terminal `error` event; the
|
|
1723
|
+
original run-creation request remains `202 Accepted`.
|
|
1579
1724
|
|
|
1580
1725
|
All non-2xx responses use this body shape:
|
|
1581
1726
|
|
|
@@ -1591,15 +1736,15 @@ All non-2xx responses use this body shape:
|
|
|
1591
1736
|
|
|
1592
1737
|
Common codes:
|
|
1593
1738
|
|
|
1594
|
-
| Code
|
|
1595
|
-
|
|
|
1596
|
-
| `unauthorized`
|
|
1597
|
-
| `not_found`
|
|
1598
|
-
| `invalid_request`
|
|
1599
|
-
| `invalid_model`
|
|
1600
|
-
| `unknown_tool_use`
|
|
1601
|
-
| `run_terminal`
|
|
1602
|
-
| `
|
|
1739
|
+
| Code | HTTP | Notes |
|
|
1740
|
+
| --------------------- | ---: | -------------------------------------- |
|
|
1741
|
+
| `unauthorized` | 401 | Missing/invalid API key |
|
|
1742
|
+
| `not_found` | 404 | Workspace, run, or session unknown |
|
|
1743
|
+
| `invalid_request` | 400 | Body failed Zod validation |
|
|
1744
|
+
| `invalid_model` | 400 | `modelId` couldn't be resolved |
|
|
1745
|
+
| `unknown_tool_use` | 404 | Tool-result for an unknown `toolUseId` |
|
|
1746
|
+
| `run_terminal` | 409 | Tool-result after run finished |
|
|
1747
|
+
| `rate_limit_exceeded` | 429 | MANTYX Developer API request bucket |
|
|
1603
1748
|
|
|
1604
1749
|
## 11. Suggested client architecture
|
|
1605
1750
|
|
|
@@ -1681,3 +1826,7 @@ A reference SDK should:
|
|
|
1681
1826
|
The npm package [`@mantyx/sdk`](https://www.npmjs.com/package/@mantyx/sdk) and the Go module
|
|
1682
1827
|
[`github.com/mantyx/mantyx-go-sdk`](https://github.com/mantyx/mantyx-go-sdk) are reference implementations of this protocol
|
|
1683
1828
|
(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.
|