@mantyx/sdk 2026.11.6 → 2026.11.8
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 +25 -0
- package/README.md +10 -59
- package/dist/a2a-server.cjs +2 -4
- package/dist/a2a-server.d.ts +5 -8
- package/dist/a2a-server.js +3 -5
- package/dist/{chunk-4WXIAVUB.js → chunk-HZGH34UW.js} +2 -198
- package/dist/client.d.ts +4 -199
- package/dist/decisions.d.ts +33 -4
- package/dist/index.cjs +3 -201
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -6
- package/dist/tools.d.ts +1 -13
- package/dist/version.d.ts +1 -1
- package/docs/agent-runs-protocol.md +97 -174
- package/docs/wire-protocol.md +37 -65
- package/package.json +2 -2
|
@@ -16,18 +16,16 @@ Companion documents:
|
|
|
16
16
|
|
|
17
17
|
## 1. Concepts
|
|
18
18
|
|
|
19
|
-
**Ephemeral agent.** A run-time agent that is _defined by the request_
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
**Ephemeral agent.** A run-time agent that is _defined by the request_. MANTYX
|
|
20
|
+
does not store agent definitions: the full spec (system prompt, model, tools)
|
|
21
|
+
travels on every `POST /agent-runs` / `POST /agent-sessions` call and is kept
|
|
22
|
+
as part of each session/run for observability only.
|
|
23
23
|
|
|
24
|
-
**Tool refs.**
|
|
24
|
+
**Tool refs.** Five flavours, all carried inside the agent spec's `tools`
|
|
25
25
|
array:
|
|
26
26
|
|
|
27
27
|
| `kind` | Resolved by | Notes |
|
|
28
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
29
|
| `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
30
|
| `a2a` | server | A _remote_ Agent2Agent peer MANTYX can reach; invoked via `message/send` and the reply is surfaced as the tool result. |
|
|
33
31
|
| `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,11 +34,10 @@ array:
|
|
|
36
34
|
|
|
37
35
|
The split is deliberate:
|
|
38
36
|
|
|
39
|
-
- **Server-resolved** (`
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
fetch).
|
|
37
|
+
- **Server-resolved** (`a2a`, `mcp`) — MANTYX has network access to the
|
|
38
|
+
resource. The worker runs the tool itself and the SDK only sees an
|
|
39
|
+
informational `tool_result` event in the SSE stream. MANTYX also does
|
|
40
|
+
discovery (`listTools`, agent-card fetch).
|
|
44
41
|
- **Client-resolved / "local"** (`local`, `a2a_local`, `mcp_local`) —
|
|
45
42
|
MANTYX has _no_ access to the resource. The SDK does **all** of the
|
|
46
43
|
work: connection, discovery, listing, expansion, arg validation, auth,
|
|
@@ -92,13 +89,11 @@ policy and are tracked per-credential.
|
|
|
92
89
|
|
|
93
90
|
### 2.1 Workspace API keys (machine credentials)
|
|
94
91
|
|
|
95
|
-
A workspace
|
|
96
|
-
**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
are visible to `spec.agentId` and ephemeral runs created from the key.
|
|
101
|
-
- **Plan gate** — the workspace tier must include the `apiKeys` feature.
|
|
92
|
+
A workspace member can create, rename, and revoke their own keys under
|
|
93
|
+
**Integrate → API keys**. Workspace admins can manage all keys in that
|
|
94
|
+
workspace, including older keys issued before ownership was recorded.
|
|
95
|
+
New keys stop authenticating while their owner’s account is locked.
|
|
96
|
+
Removing the owner from the workspace revokes their keys.
|
|
102
97
|
|
|
103
98
|
API keys carry no granular scopes; possession of a Developer-API key is
|
|
104
99
|
enough to call every route in this document.
|
|
@@ -125,6 +120,7 @@ two differences:
|
|
|
125
120
|
| `POST .../agent-runs/{runId}/cancel` | `runs:write` |
|
|
126
121
|
| `POST .../agent-runs/{runId}/tool-results` | `runs:write` |
|
|
127
122
|
| `POST .../agent-runs/{runId}/feedback` | `feedback:write` |
|
|
123
|
+
| `GET .../reply-feedback` | `feedback:read` |
|
|
128
124
|
| `POST .../agent-sessions` | `sessions:write` |
|
|
129
125
|
| `GET .../agent-sessions` | `sessions:read` |
|
|
130
126
|
| `GET .../agent-sessions/{sessionId}` | `sessions:read` |
|
|
@@ -144,13 +140,10 @@ two differences:
|
|
|
144
140
|
`/api/v1/workspaces/{otherSlug}/...` with such a token returns
|
|
145
141
|
`404 not_found` plus a `hint` with the correct slug.
|
|
146
142
|
|
|
147
|
-
|
|
148
|
-
(`
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
- PKCE flow. PKCE (`S256`) is mandatory and every MANTYX OAuth app is a
|
|
152
|
-
confidential client, so the token endpoint requires both `client_secret`
|
|
153
|
-
and `code_verifier`.
|
|
143
|
+
See [`docs/oauth.md`](./oauth.md) for the full registration and
|
|
144
|
+
authorization-code + PKCE flow. PKCE (`S256`) is mandatory and every MANTYX
|
|
145
|
+
OAuth app is a confidential client, so the token endpoint requires both
|
|
146
|
+
`client_secret` and `code_verifier`.
|
|
154
147
|
|
|
155
148
|
**Token lifetimes.** Access tokens live **1 hour** (`expires_in: 3600`).
|
|
156
149
|
Refresh tokens are **persistent and non-rotating**: they have no
|
|
@@ -256,13 +249,10 @@ The agent spec is the body shape used by `POST /agent-runs` and `POST
|
|
|
256
249
|
```jsonc
|
|
257
250
|
{
|
|
258
251
|
"name": "ephemeral", // optional, observability only
|
|
259
|
-
"
|
|
260
|
-
"systemPrompt": "You are helpful.", // required unless agentId is set
|
|
252
|
+
"systemPrompt": "You are helpful.", // required (or a `system` message, see §4.0.1)
|
|
261
253
|
"modelId": "platform:cm6abc123", // optional, see §3
|
|
262
254
|
"reasoningLevel": "medium", // optional, see §4.4
|
|
263
255
|
"tools": [
|
|
264
|
-
{ "kind": "mantyx", "id": "tool_cm6..." },
|
|
265
|
-
{ "kind": "mantyx_plugin", "name": "web_search" },
|
|
266
256
|
{
|
|
267
257
|
"kind": "local",
|
|
268
258
|
"name": "read_file",
|
|
@@ -370,15 +360,14 @@ The agent spec is the body shape used by `POST /agent-runs` and `POST
|
|
|
370
360
|
},
|
|
371
361
|
"toolBudgets": {
|
|
372
362
|
// optional, see §4.7
|
|
373
|
-
"
|
|
374
|
-
"hive_consult_ontology": { "maxCalls": 4 },
|
|
363
|
+
"search_docs": { "maxCalls": 4 },
|
|
375
364
|
"scary_tool": { "maxCalls": 0 },
|
|
376
365
|
},
|
|
377
366
|
"supervisor": {
|
|
378
367
|
// optional, see §4.8 — platform LLM judge; pass false to disable
|
|
379
368
|
"interval": 5,
|
|
380
369
|
},
|
|
381
|
-
"plan": true, // optional, see §4.9 —
|
|
370
|
+
"plan": true, // optional, see §4.9 — task plan (opt-in)
|
|
382
371
|
"metadata": {
|
|
383
372
|
// optional, see §4.10
|
|
384
373
|
"customer": "acme",
|
|
@@ -430,8 +419,8 @@ Rules:
|
|
|
430
419
|
|
|
431
420
|
- **`role`** is one of `user`, `assistant`, `system`. `system` messages are
|
|
432
421
|
applied as additional system context, **appended after** the spec's
|
|
433
|
-
`systemPrompt` (both apply). A run is valid when it has
|
|
434
|
-
|
|
422
|
+
`systemPrompt` (both apply). A run is valid when it has a `systemPrompt`
|
|
423
|
+
**or** at least one non-empty `system` message in `messages`.
|
|
435
424
|
- The **last non-system message must be `role: "user"`** (`400` otherwise) —
|
|
436
425
|
it is the current turn the model responds to, and the only message whose
|
|
437
426
|
`attachments` are sent to the model.
|
|
@@ -444,7 +433,7 @@ Rules:
|
|
|
444
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. |
|
|
445
434
|
| `input_file_url` | `url` (https only), `mimeType?`, `filename?` | Publicly fetchable HTTPS URL (max 8,192 characters, including signed query parameters). The provider fetches it directly. |
|
|
446
435
|
|
|
447
|
-
Allowed MIME types
|
|
436
|
+
Allowed MIME types:
|
|
448
437
|
|
|
449
438
|
- **Audio:** `audio/mp4` (M4A), `audio/mpeg` (MP3), `audio/wav`, `audio/webm`.
|
|
450
439
|
- **Images:** `image/jpeg`, `image/png`, `image/webp`, `image/gif`.
|
|
@@ -495,8 +484,8 @@ primaryModelId, fallbackModelId }`. Session details expose each call's actual
|
|
|
495
484
|
|
|
496
485
|
Optional string on `POST /agent-runs` and on
|
|
497
486
|
`POST /agent-sessions/:id/messages`. The model sees it for that run only. Use
|
|
498
|
-
it for context that belongs to one turn: retrieved records, a
|
|
499
|
-
|
|
487
|
+
it for context that belongs to one turn: retrieved records, a playbook
|
|
488
|
+
body, a reminder or nudge.
|
|
500
489
|
|
|
501
490
|
Where it goes depends on `turnInstructionsAuthority` (optional, same two
|
|
502
491
|
endpoints, this run only) and on the run's provider and model:
|
|
@@ -579,30 +568,31 @@ SDKs: TypeScript `turnInstructions` / `turnInstructionsAuthority` (run spec,
|
|
|
579
568
|
`RunSpec.TurnInstructionsAuthority` and `WithTurnInstructions` /
|
|
580
569
|
`WithTurnInstructionsAuthority`.
|
|
581
570
|
|
|
582
|
-
### 4.1
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
571
|
+
### 4.1 Tool refs
|
|
572
|
+
|
|
573
|
+
`tools` is an array of tool refs discriminated by `kind`. The agent is always
|
|
574
|
+
defined inline: there is no stored agent to reference. `POST /agent-runs`
|
|
575
|
+
requires `systemPrompt` **or** a non-empty `system` message in `messages`
|
|
576
|
+
(§4.0.1); `POST /agent-sessions` requires `systemPrompt`.
|
|
577
|
+
|
|
578
|
+
| `kind` | Section |
|
|
579
|
+
| ----------- | ------- |
|
|
580
|
+
| `local` | §4.1.1 |
|
|
581
|
+
| `a2a` | §4.2 |
|
|
582
|
+
| `a2a_local` | §4.2 |
|
|
583
|
+
| `mcp` | §4.3 |
|
|
584
|
+
| `mcp_local` | §4.3 |
|
|
585
|
+
|
|
586
|
+
Earlier protocol versions also accepted an `agentId` field (run a stored
|
|
587
|
+
workspace agent) and the `mantyx` / `mantyx_plugin` tool kinds (stored
|
|
588
|
+
workspace tools and installed plugin tools). MANTYX no longer stores agents,
|
|
589
|
+
tools, or plugins, and those fields are no longer part of the protocol:
|
|
590
|
+
|
|
591
|
+
- `agentId` is **silently ignored**. A request that relied on it and carries
|
|
592
|
+
no `systemPrompt` (and, for `POST /agent-runs`, no non-empty `system`
|
|
593
|
+
message) fails validation with `400` (`systemPrompt is required`).
|
|
594
|
+
- A tool ref with `kind: "mantyx"` or `kind: "mantyx_plugin"` is **rejected**
|
|
595
|
+
by schema validation with `400 invalid_request`.
|
|
606
596
|
|
|
607
597
|
### 4.1.1 `kind: "local"` — generic local tools
|
|
608
598
|
|
|
@@ -666,12 +656,9 @@ agent's text reply back as the tool result.
|
|
|
666
656
|
| `headers` | no | Flat string→string HTTP headers sent on every A2A request — typically `Authorization`. Each value is capped at 8 KB. |
|
|
667
657
|
| `contextId` | no | A2A `contextId` to thread multiple delegations into the same remote conversation. Omit for fresh per-call context. |
|
|
668
658
|
|
|
669
|
-
> **Secret handling.** `headers` are forwarded **as-is** by the SDK API.
|
|
670
|
-
>
|
|
671
|
-
>
|
|
672
|
-
> support `{{secret:NAME}}` resolution against the workspace secrets store
|
|
673
|
-
> (see `runtime/a2a-client.ts`). The wire-protocol `a2a` ref is best for
|
|
674
|
-
> short-lived per-run tokens minted by your application.
|
|
659
|
+
> **Secret handling.** `headers` are forwarded **as-is** by the SDK API.
|
|
660
|
+
> The wire-protocol `a2a` ref is best for short-lived per-run tokens minted
|
|
661
|
+
> by your application.
|
|
675
662
|
|
|
676
663
|
#### `kind: "a2a_local"` — local A2A
|
|
677
664
|
|
|
@@ -842,7 +829,7 @@ Responses API's encrypted reasoning items across tool turns. Long-running
|
|
|
842
829
|
OpenAI contexts can additionally use provider-native compaction, which replaces
|
|
843
830
|
the earlier in-run prefix with an opaque retained-context item instead of
|
|
844
831
|
silently dropping it. These opaque items survive HITL and shutdown checkpoints,
|
|
845
|
-
but are intentionally not persisted into the next separate user
|
|
832
|
+
but are intentionally not persisted into the next separate user message.
|
|
846
833
|
OpenRouter, Grok, and generic OpenAI-compatible providers do not receive these
|
|
847
834
|
OpenAI-specific request fields.
|
|
848
835
|
|
|
@@ -850,12 +837,10 @@ Two equivalent input shapes are accepted:
|
|
|
850
837
|
|
|
851
838
|
| Form | Values | Notes |
|
|
852
839
|
| ---------- | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
853
|
-
| **String** | `"off"`, `"low"`, `"medium"`, `"high"` | Snaps to
|
|
840
|
+
| **String** | `"off"`, `"low"`, `"medium"`, `"high"` | Snaps to fixed anchors: off=0, low=30, medium=50, high=80. |
|
|
854
841
|
| **Number** | integer `0`–`100` | Pass-through to `RunAgentOptions.reasoningLevel`. `0` explicitly disables provider thinking even on reasoning models. |
|
|
855
842
|
|
|
856
|
-
When omitted,
|
|
857
|
-
specs, that means thinking is off; for `agentId`-backed specs, it follows
|
|
858
|
-
the persisted `Agent` configuration.
|
|
843
|
+
When omitted, thinking is off.
|
|
859
844
|
|
|
860
845
|
For session-scoped runs the inheritance rules are:
|
|
861
846
|
|
|
@@ -893,8 +878,7 @@ Provider create (`POST /api/llm-providers`, including marketplace connections
|
|
|
893
878
|
and BYOK duplication) accepts `openRouterProvider` as a stored default on the
|
|
894
879
|
workspace provider. Provider update (`PATCH /api/llm-providers/:id`) also accepts
|
|
895
880
|
`null` to clear the default. Provider responses return the object or `null`.
|
|
896
|
-
|
|
897
|
-
the stored value unchanged does not.
|
|
881
|
+
Managing workspace provider connections and routing defaults requires a workspace admin.
|
|
898
882
|
|
|
899
883
|
Effective routing is a shallow per-key merge:
|
|
900
884
|
`{ ...providerDefault, ...runOverride }`. Arrays and nested objects in the
|
|
@@ -1026,10 +1010,7 @@ enforcement terminates as `structured_output_not_supported`.
|
|
|
1026
1010
|
per-message override; applies to that one run only and does not mutate
|
|
1027
1011
|
the session's stored value.
|
|
1028
1012
|
|
|
1029
|
-
|
|
1030
|
-
`agentId`-backed runs — the runner applies the schema to whatever
|
|
1031
|
-
`AgentSpec` it built for the run. When the field is omitted, runs return
|
|
1032
|
-
unconstrained plain text as before.
|
|
1013
|
+
When the field is omitted, runs return unconstrained plain text.
|
|
1033
1014
|
|
|
1034
1015
|
### 4.6 `loopDetection` (steering nudge + hard cutoff)
|
|
1035
1016
|
|
|
@@ -1076,9 +1057,7 @@ Validation (server-side, `400 invalid_request` on violation):
|
|
|
1076
1057
|
|
|
1077
1058
|
**Defaults.** When `loopDetection` is omitted entirely, MANTYX applies the
|
|
1078
1059
|
runtime defaults from `runtime/default-run-guards.ts`:
|
|
1079
|
-
`{ consecutiveThreshold: 3, hardCutoffThreshold: 6 }`.
|
|
1080
|
-
configuration used by every in-process runner (chat, schedule, inbound) so
|
|
1081
|
-
SDK-driven runs and platform-driven runs behave identically.
|
|
1060
|
+
`{ consecutiveThreshold: 3, hardCutoffThreshold: 6 }`.
|
|
1082
1061
|
|
|
1083
1062
|
**Inheritance for sessions.**
|
|
1084
1063
|
|
|
@@ -1103,17 +1082,16 @@ tool result.
|
|
|
1103
1082
|
|
|
1104
1083
|
```jsonc
|
|
1105
1084
|
"toolBudgets": {
|
|
1106
|
-
"
|
|
1107
|
-
"
|
|
1108
|
-
"
|
|
1109
|
-
"scary_tool": { "maxCalls": 0 } // disables the tool for this run
|
|
1085
|
+
"search_docs": { "maxCalls": 4 },
|
|
1086
|
+
"fetch_page": { "maxCalls": 3 },
|
|
1087
|
+
"scary_tool": { "maxCalls": 0 } // disables the tool for this run
|
|
1110
1088
|
}
|
|
1111
1089
|
```
|
|
1112
1090
|
|
|
1113
1091
|
| Field | Type | Required | Notes |
|
|
1114
1092
|
| ---------- | ----------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1115
1093
|
| `<key>` | string | yes | Logical tool name as the model sees it (the same name on `ResolvedTool.name`; the SDK + pipeline handle sanitisation). 1–120 characters. |
|
|
1116
|
-
| `maxCalls` | integer ≥ 0 | yes | Hard cap on executed calls per run. `0` disables the tool entirely (every attempt returns the synthetic body on the first try). Budgets are **per-tool, not pooled**: `
|
|
1094
|
+
| `maxCalls` | integer ≥ 0 | yes | Hard cap on executed calls per run. `0` disables the tool entirely (every attempt returns the synthetic body on the first try). Budgets are **per-tool, not pooled**: `search_docs: { maxCalls: 5 }` and `search_tickets: { maxCalls: 5 }` give the agent five of each, not five between them. |
|
|
1117
1095
|
|
|
1118
1096
|
Validation (server-side, `400 invalid_request` on violation):
|
|
1119
1097
|
|
|
@@ -1123,22 +1101,10 @@ Validation (server-side, `400 invalid_request` on violation):
|
|
|
1123
1101
|
| `<key>` length | `1..120` chars |
|
|
1124
1102
|
| `maxCalls` upper bound | `1000` (functionally unlimited; the SDK's `maxToolTurns: 100` fires first) |
|
|
1125
1103
|
|
|
1126
|
-
**Defaults.**
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
| Tool | Default `maxCalls` |
|
|
1131
|
-
| ---------------------------------------------------------------------------------------- | ------------------ |
|
|
1132
|
-
| `recall` (workspace memory hybrid search) | `4` |
|
|
1133
|
-
| `traverse` (memory graph BFS) | `3` |
|
|
1134
|
-
| `hive_consult_ontology` (per-hive ontology read; same name across both active hives) | `4` |
|
|
1135
|
-
| `hive_search_deals` / `_meetings` / `_companies` / `_people` (Sales Hive general search) | `5` |
|
|
1136
|
-
| `hive_search_tickets` / `_conversations` / `_accounts` (Customer Hive general search) | `5` |
|
|
1137
|
-
|
|
1138
|
-
Pass `"toolBudgets": {}` to start from a clean slate (no defaults applied
|
|
1139
|
-
on top — useful for runs that intentionally want unbounded research). When
|
|
1140
|
-
both the caller and the runtime defaults specify a budget for the same
|
|
1141
|
-
tool, **the caller's value wins**.
|
|
1104
|
+
**Defaults.** No tool is capped by default: when `toolBudgets` is omitted,
|
|
1105
|
+
only the budgets you send apply (loop detection, §4.6, still guards against
|
|
1106
|
+
repeated identical batches). `"toolBudgets": {}` is accepted and is
|
|
1107
|
+
equivalent to sending no budgets.
|
|
1142
1108
|
|
|
1143
1109
|
**Inheritance for sessions.**
|
|
1144
1110
|
|
|
@@ -1149,18 +1115,11 @@ tool, **the caller's value wins**.
|
|
|
1149
1115
|
the session's stored value.
|
|
1150
1116
|
|
|
1151
1117
|
**Observability.** Each interception emits a SSE `tool_budget_exceeded`
|
|
1152
|
-
event (see §7) so SDK clients can render `
|
|
1118
|
+
event (see §7) so SDK clients can render `search budget exhausted` /
|
|
1153
1119
|
`research cap reached` status notes. The synthetic tool-result is emitted
|
|
1154
1120
|
on the normal `tool_result` channel just like any other server-resolved
|
|
1155
1121
|
result, so the run timeline stays linear.
|
|
1156
1122
|
|
|
1157
|
-
**Tools NOT capped by default.** `hive_list_*` and `hive_get_*` are
|
|
1158
|
-
intentionally not in the default budget map — agents legitimately call
|
|
1159
|
-
them once per entity-of-interest, which can easily exceed any small cap
|
|
1160
|
-
during normal multi-entity reads. The loop-detection guard catches the
|
|
1161
|
-
pathological "same `(name, args)` batch over and over" case for that
|
|
1162
|
-
family without needing per-tool caps.
|
|
1163
|
-
|
|
1164
1123
|
### 4.8 `supervisor` (run judge)
|
|
1165
1124
|
|
|
1166
1125
|
`supervisor` controls the optional **run supervisor** — an LLM judge that
|
|
@@ -1237,8 +1196,8 @@ the verdict by the time the event arrives.
|
|
|
1237
1196
|
|
|
1238
1197
|
### 4.9 `plan` (task plan / plan-only)
|
|
1239
1198
|
|
|
1240
|
-
`plan` turns on the
|
|
1241
|
-
|
|
1199
|
+
`plan` turns on the **task plan**, a live checklist the agent maintains as
|
|
1200
|
+
it works. It is **opt-in** on API/ephemeral runs,
|
|
1242
1201
|
same as `supervisor` (§4.8). Active plans are owned by the executing agent
|
|
1243
1202
|
through the host `update_task_plan` tool; there is no pre-flight classifier or
|
|
1244
1203
|
separate tracker LLM call.
|
|
@@ -1291,7 +1250,7 @@ runs do not use the classifier/tracker path.
|
|
|
1291
1250
|
|
|
1292
1251
|
`metadata` is a flat string→string KV that is **persisted alongside the run /
|
|
1293
1252
|
session** and surfaced in the MANTYX dashboard. Use it to tag runs with your
|
|
1294
|
-
own application identifiers (`customer`, `env`, `
|
|
1253
|
+
own application identifiers (`customer`, `env`, `feature`, `trace_id`, …) so
|
|
1295
1254
|
your team can filter the observability UI without reverse-engineering the
|
|
1296
1255
|
prompt.
|
|
1297
1256
|
|
|
@@ -1326,8 +1285,8 @@ A run that calls tools makes several model calls ("turns"). Models often
|
|
|
1326
1285
|
write a sentence before a tool call ("Let me check the order history.") and
|
|
1327
1286
|
the answer after the last one. The run's reply text — the terminal
|
|
1328
1287
|
`result.text` (and `partialText` on a salvaged `error`), the run's stored
|
|
1329
|
-
final text, the assistant message appended to session history
|
|
1330
|
-
|
|
1288
|
+
final text, and the assistant message appended to session history —
|
|
1289
|
+
contains every turn's visible text in order, with a
|
|
1331
1290
|
paragraph break between turns, so one turn's last sentence is never glued
|
|
1332
1291
|
onto the next turn's first.
|
|
1333
1292
|
|
|
@@ -1381,7 +1340,7 @@ POST /api/v1/workspaces/{slug}/agent-runs/{runId}/feedback
|
|
|
1381
1340
|
|
|
1382
1341
|
`GET /agent-runs` returns compact calls newest-first. Pass its opaque
|
|
1383
1342
|
`nextCursor` value back as `cursor` for stable keyset pagination. Supported
|
|
1384
|
-
filters are `status`, `modelId`,
|
|
1343
|
+
filters are `status`, `modelId`, and repeatable, AND-combined
|
|
1385
1344
|
`metadata=key:value`; `limit` defaults to 50 (max 200). Exact counts are
|
|
1386
1345
|
skipped by default; `includeTotal=1` adds `total`.
|
|
1387
1346
|
|
|
@@ -1396,7 +1355,6 @@ skipped by default; `includeTotal=1` adds `total`.
|
|
|
1396
1355
|
"sessionId": null,
|
|
1397
1356
|
"status": "succeeded",
|
|
1398
1357
|
"specName": "support-bot",
|
|
1399
|
-
"agentId": null,
|
|
1400
1358
|
"modelId": "platform:demo",
|
|
1401
1359
|
"inputPreview": "Where is my order?",
|
|
1402
1360
|
"outputPreview": "It shipped on Tuesday.",
|
|
@@ -1422,8 +1380,7 @@ The list is a projection, not a snapshot: `inputPreview` / `outputPreview` /
|
|
|
1422
1380
|
`error` are truncated, and `total` is `null` unless `includeTotal=1`. Fetch
|
|
1423
1381
|
`GET /agent-runs/{runId}` for full text, the spec, and `model`. `modelId`,
|
|
1424
1382
|
`durationMs`, and `toolCallCount` are populated when the run reaches a
|
|
1425
|
-
terminal state
|
|
1426
|
-
workspace agent.
|
|
1383
|
+
terminal state.
|
|
1427
1384
|
|
|
1428
1385
|
`GET /agent-runs/{runId}` returns the run snapshot (status, final text, error,
|
|
1429
1386
|
spec, plus the cost-attribution triple `tokens` / `turns` / `model` —
|
|
@@ -1627,12 +1584,12 @@ data: <utf-8 JSON>
|
|
|
1627
1584
|
// loop-detection guard fired (see §4.6). Soft nudge: hardCutoff=false. Hard cutoff: hardCutoff=true.
|
|
1628
1585
|
// `tools` is the (toolName, …) batch the model just repeated; the synthetic skip + nudge are
|
|
1629
1586
|
// emitted on the normal tool_result + assistant_delta channels — this event is observability only.
|
|
1630
|
-
{ "seq": 7, "type": "loop_detected", "data": { "consecutiveCount": 3, "hardCutoff": false, "tools": ["
|
|
1587
|
+
{ "seq": 7, "type": "loop_detected", "data": { "consecutiveCount": 3, "hardCutoff": false, "tools": ["search_docs"] } }
|
|
1631
1588
|
|
|
1632
1589
|
// per-tool budget exceeded (see §4.7). The pipeline already surfaced the synthetic
|
|
1633
1590
|
// "budget exceeded — pivot or finalize" body on the normal tool_result channel; this event
|
|
1634
|
-
// is observability so SDK clients can render "
|
|
1635
|
-
{ "seq": 7, "type": "tool_budget_exceeded", "data": { "tool": "
|
|
1591
|
+
// is observability so SDK clients can render "search budget exhausted" status notes.
|
|
1592
|
+
{ "seq": 7, "type": "tool_budget_exceeded", "data": { "tool": "search_docs", "maxCalls": 4, "callIndex": 5 } }
|
|
1636
1593
|
|
|
1637
1594
|
// run-supervisor check (see §4.8). Fired on every review — on_track included.
|
|
1638
1595
|
{ "seq": 7, "type": "supervisor", "data": { "action": "on_track", "reason": "Agent is making progress.", "llmCalls": 5, "model": { "id": "platform:demo", "provider": "openai", "vendorModelId": "gpt-4o-mini" } } }
|
|
@@ -1793,43 +1750,6 @@ SDK clients can probe server capability via `"tokens" in body` without
|
|
|
1793
1750
|
triggering an undefined-vs-null distinction across HTTP/JSON
|
|
1794
1751
|
serialization.
|
|
1795
1752
|
|
|
1796
|
-
**A2A exposure.** The MANTYX-hosted A2A endpoint
|
|
1797
|
-
(`POST /api/a2a/{workspaceSlug}/agents/{agentSlug}`) returns the same
|
|
1798
|
-
triple on the JSON-RPC response under `result.metadata.mantyx`:
|
|
1799
|
-
|
|
1800
|
-
```jsonc
|
|
1801
|
-
{
|
|
1802
|
-
"result": {
|
|
1803
|
-
"kind": "message",
|
|
1804
|
-
"messageId": "msg_abc",
|
|
1805
|
-
"role": "agent",
|
|
1806
|
-
"parts": [{ "kind": "text", "text": "Final reply" }],
|
|
1807
|
-
"metadata": {
|
|
1808
|
-
"mantyx": {
|
|
1809
|
-
"tokens": {
|
|
1810
|
-
"inputTokens": 1283,
|
|
1811
|
-
"cachedTokens": 512,
|
|
1812
|
-
"reasoningTokens": 96,
|
|
1813
|
-
"outputTokens": 240,
|
|
1814
|
-
},
|
|
1815
|
-
"turns": 3,
|
|
1816
|
-
"model": {
|
|
1817
|
-
"id": "platform:demo",
|
|
1818
|
-
"provider": "openai",
|
|
1819
|
-
"vendorModelId": "gpt-5.4-mini",
|
|
1820
|
-
"reasoningEffort": "low",
|
|
1821
|
-
},
|
|
1822
|
-
},
|
|
1823
|
-
},
|
|
1824
|
-
},
|
|
1825
|
-
}
|
|
1826
|
-
```
|
|
1827
|
-
|
|
1828
|
-
The `metadata.mantyx` block is omitted entirely against legacy runners
|
|
1829
|
-
that haven't implemented `runWithUsage` on the A2A adapter (see
|
|
1830
|
-
`packages/ts-sdk/src/a2a/adapter.ts`); cross-platform A2A clients
|
|
1831
|
-
should treat its absence as "no usage data" rather than as zero usage.
|
|
1832
|
-
|
|
1833
1753
|
## 8. Local tool result
|
|
1834
1754
|
|
|
1835
1755
|
```
|
|
@@ -1880,9 +1800,8 @@ stream. In-flight `tool-results` posted after cancellation are accepted with
|
|
|
1880
1800
|
POST /api/v1/workspaces/{slug}/agent-runs/{runId}/feedback
|
|
1881
1801
|
```
|
|
1882
1802
|
|
|
1883
|
-
Record thumbs up/down feedback on a completed (or in-flight) run
|
|
1884
|
-
`
|
|
1885
|
-
extended to ephemeral SDK runs. Requires the `feedback:write` scope.
|
|
1803
|
+
Record thumbs up/down feedback on a completed (or in-flight) run. Requires
|
|
1804
|
+
the `feedback:write` scope.
|
|
1886
1805
|
|
|
1887
1806
|
Request body:
|
|
1888
1807
|
|
|
@@ -1910,9 +1829,14 @@ first call returns `201`. Response:
|
|
|
1910
1829
|
The author is attributed to the calling workspace **API key** (`apiKeyId`); OAuth
|
|
1911
1830
|
tokens leave the author null. Recorded feedback surfaces in the workspace
|
|
1912
1831
|
**API feedback** dashboard (Developer area) and the read-only
|
|
1913
|
-
`GET .../reply-feedback` listing (scope `feedback:read
|
|
1914
|
-
|
|
1915
|
-
|
|
1832
|
+
`GET .../reply-feedback` listing (scope `feedback:read`). Unknown runs return
|
|
1833
|
+
`404 { "error": "Run not found" }`.
|
|
1834
|
+
|
|
1835
|
+
Each item in the `GET .../reply-feedback` listing describes feedback on one
|
|
1836
|
+
agent run and carries `id`, `verdict`, `targetKind` (always `"agent_run"`),
|
|
1837
|
+
`surface`, `explanation`, `contentSnapshot`, `specName`, `metadata`,
|
|
1838
|
+
`agentRunId`, `ephemeralSessionId`, `createdAt`, `user`, and `apiKey`. The
|
|
1839
|
+
listing has no `agentId` or `targetKinds` filter.
|
|
1916
1840
|
|
|
1917
1841
|
## 10. Rate limits and errors
|
|
1918
1842
|
|
|
@@ -1984,14 +1908,13 @@ A reference SDK should:
|
|
|
1984
1908
|
optional `serverInfo`, and dispatch incoming calls by the `mcpServer`
|
|
1985
1909
|
field in the event payload.
|
|
1986
1910
|
|
|
1987
|
-
`
|
|
1988
|
-
no SDK-side registry needed.
|
|
1911
|
+
`a2a` and `mcp` refs are server-resolved — no SDK-side registry needed.
|
|
1989
1912
|
|
|
1990
1913
|
3. On `runAgent` / `session.send`:
|
|
1991
1914
|
- Accept `reasoningLevel` from the caller and pass it through unchanged
|
|
1992
1915
|
(string `"off" | "low" | "medium" | "high"` _or_ number `0–100`); do
|
|
1993
1916
|
**not** translate to a vendor-specific knob — the server owns that
|
|
1994
|
-
mapping so all SDKs stay aligned
|
|
1917
|
+
mapping so all SDKs stay aligned.
|
|
1995
1918
|
- POST the run/message, get `{ runId, streamUrl }`.
|
|
1996
1919
|
- Open the SSE stream with `Last-Event-ID` if reconnecting.
|
|
1997
1920
|
- On `local_tool_call`, dispatch by the event's `kind` discriminator
|
|
@@ -2002,10 +1925,10 @@ A reference SDK should:
|
|
|
2002
1925
|
them by default. Their presence depends on `reasoningLevel > 0` and
|
|
2003
1926
|
on the active model exposing thought parts.
|
|
2004
1927
|
- Accept `loopDetection`, `toolBudgets`, and `supervisor` from the caller
|
|
2005
|
-
and pass them through unchanged (see §4.6 / §4.7 / §4.8).
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
1928
|
+
and pass them through unchanged (see §4.6 / §4.7 / §4.8). Omitting
|
|
1929
|
+
`loopDetection` keeps MANTYX's runtime defaults and `loopDetection: false`
|
|
1930
|
+
opts out; `toolBudgets` caps only the tools it names (omitted or `{}`
|
|
1931
|
+
means no caps). `supervisor` and `plan` are opt-in — omitting them
|
|
2009
1932
|
keeps both off; pass `supervisor: true` / `{}` / `{ interval?, modelId? }`
|
|
2010
1933
|
or `plan: "auto"` / `"required"` / `{ … }` to enable.
|
|
2011
1934
|
- Treat `loop_detected`, `tool_budget_exceeded`, and `supervisor` SSE
|
|
@@ -2026,7 +1949,7 @@ A reference SDK should:
|
|
|
2026
1949
|
5. Treat the protocol as the contract. Implementation details such as Valkey
|
|
2027
1950
|
pub/sub or pgvector are server-side only.
|
|
2028
1951
|
6. **Execution model (server-side, informational).** Runs are executed
|
|
2029
|
-
out-of-process by
|
|
1952
|
+
out-of-process by a worker off a dedicated
|
|
2030
1953
|
`mantyx:agent-runs` RabbitMQ queue; the API only persists the run row and
|
|
2031
1954
|
enqueues. Nothing about this is observable on the wire — clients still see
|
|
2032
1955
|
`202 { runId, streamUrl }` followed by the same SSE vocabulary — but it
|