@mantyx/sdk 0.24.0 → 0.25.0
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 +7 -0
- package/README.md +15 -5
- package/dist/a2a-server.cjs +9 -0
- package/dist/a2a-server.cjs.map +1 -1
- package/dist/a2a-server.js +1 -1
- package/dist/{chunk-OUK6ZZ5H.js → chunk-4EJRV6KZ.js} +40 -1
- package/dist/chunk-4EJRV6KZ.js.map +1 -0
- package/dist/client.d.ts +19 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.cjs +40 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/structured-output.d.ts +12 -0
- package/dist/structured-output.d.ts.map +1 -0
- package/dist/version.d.ts +1 -1
- package/docs/agent-runs-protocol.md +171 -87
- package/docs/wire-protocol.md +201 -82
- package/package.json +1 -1
- package/dist/chunk-OUK6ZZ5H.js.map +0 -1
|
@@ -24,15 +24,15 @@ but is not editable from the dashboard.
|
|
|
24
24
|
**Tool refs.** Seven flavours, all carried inside the agent spec's `tools`
|
|
25
25
|
array:
|
|
26
26
|
|
|
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.
|
|
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. |
|
|
36
36
|
|
|
37
37
|
The split is deliberate:
|
|
38
38
|
|
|
@@ -352,6 +352,7 @@ The agent spec is the body shape used by `POST /agent-runs` and `POST
|
|
|
352
352
|
"outputSchema": {
|
|
353
353
|
// optional, see §4.5
|
|
354
354
|
"name": "weather_report",
|
|
355
|
+
"enforcement": "strict",
|
|
355
356
|
"schema": {
|
|
356
357
|
"type": "object",
|
|
357
358
|
"properties": {
|
|
@@ -407,11 +408,20 @@ append to the session).
|
|
|
407
408
|
"role": "user",
|
|
408
409
|
"content": "What's in this file?",
|
|
409
410
|
"attachments": [
|
|
410
|
-
{
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
411
|
+
{
|
|
412
|
+
"type": "input_file",
|
|
413
|
+
"mimeType": "application/pdf",
|
|
414
|
+
"filename": "report.pdf",
|
|
415
|
+
"data": "<base64>",
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"type": "input_file_url",
|
|
419
|
+
"url": "https://example.com/image.png",
|
|
420
|
+
"mimeType": "image/png",
|
|
421
|
+
},
|
|
422
|
+
],
|
|
423
|
+
},
|
|
424
|
+
],
|
|
415
425
|
}
|
|
416
426
|
```
|
|
417
427
|
|
|
@@ -428,10 +438,10 @@ Rules:
|
|
|
428
438
|
|
|
429
439
|
**File attachments** (`attachments` on the last `user` message, max 20):
|
|
430
440
|
|
|
431
|
-
| `type`
|
|
432
|
-
|
|
|
433
|
-
| `input_file`
|
|
434
|
-
| `input_file_url`
|
|
441
|
+
| `type` | Fields | Notes |
|
|
442
|
+
| ---------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
443
|
+
| `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. |
|
|
444
|
+
| `input_file_url` | `url` (https only), `mimeType?`, `filename?` | Publicly fetchable HTTPS URL. The provider fetches it directly. |
|
|
435
445
|
|
|
436
446
|
Allowed MIME types match the workspace chat allowlist:
|
|
437
447
|
|
|
@@ -483,15 +493,15 @@ the handler in its own process. MANTYX never executes the body — it
|
|
|
483
493
|
emits a `local_tool_call` event when the model picks the tool and waits
|
|
484
494
|
for the SDK to POST a tool-result.
|
|
485
495
|
|
|
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.
|
|
496
|
+
| Field | Required | Notes |
|
|
497
|
+
| -------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
498
|
+
| `kind` | yes | Discriminator literal `"local"`. |
|
|
499
|
+
| `name` | yes | Model-facing tool name. Must match `/^[a-zA-Z0-9_]{1,64}$/`. |
|
|
500
|
+
| `description` | no | Free-form. Empty when omitted (acceptable, but reduces tool-selection accuracy). |
|
|
501
|
+
| `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. |
|
|
502
|
+
| `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. |
|
|
503
|
+
| `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. |
|
|
504
|
+
| `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
505
|
| `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
506
|
|
|
497
507
|
The `outputSchema`, `longRunning`, `readOnly`, and `retain` fields are
|
|
@@ -709,6 +719,15 @@ provider:
|
|
|
709
719
|
- **Anthropic / Bedrock-Anthropic** — extended thinking with a budget that
|
|
710
720
|
scales with strength (≈512 tokens at `low` → ≈8000 at `high`).
|
|
711
721
|
|
|
722
|
+
For direct OpenAI reasoning runs, MANTYX keeps `store: false` and carries the
|
|
723
|
+
Responses API's encrypted reasoning items across tool turns. Long-running
|
|
724
|
+
OpenAI contexts can additionally use provider-native compaction, which replaces
|
|
725
|
+
the earlier in-run prefix with an opaque retained-context item instead of
|
|
726
|
+
silently dropping it. These opaque items survive HITL and shutdown checkpoints,
|
|
727
|
+
but are intentionally not persisted into the next separate user chat message.
|
|
728
|
+
OpenRouter, Grok, and generic OpenAI-compatible providers do not receive these
|
|
729
|
+
OpenAI-specific request fields.
|
|
730
|
+
|
|
712
731
|
Two equivalent input shapes are accepted:
|
|
713
732
|
|
|
714
733
|
| Form | Values | Notes |
|
|
@@ -744,14 +763,27 @@ reply directly into downstream code without LLM-flavoured prose to parse out.
|
|
|
744
763
|
"temperature_c": { "type": "number" }
|
|
745
764
|
},
|
|
746
765
|
"required": ["city", "temperature_c"]
|
|
747
|
-
}
|
|
766
|
+
},
|
|
767
|
+
"enforcement": "strict" // optional; default "best_effort"
|
|
748
768
|
}
|
|
749
769
|
```
|
|
750
770
|
|
|
751
|
-
| Field
|
|
752
|
-
|
|
|
753
|
-
| `name`
|
|
754
|
-
| `schema`
|
|
771
|
+
| Field | Required | Notes |
|
|
772
|
+
| ------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
773
|
+
| `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}$/`. |
|
|
774
|
+
| `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. |
|
|
775
|
+
| `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. |
|
|
776
|
+
|
|
777
|
+
`best_effort` is deliberately the default for backward compatibility. OpenAI
|
|
778
|
+
or Gemini schema rejection may be memoized and retried without the schema; the
|
|
779
|
+
terminal event reports that outcome rather than presenting it as enforcement.
|
|
780
|
+
`strict` never consults or writes that memo and never retries without the
|
|
781
|
+
schema. Provider rejection fails with
|
|
782
|
+
`errorClass: "structured_output_schema_rejected"` and preserves the provider's
|
|
783
|
+
message plus `apiStatus` / `apiCode` when available. An unsupported
|
|
784
|
+
provider/model fails as `structured_output_not_supported`; a final response
|
|
785
|
+
that bypasses its required synthetic tool fails as
|
|
786
|
+
`structured_output_not_enforced`.
|
|
755
787
|
|
|
756
788
|
Validation (server-side, `400 invalid_request` on violation):
|
|
757
789
|
|
|
@@ -770,7 +802,7 @@ Validation (server-side, `400 invalid_request` on violation):
|
|
|
770
802
|
| Gemini ≤ 2.5 (no-tools turn) | `responseMimeType: "application/json"` + `responseJsonSchema`. |
|
|
771
803
|
| 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
804
|
| 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 |
|
|
805
|
+
| xAI Grok, others | Best effort may return plain text and reports no enforcement. Strict mode fails explicitly instead of returning an unconstrained success. |
|
|
774
806
|
|
|
775
807
|
The synthetic-tool paths (Gemini 2.5 + tools, Anthropic) are entirely
|
|
776
808
|
internal: the SDK never receives a `local_tool_call` for
|
|
@@ -783,6 +815,31 @@ The terminal `result` event still carries the reply as
|
|
|
783
815
|
against its own source-of-truth schema (Zod, Pydantic, …) so it keeps
|
|
784
816
|
control of error handling on malformed-but-rare provider outputs.
|
|
785
817
|
|
|
818
|
+
Every terminal `result` and `error` from a new server also carries actual
|
|
819
|
+
execution metadata:
|
|
820
|
+
|
|
821
|
+
```json
|
|
822
|
+
{
|
|
823
|
+
"structuredOutput": {
|
|
824
|
+
"schemaRequested": true,
|
|
825
|
+
"schemaEnforced": true,
|
|
826
|
+
"enforcementMechanism": "native_schema",
|
|
827
|
+
"unconstrainedFallbackOccurred": false
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
`enforcementMechanism` is `"native_schema"`, `"synthetic_tool"`, or `"none"`.
|
|
833
|
+
`unconstrainedFallbackOccurred` is run-level and remains `true` if any provider
|
|
834
|
+
call in the run fell back without the requested schema.
|
|
835
|
+
SDK result/error fields are optional so they remain compatible with older
|
|
836
|
+
servers. A strict compatibility test should require `schemaEnforced: true` and
|
|
837
|
+
`unconstrainedFallbackOccurred: false`.
|
|
838
|
+
|
|
839
|
+
`plan: { planOnly: true }` skips the agent execution loop, so it cannot enforce
|
|
840
|
+
a run-level output schema. Combining plan-only execution with strict
|
|
841
|
+
enforcement terminates as `structured_output_not_supported`.
|
|
842
|
+
|
|
786
843
|
**Inheritance for sessions:**
|
|
787
844
|
|
|
788
845
|
- `POST /agent-sessions { outputSchema }` — sets the session-default,
|
|
@@ -896,10 +953,9 @@ default research-tool surface is:
|
|
|
896
953
|
| ---------------------------------------------------------------------------------------- | ------------------ |
|
|
897
954
|
| `recall` (workspace memory hybrid search) | `4` |
|
|
898
955
|
| `traverse` (memory graph BFS) | `3` |
|
|
899
|
-
| `hive_consult_ontology` (per-hive ontology read; same name across
|
|
956
|
+
| `hive_consult_ontology` (per-hive ontology read; same name across both active hives) | `4` |
|
|
900
957
|
| `hive_search_deals` / `_meetings` / `_companies` / `_people` (Sales Hive general search) | `5` |
|
|
901
958
|
| `hive_search_tickets` / `_conversations` / `_accounts` (Customer Hive general search) | `5` |
|
|
902
|
-
| `hive_search_releases` / `_issues` (Product Hive general search) | `5` |
|
|
903
959
|
|
|
904
960
|
Pass `"toolBudgets": {}` to start from a clean slate (no defaults applied
|
|
905
961
|
on top — useful for runs that intentionally want unbounded research). When
|
|
@@ -963,13 +1019,13 @@ Reviews fire on two triggers:
|
|
|
963
1019
|
"supervisor": false // explicitly disable (same as omitting the field)
|
|
964
1020
|
```
|
|
965
1021
|
|
|
966
|
-
| Field
|
|
967
|
-
|
|
|
968
|
-
| (literal `true`)
|
|
969
|
-
| `interval`
|
|
970
|
-
| `modelId`
|
|
971
|
-
| `reasoningTrigger` | `false` \| `{ chars?, ms? }` | no
|
|
972
|
-
| (literal `false`)
|
|
1022
|
+
| Field | Type | Required | Notes |
|
|
1023
|
+
| ------------------ | ---------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1024
|
+
| (literal `true`) | `true` | no | Enables the run supervisor with platform defaults (`interval` 5, reasoning trigger 3000 chars / 30s, workspace judge model). |
|
|
1025
|
+
| `interval` | integer ≥ 1 | no | Defaults to **5** when the supervisor is enabled and `interval` is omitted. Capped at **100** server-side. |
|
|
1026
|
+
| `modelId` | string | no | Judge model selector (same grammar as `modelId`). Falls back to workspace `defaultSupervisorModelId`, then workspace default model. |
|
|
1027
|
+
| `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. |
|
|
1028
|
+
| (literal `false`) | `false` | no | Disables the run supervisor for this run. `loopDetection` and `toolBudgets` still apply. |
|
|
973
1029
|
|
|
974
1030
|
**Defaults.** When `supervisor` is **omitted** (or `false`), MANTYX does **not**
|
|
975
1031
|
run the platform LLM judge on ephemeral API runs. Pass `"supervisor": true`,
|
|
@@ -984,8 +1040,8 @@ on API/ephemeral runs only.
|
|
|
984
1040
|
|
|
985
1041
|
Validation (server-side, `400 invalid_request` on violation):
|
|
986
1042
|
|
|
987
|
-
| Constraint
|
|
988
|
-
|
|
|
1043
|
+
| Constraint | Limit |
|
|
1044
|
+
| ---------------------- | ----- |
|
|
989
1045
|
| `interval` upper bound | `100` |
|
|
990
1046
|
|
|
991
1047
|
**Inheritance for sessions.**
|
|
@@ -1026,19 +1082,19 @@ separate tracker LLM call.
|
|
|
1026
1082
|
"plan": false // (or omit) no planning — a plain run
|
|
1027
1083
|
```
|
|
1028
1084
|
|
|
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.
|
|
1085
|
+
| Form | Behavior |
|
|
1086
|
+
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1087
|
+
| omitted / `false` | No planning. Default. |
|
|
1088
|
+
| `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. |
|
|
1089
|
+
| `"required"` | Requires `update_task_plan` before substantive tools and rejects premature final answers while required steps remain unfinished (bounded continuation guard). |
|
|
1090
|
+
| `{ mode?, steps, brief? }` | Seeds an authoritative checklist. `mode` defaults to `auto`; use `required` to enforce initialization/execution. |
|
|
1035
1091
|
| `{ 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
1092
|
|
|
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.
|
|
1093
|
+
| Field | Type | Required | Notes |
|
|
1094
|
+
| ---------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------- |
|
|
1095
|
+
| `planOnly` | boolean | no | When `true`, the run stops after producing the plan. |
|
|
1096
|
+
| `mode` | string | no | `off`, `auto`, or `required`. Defaults to `auto`. |
|
|
1097
|
+
| `brief` | string | no | One-line objective for a caller-provided plan. Clamped server-side. |
|
|
1042
1098
|
| `steps` | string[] | no | Caller-provided checklist titles. Empty/omitted ⇒ auto-classify. Count + per-step length clamped server-side. |
|
|
1043
1099
|
|
|
1044
1100
|
Plan-only runs do **not** append an assistant turn to a session (the plan is
|
|
@@ -1138,8 +1194,8 @@ Lists the workspace's sessions, most-recently-used first. Supports paging
|
|
|
1138
1194
|
and metadata filtering so callers can find earlier sessions by the
|
|
1139
1195
|
application identifiers they attached at create time (see §4.9).
|
|
1140
1196
|
|
|
1141
|
-
| Query param | Notes
|
|
1142
|
-
| ----------- |
|
|
1197
|
+
| Query param | Notes |
|
|
1198
|
+
| ----------- | -------------------------------------------------------------------------------------------- |
|
|
1143
1199
|
| `metadata` | Repeatable `key:value` filter; AND-combined. Malformed entries return `400 invalid_request`. |
|
|
1144
1200
|
| `status` | Optional exact match (`active` / `ended`). |
|
|
1145
1201
|
| `limit` | Default `50`, max `200`. |
|
|
@@ -1157,13 +1213,13 @@ GET /api/v1/workspaces/acme/agent-sessions?metadata=customer:acme&metadata=env:p
|
|
|
1157
1213
|
"sessions": [
|
|
1158
1214
|
{
|
|
1159
1215
|
"sessionId": "ses_abc",
|
|
1160
|
-
"creationDate": "2026-06-08T17:00:00.000Z",
|
|
1216
|
+
"creationDate": "2026-06-08T17:00:00.000Z", // ISO 8601 — when created
|
|
1161
1217
|
"lastInteractionDate": "2026-06-08T17:42:10.000Z", // ISO 8601 — last message run
|
|
1162
|
-
"summary": "How do I reset my password?",
|
|
1218
|
+
"summary": "How do I reset my password?", // derived from the first user prompt
|
|
1163
1219
|
"metadata": { "customer": "acme", "env": "prod" },
|
|
1164
|
-
"status": "active"
|
|
1165
|
-
}
|
|
1166
|
-
]
|
|
1220
|
+
"status": "active",
|
|
1221
|
+
},
|
|
1222
|
+
],
|
|
1167
1223
|
}
|
|
1168
1224
|
```
|
|
1169
1225
|
|
|
@@ -1177,10 +1233,10 @@ Returns the session's stored conversation as realtime-style event frames so a
|
|
|
1177
1233
|
UI can restore the thread through the same handler it uses for the live SSE
|
|
1178
1234
|
stream (§7). Unknown session ids return `404 not_found`.
|
|
1179
1235
|
|
|
1180
|
-
| Query param | Notes
|
|
1181
|
-
| -------------- |
|
|
1182
|
-
| `full` | `1` / `true` returns every message (the default when no paging param is given).
|
|
1183
|
-
| `lastMessages` | Return only the last `N` messages. Ignored when `full` is set.
|
|
1236
|
+
| Query param | Notes |
|
|
1237
|
+
| -------------- | ------------------------------------------------------------------------------- |
|
|
1238
|
+
| `full` | `1` / `true` returns every message (the default when no paging param is given). |
|
|
1239
|
+
| `lastMessages` | Return only the last `N` messages. Ignored when `full` is set. |
|
|
1184
1240
|
|
|
1185
1241
|
```http
|
|
1186
1242
|
GET /api/v1/workspaces/acme/agent-sessions/ses_abc/events?lastMessages=2
|
|
@@ -1189,11 +1245,11 @@ GET /api/v1/workspaces/acme/agent-sessions/ses_abc/events?lastMessages=2
|
|
|
1189
1245
|
```jsonc
|
|
1190
1246
|
{
|
|
1191
1247
|
"sessionId": "ses_abc",
|
|
1192
|
-
"total": 4,
|
|
1248
|
+
"total": 4, // total messages in the session (not the page size)
|
|
1193
1249
|
"events": [
|
|
1194
|
-
{ "seq": 3, "type": "user_message",
|
|
1195
|
-
{ "seq": 4, "type": "assistant_message", "text": "four" }
|
|
1196
|
-
]
|
|
1250
|
+
{ "seq": 3, "type": "user_message", "text": "three" },
|
|
1251
|
+
{ "seq": 4, "type": "assistant_message", "text": "four" },
|
|
1252
|
+
],
|
|
1197
1253
|
}
|
|
1198
1254
|
```
|
|
1199
1255
|
|
|
@@ -1201,10 +1257,10 @@ Frames use the flattened wire shape clients already consume from SSE
|
|
|
1201
1257
|
(`{ seq, type, ...payload }`). `seq` is the message's position in the full
|
|
1202
1258
|
conversation (stable across paging). Reconstructed turns map as:
|
|
1203
1259
|
|
|
1204
|
-
| Stored role | Frame `type`
|
|
1205
|
-
| ----------- |
|
|
1206
|
-
| `user` | `user_message`
|
|
1207
|
-
| `assistant` | `assistant_message`
|
|
1260
|
+
| Stored role | Frame `type` |
|
|
1261
|
+
| ----------- | ---------------------------------- |
|
|
1262
|
+
| `user` | `user_message` |
|
|
1263
|
+
| `assistant` | `assistant_message` |
|
|
1208
1264
|
| other | `message` (carries a `role` field) |
|
|
1209
1265
|
|
|
1210
1266
|
`user_message` is a **replay/restore-only** frame — the live SSE stream never
|
|
@@ -1353,6 +1409,12 @@ data: <utf-8 JSON>
|
|
|
1353
1409
|
{ "seq": 8, "type": "result", "data": {
|
|
1354
1410
|
"subtype": "success",
|
|
1355
1411
|
"text": "Final reply",
|
|
1412
|
+
"structuredOutput": {
|
|
1413
|
+
"schemaRequested": true,
|
|
1414
|
+
"schemaEnforced": true,
|
|
1415
|
+
"enforcementMechanism": "native_schema",
|
|
1416
|
+
"unconstrainedFallbackOccurred": false
|
|
1417
|
+
},
|
|
1356
1418
|
"tokens": { "inputTokens": 1283, "cachedTokens": 512, "reasoningTokens": 96, "outputTokens": 240 },
|
|
1357
1419
|
"turns": 3,
|
|
1358
1420
|
"model": { "id": "platform:demo", "provider": "openai", "vendorModelId": "gpt-5.4-mini", "reasoningEffort": "low" }
|
|
@@ -1554,9 +1616,9 @@ Request body:
|
|
|
1554
1616
|
|
|
1555
1617
|
```jsonc
|
|
1556
1618
|
{
|
|
1557
|
-
"verdict": "UP",
|
|
1619
|
+
"verdict": "UP", // "UP" | "DOWN" (required)
|
|
1558
1620
|
"explanation": "Nailed it", // optional free-text note (≤ 8000 chars)
|
|
1559
|
-
"contentSnapshot": "..."
|
|
1621
|
+
"contentSnapshot": "...", // optional; defaults to the run's finalText
|
|
1560
1622
|
}
|
|
1561
1623
|
```
|
|
1562
1624
|
|
|
@@ -1565,7 +1627,12 @@ repeated call updates the existing row (last-write-wins) and returns `200`; the
|
|
|
1565
1627
|
first call returns `201`. Response:
|
|
1566
1628
|
|
|
1567
1629
|
```jsonc
|
|
1568
|
-
{
|
|
1630
|
+
{
|
|
1631
|
+
"id": "fb_…",
|
|
1632
|
+
"verdict": "UP",
|
|
1633
|
+
"targetKind": "agent_run",
|
|
1634
|
+
"agentRunId": "run_…",
|
|
1635
|
+
}
|
|
1569
1636
|
```
|
|
1570
1637
|
|
|
1571
1638
|
The author is attributed to the calling workspace **API key** (`apiKeyId`); OAuth
|
|
@@ -1575,7 +1642,24 @@ tokens leave the author null. Recorded feedback surfaces in the workspace
|
|
|
1575
1642
|
only** — in-product chat and artifact feedback is workspace-admin only). Unknown
|
|
1576
1643
|
runs return `404 { "error": "Run not found" }`.
|
|
1577
1644
|
|
|
1578
|
-
## 10.
|
|
1645
|
+
## 10. Rate limits and errors
|
|
1646
|
+
|
|
1647
|
+
Developer API requests use fixed 60-second sliding windows keyed by workspace
|
|
1648
|
+
and credential. New run starts have their own bucket (default 120/min);
|
|
1649
|
+
tool-result callbacks, approvals, feedback, and cancellation use the lifecycle
|
|
1650
|
+
bucket (default 600/min); other mutations default to 120/min. Platform
|
|
1651
|
+
operators can override those three maxima per workspace. Reads, status checks,
|
|
1652
|
+
and SSE opens/reconnects use a separate high transport limit and never consume
|
|
1653
|
+
run-start capacity.
|
|
1654
|
+
|
|
1655
|
+
Metered responses include `X-RateLimit-Limit`, `X-RateLimit-Remaining`,
|
|
1656
|
+
`X-RateLimit-Reset`, and `X-RateLimit-Bucket`. A MANTYX limit returns HTTP
|
|
1657
|
+
`429`, `Retry-After`, and `code: "rate_limit_exceeded"`.
|
|
1658
|
+
|
|
1659
|
+
This is distinct from model-provider throttling. A provider 429 is classified
|
|
1660
|
+
as `errorClass: "rate_limit"` and retried by the agent pipeline. If retries are
|
|
1661
|
+
exhausted, it appears asynchronously in the run's terminal `error` event; the
|
|
1662
|
+
original run-creation request remains `202 Accepted`.
|
|
1579
1663
|
|
|
1580
1664
|
All non-2xx responses use this body shape:
|
|
1581
1665
|
|
|
@@ -1591,15 +1675,15 @@ All non-2xx responses use this body shape:
|
|
|
1591
1675
|
|
|
1592
1676
|
Common codes:
|
|
1593
1677
|
|
|
1594
|
-
| Code
|
|
1595
|
-
|
|
|
1596
|
-
| `unauthorized`
|
|
1597
|
-
| `not_found`
|
|
1598
|
-
| `invalid_request`
|
|
1599
|
-
| `invalid_model`
|
|
1600
|
-
| `unknown_tool_use`
|
|
1601
|
-
| `run_terminal`
|
|
1602
|
-
| `
|
|
1678
|
+
| Code | HTTP | Notes |
|
|
1679
|
+
| --------------------- | ---: | -------------------------------------- |
|
|
1680
|
+
| `unauthorized` | 401 | Missing/invalid API key |
|
|
1681
|
+
| `not_found` | 404 | Workspace, run, or session unknown |
|
|
1682
|
+
| `invalid_request` | 400 | Body failed Zod validation |
|
|
1683
|
+
| `invalid_model` | 400 | `modelId` couldn't be resolved |
|
|
1684
|
+
| `unknown_tool_use` | 404 | Tool-result for an unknown `toolUseId` |
|
|
1685
|
+
| `run_terminal` | 409 | Tool-result after run finished |
|
|
1686
|
+
| `rate_limit_exceeded` | 429 | MANTYX Developer API request bucket |
|
|
1603
1687
|
|
|
1604
1688
|
## 11. Suggested client architecture
|
|
1605
1689
|
|