@mantyx/sdk 0.23.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.
@@ -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
- { "type": "input_file", "mimeType": "application/pdf", "filename": "report.pdf", "data": "<base64>" },
411
- { "type": "input_file_url", "url": "https://example.com/image.png", "mimeType": "image/png" }
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,16 +438,28 @@ Rules:
428
438
 
429
439
  **File attachments** (`attachments` on the last `user` message, max 20):
430
440
 
431
- | `type` | Fields | Notes |
432
- | ----------------- | --------------------------------------------------- | ----------------------------------------------------------------------------------------- |
433
- | `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. |
434
- | `input_file_url` | `url` (https only), `mimeType?`, `filename?` | Publicly fetchable HTTPS URL. The provider fetches it directly. |
435
-
436
- Allowed MIME types match the workspace chat allowlist (images, PDF, DOCX,
437
- and `text/*` subtypes). Disallowed types, non-HTTPS URLs, malformed base64, or
438
- oversized inline payloads return `400 invalid_request`. Attachments on older
439
- history turns are not re-sent to the model (text only); only the current
440
- turn's files reach the LLM.
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. |
445
+
446
+ Allowed MIME types match the workspace chat allowlist:
447
+
448
+ - **Audio:** `audio/mp4` (M4A), `audio/mpeg` (MP3), `audio/wav`, `audio/webm`.
449
+ - **Images:** `image/jpeg`, `image/png`, `image/webp`, `image/gif`.
450
+ - **Documents:** PDF (`application/pdf`), DOCX
451
+ (`application/vnd.openxmlformats-officedocument.wordprocessingml.document`),
452
+ TXT (`text/plain`), Markdown (`text/markdown`, `text/x-markdown`), CSV/TSV
453
+ (`text/csv`, `application/csv`, `text/comma-separated-values`,
454
+ `text/tab-separated-values`), JSON (`application/json`), XML
455
+ (`application/xml`, `text/xml`), and HTML (`text/html`). Other `text/*`
456
+ subtypes remain accepted.
457
+
458
+ Disallowed types, non-HTTPS URLs, malformed base64, or oversized inline
459
+ payloads return `400 invalid_request`. Attachments on older history turns are
460
+ not re-sent to the model (text only); only the current turn's files reach the
461
+ LLM. Whether the model can interpret an accepted file depends on the selected
462
+ model and provider.
441
463
 
442
464
  ### 4.1 Triggering a persisted MANTYX agent (`agentId`)
443
465
 
@@ -471,15 +493,15 @@ the handler in its own process. MANTYX never executes the body — it
471
493
  emits a `local_tool_call` event when the model picks the tool and waits
472
494
  for the SDK to POST a tool-result.
473
495
 
474
- | Field | Required | Notes |
475
- | -------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
476
- | `kind` | yes | Discriminator literal `"local"`. |
477
- | `name` | yes | Model-facing tool name. Must match `/^[a-zA-Z0-9_]{1,64}$/`. |
478
- | `description` | no | Free-form. Empty when omitted (acceptable, but reduces tool-selection accuracy). |
479
- | `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. |
480
- | `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. |
481
- | `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. |
482
- | `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. |
483
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`. |
484
506
 
485
507
  The `outputSchema`, `longRunning`, `readOnly`, and `retain` fields are
@@ -697,6 +719,15 @@ provider:
697
719
  - **Anthropic / Bedrock-Anthropic** — extended thinking with a budget that
698
720
  scales with strength (≈512 tokens at `low` → ≈8000 at `high`).
699
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
+
700
731
  Two equivalent input shapes are accepted:
701
732
 
702
733
  | Form | Values | Notes |
@@ -732,14 +763,27 @@ reply directly into downstream code without LLM-flavoured prose to parse out.
732
763
  "temperature_c": { "type": "number" }
733
764
  },
734
765
  "required": ["city", "temperature_c"]
735
- }
766
+ },
767
+ "enforcement": "strict" // optional; default "best_effort"
736
768
  }
737
769
  ```
738
770
 
739
- | Field | Required | Notes |
740
- | -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
741
- | `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}$/`. |
742
- | `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. |
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`.
743
787
 
744
788
  Validation (server-side, `400 invalid_request` on violation):
745
789
 
@@ -758,7 +802,7 @@ Validation (server-side, `400 invalid_request` on violation):
758
802
  | Gemini ≤ 2.5 (no-tools turn) | `responseMimeType: "application/json"` + `responseJsonSchema`. |
759
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. |
760
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. |
761
- | xAI Grok, others | Ignored (the model returns plain text). |
805
+ | xAI Grok, others | Best effort may return plain text and reports no enforcement. Strict mode fails explicitly instead of returning an unconstrained success. |
762
806
 
763
807
  The synthetic-tool paths (Gemini 2.5 + tools, Anthropic) are entirely
764
808
  internal: the SDK never receives a `local_tool_call` for
@@ -771,6 +815,31 @@ The terminal `result` event still carries the reply as
771
815
  against its own source-of-truth schema (Zod, Pydantic, …) so it keeps
772
816
  control of error handling on malformed-but-rare provider outputs.
773
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
+
774
843
  **Inheritance for sessions:**
775
844
 
776
845
  - `POST /agent-sessions { outputSchema }` — sets the session-default,
@@ -884,10 +953,9 @@ default research-tool surface is:
884
953
  | ---------------------------------------------------------------------------------------- | ------------------ |
885
954
  | `recall` (workspace memory hybrid search) | `4` |
886
955
  | `traverse` (memory graph BFS) | `3` |
887
- | `hive_consult_ontology` (per-hive ontology read; same name across all three hives) | `4` |
956
+ | `hive_consult_ontology` (per-hive ontology read; same name across both active hives) | `4` |
888
957
  | `hive_search_deals` / `_meetings` / `_companies` / `_people` (Sales Hive general search) | `5` |
889
958
  | `hive_search_tickets` / `_conversations` / `_accounts` (Customer Hive general search) | `5` |
890
- | `hive_search_releases` / `_issues` (Product Hive general search) | `5` |
891
959
 
892
960
  Pass `"toolBudgets": {}` to start from a clean slate (no defaults applied
893
961
  on top — useful for runs that intentionally want unbounded research). When
@@ -951,13 +1019,13 @@ Reviews fire on two triggers:
951
1019
  "supervisor": false // explicitly disable (same as omitting the field)
952
1020
  ```
953
1021
 
954
- | Field | Type | Required | Notes |
955
- | ----------------- | --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------- |
956
- | (literal `true`) | `true` | no | Enables the run supervisor with platform defaults (`interval` 5, reasoning trigger 3000 chars / 30s, workspace judge model). |
957
- | `interval` | integer ≥ 1 | no | Defaults to **5** when the supervisor is enabled and `interval` is omitted. Capped at **100** server-side. |
958
- | `modelId` | string | no | Judge model selector (same grammar as `modelId`). Falls back to workspace `defaultSupervisorModelId`, then workspace default model. |
959
- | `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. |
960
- | (literal `false`) | `false` | no | Disables the run supervisor for this run. `loopDetection` and `toolBudgets` still apply. |
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. |
961
1029
 
962
1030
  **Defaults.** When `supervisor` is **omitted** (or `false`), MANTYX does **not**
963
1031
  run the platform LLM judge on ephemeral API runs. Pass `"supervisor": true`,
@@ -972,8 +1040,8 @@ on API/ephemeral runs only.
972
1040
 
973
1041
  Validation (server-side, `400 invalid_request` on violation):
974
1042
 
975
- | Constraint | Limit |
976
- | ----------------- | ----- |
1043
+ | Constraint | Limit |
1044
+ | ---------------------- | ----- |
977
1045
  | `interval` upper bound | `100` |
978
1046
 
979
1047
  **Inheritance for sessions.**
@@ -1014,19 +1082,19 @@ separate tracker LLM call.
1014
1082
  "plan": false // (or omit) no planning — a plain run
1015
1083
  ```
1016
1084
 
1017
- | Form | Behavior |
1018
- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1019
- | omitted / `false` | No planning. Default. |
1020
- | `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. |
1021
- | `"required"` | Requires `update_task_plan` before substantive tools and rejects premature final answers while required steps remain unfinished (bounded continuation guard). |
1022
- | `{ 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. |
1023
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). |
1024
1092
 
1025
- | Field | Type | Required | Notes |
1026
- | ---------- | -------- | -------- | ---------------------------------------------------------------------------------------------------- |
1027
- | `planOnly` | boolean | no | When `true`, the run stops after producing the plan. |
1028
- | `mode` | string | no | `off`, `auto`, or `required`. Defaults to `auto`. |
1029
- | `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. |
1030
1098
  | `steps` | string[] | no | Caller-provided checklist titles. Empty/omitted ⇒ auto-classify. Count + per-step length clamped server-side. |
1031
1099
 
1032
1100
  Plan-only runs do **not** append an assistant turn to a session (the plan is
@@ -1126,8 +1194,8 @@ Lists the workspace's sessions, most-recently-used first. Supports paging
1126
1194
  and metadata filtering so callers can find earlier sessions by the
1127
1195
  application identifiers they attached at create time (see §4.9).
1128
1196
 
1129
- | Query param | Notes |
1130
- | ----------- | ------------------------------------------------------------------------------------------- |
1197
+ | Query param | Notes |
1198
+ | ----------- | -------------------------------------------------------------------------------------------- |
1131
1199
  | `metadata` | Repeatable `key:value` filter; AND-combined. Malformed entries return `400 invalid_request`. |
1132
1200
  | `status` | Optional exact match (`active` / `ended`). |
1133
1201
  | `limit` | Default `50`, max `200`. |
@@ -1145,13 +1213,13 @@ GET /api/v1/workspaces/acme/agent-sessions?metadata=customer:acme&metadata=env:p
1145
1213
  "sessions": [
1146
1214
  {
1147
1215
  "sessionId": "ses_abc",
1148
- "creationDate": "2026-06-08T17:00:00.000Z", // ISO 8601 — when created
1216
+ "creationDate": "2026-06-08T17:00:00.000Z", // ISO 8601 — when created
1149
1217
  "lastInteractionDate": "2026-06-08T17:42:10.000Z", // ISO 8601 — last message run
1150
- "summary": "How do I reset my password?", // derived from the first user prompt
1218
+ "summary": "How do I reset my password?", // derived from the first user prompt
1151
1219
  "metadata": { "customer": "acme", "env": "prod" },
1152
- "status": "active"
1153
- }
1154
- ]
1220
+ "status": "active",
1221
+ },
1222
+ ],
1155
1223
  }
1156
1224
  ```
1157
1225
 
@@ -1165,10 +1233,10 @@ Returns the session's stored conversation as realtime-style event frames so a
1165
1233
  UI can restore the thread through the same handler it uses for the live SSE
1166
1234
  stream (§7). Unknown session ids return `404 not_found`.
1167
1235
 
1168
- | Query param | Notes |
1169
- | -------------- | ---------------------------------------------------------------------------------------------- |
1170
- | `full` | `1` / `true` returns every message (the default when no paging param is given). |
1171
- | `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. |
1172
1240
 
1173
1241
  ```http
1174
1242
  GET /api/v1/workspaces/acme/agent-sessions/ses_abc/events?lastMessages=2
@@ -1177,11 +1245,11 @@ GET /api/v1/workspaces/acme/agent-sessions/ses_abc/events?lastMessages=2
1177
1245
  ```jsonc
1178
1246
  {
1179
1247
  "sessionId": "ses_abc",
1180
- "total": 4, // total messages in the session (not the page size)
1248
+ "total": 4, // total messages in the session (not the page size)
1181
1249
  "events": [
1182
- { "seq": 3, "type": "user_message", "text": "three" },
1183
- { "seq": 4, "type": "assistant_message", "text": "four" }
1184
- ]
1250
+ { "seq": 3, "type": "user_message", "text": "three" },
1251
+ { "seq": 4, "type": "assistant_message", "text": "four" },
1252
+ ],
1185
1253
  }
1186
1254
  ```
1187
1255
 
@@ -1189,10 +1257,10 @@ Frames use the flattened wire shape clients already consume from SSE
1189
1257
  (`{ seq, type, ...payload }`). `seq` is the message's position in the full
1190
1258
  conversation (stable across paging). Reconstructed turns map as:
1191
1259
 
1192
- | Stored role | Frame `type` |
1193
- | ----------- | ------------------- |
1194
- | `user` | `user_message` |
1195
- | `assistant` | `assistant_message` |
1260
+ | Stored role | Frame `type` |
1261
+ | ----------- | ---------------------------------- |
1262
+ | `user` | `user_message` |
1263
+ | `assistant` | `assistant_message` |
1196
1264
  | other | `message` (carries a `role` field) |
1197
1265
 
1198
1266
  `user_message` is a **replay/restore-only** frame — the live SSE stream never
@@ -1341,6 +1409,12 @@ data: <utf-8 JSON>
1341
1409
  { "seq": 8, "type": "result", "data": {
1342
1410
  "subtype": "success",
1343
1411
  "text": "Final reply",
1412
+ "structuredOutput": {
1413
+ "schemaRequested": true,
1414
+ "schemaEnforced": true,
1415
+ "enforcementMechanism": "native_schema",
1416
+ "unconstrainedFallbackOccurred": false
1417
+ },
1344
1418
  "tokens": { "inputTokens": 1283, "cachedTokens": 512, "reasoningTokens": 96, "outputTokens": 240 },
1345
1419
  "turns": 3,
1346
1420
  "model": { "id": "platform:demo", "provider": "openai", "vendorModelId": "gpt-5.4-mini", "reasoningEffort": "low" }
@@ -1542,9 +1616,9 @@ Request body:
1542
1616
 
1543
1617
  ```jsonc
1544
1618
  {
1545
- "verdict": "UP", // "UP" | "DOWN" (required)
1619
+ "verdict": "UP", // "UP" | "DOWN" (required)
1546
1620
  "explanation": "Nailed it", // optional free-text note (≤ 8000 chars)
1547
- "contentSnapshot": "..." // optional; defaults to the run's finalText
1621
+ "contentSnapshot": "...", // optional; defaults to the run's finalText
1548
1622
  }
1549
1623
  ```
1550
1624
 
@@ -1553,7 +1627,12 @@ repeated call updates the existing row (last-write-wins) and returns `200`; the
1553
1627
  first call returns `201`. Response:
1554
1628
 
1555
1629
  ```jsonc
1556
- { "id": "fb_…", "verdict": "UP", "targetKind": "agent_run", "agentRunId": "run_…" }
1630
+ {
1631
+ "id": "fb_…",
1632
+ "verdict": "UP",
1633
+ "targetKind": "agent_run",
1634
+ "agentRunId": "run_…",
1635
+ }
1557
1636
  ```
1558
1637
 
1559
1638
  The author is attributed to the calling workspace **API key** (`apiKeyId`); OAuth
@@ -1563,7 +1642,24 @@ tokens leave the author null. Recorded feedback surfaces in the workspace
1563
1642
  only** — in-product chat and artifact feedback is workspace-admin only). Unknown
1564
1643
  runs return `404 { "error": "Run not found" }`.
1565
1644
 
1566
- ## 10. Errors
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`.
1567
1663
 
1568
1664
  All non-2xx responses use this body shape:
1569
1665
 
@@ -1579,15 +1675,15 @@ All non-2xx responses use this body shape:
1579
1675
 
1580
1676
  Common codes:
1581
1677
 
1582
- | Code | HTTP | Notes |
1583
- | ------------------ | ---: | -------------------------------------- |
1584
- | `unauthorized` | 401 | Missing/invalid API key |
1585
- | `not_found` | 404 | Workspace, run, or session unknown |
1586
- | `invalid_request` | 400 | Body failed Zod validation |
1587
- | `invalid_model` | 400 | `modelId` couldn't be resolved |
1588
- | `unknown_tool_use` | 404 | Tool-result for an unknown `toolUseId` |
1589
- | `run_terminal` | 409 | Tool-result after run finished |
1590
- | `rate_limited` | 429 | Per-API-key sliding window |
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 |
1591
1687
 
1592
1688
  ## 11. Suggested client architecture
1593
1689