Skip to content

Agents API

A saved agent is a named, gateway-scoped inference config (instructions + model + tools + optional knowledge project), invoked head-lessly at /v1/{tenant}/{gateway}/agents/{slug}/invoke. Agents are user-owned (created_by); admin/tenant_admin govern all agents in their scope.

Admin endpoints require an authenticated admin session (aig_admin cookie). The base URL is https://ai-api-admin.myra.eu/admin/v1.

Per-tenant feature gate (agents_enabled)

Agents is a per-tenant feature (tenant.agents_enabled, default 0 = off for every newly-created tenant / migration 0293 — a premium, not-yet-public feature; a platform admin enables it per-tenant; flip via PATCH /admin/v1/tenants/{id} — see Tenants). Enforced server-side, not just by hiding the SPA nav (invariant 11 — the client is never the authz boundary):

  • Admin routes — every …/gateways/{gw}/agents… route (list, get, create, update, delete, sharing, curation, rating, versions, schedules, webhook-triggers, runs, credentials) and the org agent-catalog return 403 { "error": "feature_disabled" } when the tenant is disabled.
  • Invoke — a human agent run — the interactive /v1/{tenant}/{gw}/agents/{slug}/invoke (user session / user-bound token), the run-as-self preview, and the in-chat agent bridge — returns 403 { "error": { "code": "agents_disabled" } } (a distinct code so the SPA can localize "ask your workspace admin to enable Agents"). These runs depend on agents_enabled only, not on the tenant's playground_enabled: the web app's Try it and draft preview run with a token from POST /admin/v1/playground/token, which is not Playground-gated (only the Playground's own search route is), so an organisation with Agents on and the Playground off can still run its agents.
  • Scheduled / webhook agent runs are withheld at the claim layer (no fire, no failure email, no auto-pause); the inbound agent-webhook receiver fail-fasts 503 without enqueuing. They resume automatically when Agents is re-enabled.

Exempt (still reachable while disabled, by design): the governance review decisions (approve/flag/disable/reactivate) on agents that already exist — so a pending review can be resolved (mirrors the workflow-approval precedent) — the gateway compliance audit read, and an agent-step that runs inside an enabled Workflow (governed by workflows_enabled, not agents_enabled).

Four-eyes config approval (202 pending_approval)

When the tenant enables four-eyes configuration approval, a mutating call — create (POST …/agents), update (PATCH …/agents/{id}), restore (POST …/agents/{id}/versions/{version}/restore), delete (DELETE …/agents/{id}), schedule create (POST …/agents/{agent}/schedules), schedule update (PATCH …/agents/{agent}/schedules/{id}), and schedule delete (DELETE …/agents/{agent}/schedules/{id}) — made by a tenant admin does not apply immediately. Instead it is held for a second admin and the route returns 202 { "status": "pending_approval", "approval_id": "<id>" }. The change applies only after a different admin approves it, re-validated against the then-current state (never a stale replay); a delete and a schedule update/delete are captured and replayed against the current row (a schedule update whose row has since changed incompatibly fails closed at apply rather than reverting it). If the approval gate itself is unavailable the call fails closed with 503. See Configuration approvals for the approval lifecycle.


Database faults are opaque (every agent route)

A failed database read on any agent route — list, read one, versions, runs, shares, the org catalog, webhook triggers, schedules, the audit trail, the feature check, and every lookup a write performs before writing — answers 503 { "error": "temporarily unavailable; retry later" } (nothing written; retry). A failed write (create, update, restore, delete, sharing, curation, rating, review transitions, schedules, webhook triggers) answers 500 { "error": "internal error", "request_id": "<id>" } unless nothing was written (below). Neither carries a code or the database's own error text (which names tables, columns and stored values; it goes to the server log under the request_id) — see Storage faults. A fault is never disguised as a client answer either: a failed lookup is the 503, not 404 agent not found / user not found / group not found, not 403 org_share_disabled, and a failed shares read is the 503, not an empty list (an empty list would make a following sharing PUT — which replaces the whole set — revoke every share). The same holds for every part of a response: the rating aggregate and the caller's own rating (read one, org catalog, and the answer of a rating PUT / DELETE), and a run's trace steps, usage, owner result and config snapshot on the run detail — a failed read of any of them is the 503, never an omitted, empty or zero value (which would read as "unrated" or "this run had no steps / cost / result"). After a rating PUT / DELETE whose write was stored, a failed read of the fresh aggregate is the 500 (the write landed); the write is an absolute set, so sending it again is safe.

The run-start write of an agent invoke without a run id (the gateway starts the run itself) and the claim that resumes an approved held tool call answer 503 service_unavailable with Retry-After: 1 when the write hit a retryable fault and nothing was written: send the call again. On an open stream the same refusal arrives as the service_unavailable error event without the header. A write fault with an unknown outcome, and a hold recorded after the resume claim, stay 500. Validating a knowledge-area or MCP-connector binding whose lookup fails is the 503 too, not a 400 (the /v1 draft preview, outside the admin API, answers 500 internal_error), so a retry is safe and a four-eyes approval is left pending rather than failed.

A write that rolled back on a transient database conflict — a deadlock, or a lock wait the write gave up on (it is never re-waited) — or that found no database connection at all, changed nothing and answers 503 { "error": "temporarily unavailable; retry later" } instead (create, update, restore, delete, schedule create / update / delete, webhook-trigger create / update / delete): sending the same request again is safe. A four-eyes approval whose write hit such a conflict stays pending — see Config approvals. The same 503 answers when any read a write depends on fails — the caller's department policy, a project lock, the slug / gateway / review-policy / MCP-connector / provider lookups, the version a restore reads, or the re-read after a concurrent schedule change (nothing is written). A stored version whose snapshot cannot be decoded is not retryable: a restore of it answers the sanitised 500 { "error": "internal error", "request_id": "…" } and changes nothing.

Department refusal names whose department. POST /agents and PATCH /agents/{id} answer 403 department_gateway_not_allowed when the department of the agent's owner does not allow the chosen gateway. The body adds subject: "owner" when the refusing department is the owner's and the caller is someone else (an administrator editing another member's agent), "caller" when the caller is the owner. The field is additive, there is no new code; an absent or unknown value means "caller". The SPA words the owner case as the department of the agent's owner, not as the viewer's own organisation.

The read-back of the stored agent runs inside the same database transaction as the change and its audit entry. A failure of that read-back therefore rolls the change and its audit entry back: it answers the retryable 503 { "error": "temporarily unavailable; retry later" } (nothing stored) or, when the outcome is unknown, the opaque 500 — read the agent before retrying. A read-back that finds no row without any fault keeps these answers:

  • create (POST …/agents) answers 201 with { "id", "gateway_id", "name", "slug" } only — the agent exists (fetch it for the full record);
  • an update / restore whose UPDATE matched no row (the agent was deleted in the meantime) answers 404 agent_not_found.

The curation (PATCH …/curation) and starters writes are not part of that transaction: their read-back runs after the commit, and a failed read-back answers the opaque 500 with the change stored and audited, or 404 agent_not_found (and no audit record) when the agent was deleted in between.

Audit. An agent create, update, restore, consent revoke and delete, and a schedule create, update and delete, are committed in one database transaction together with their audit entry (agent.created, agent.updated, agent.version_restored, agent.consent_revoked, agent.deleted, agent_schedule.created, agent_schedule.updated, agent_schedule.deleted); an audit entry that cannot be written rolls the change back, so there is never a change without its entry or the reverse. The audit after is read inside that transaction. When nothing was stored the write answers a retryable 503 { "error": "temporarily unavailable; retry later" } (a held four-eyes approval stays pending); when the outcome is unknown it answers the opaque 500, and a held approval fails rather than being re-run. Deleting an agent also revokes its tokens in the same transaction.

What stays a client error, with a fixed message:

Request Response
PATCH …/agents/{id} that changes nothing 400 { "error": "no fields to update" }
POST …/agents or PATCH …/agents/{id} with a number that is not finite (NaN, Infinity, 1e999) anywhere in the body 400 { "error": "request body contains a number that is not finite (NaN / Infinity / out of range)", "code": "malformed_body" } — rejected before any field is read or stored (after the session / permission checks), so it is never stored (create used to save such a tool_config as {} and such a response_schema / source_metadata as nothing). See Error codes
POST …/agents or PATCH …/agents/{id} with a number in the body that is not exact 400 with code number_not_exact or number_invalid and field naming the top-level member (for example response_schema) — see the rows in Error codes; nothing is stored. Refused before any field is read, after the non-finite check
PATCH …/agents/{id} with "name": null 400 { "error": "name cannot be cleared (it is required)" }
POST/PATCH …/agents with a tool_config switch (web_search, file, agentic_fetch or sources_footer) that is not a JSON boolean 400 { "error": "tool_config.<key> must be a boolean" } — a string such as "false" is no longer read as enabled. Stored legacy rows are normalised by migration: a non-boolean web_search, file or agentic_fetch becomes false; a non-boolean sources_footer is removed (footer on, the default)
PATCH …/agents/{id} with "tool_config": null 400 { "error": "tool_config cannot be cleared (send {} for no tools)" } — on create, a null tool_config still means "no tools" ({})
The model pin check cannot run a failed database read (the gateway or provider lookup) is 503 { "error": "temporarily unavailable; retry later" } (nothing written — retry); a gateway configuration stored corrupt is the sanitised 500 { "error": "internal error", "request_id": "…" } — see Model pin offer validation
POST …/agents whose slug is already in use on the gateway 409 { "error": "an agent with this slug already exists", "code": "duplicate" } — the same answer whether the clash is seen by the up-front check or by a concurrent create losing the (gateway_id, slug) unique key at insert. Branch on code, not the prose. (Duplicating an agent auto-picks a free <slug>-copy / -copy-2 / … client-side on this 409, so the user never hits it; it still surfaces when you send your own slug.)

The gateway audit trail (GET …/audit) answers the same retry 503 when the trail cannot be read.


Account deactivated mid-request. A create (agent or schedule) whose acting user is disabled or erased while the write runs answers 401 { "error": "unauthenticated" } — nothing is created, and no agent is ever owned by an account that no longer exists. A four-eyes-held create whose requester is gone by approval time ends apply_failed / requester_unauthorized.

Run lane: retryable database faults

The checks that decide whether an agent run or an agent MCP call may start (the agent owner lookup, including the department stamped on the owner row, and sharee visibility, the Agents feature gate, the chat-bridge token and the workflow gate of the Copilot lane) answer 503 service_unavailable with Retry-After: 1 when the read hit a retryable database fault (no free connection, a lock wait timeout, a deadlock). The request is refused and nothing runs; retry after the delay. A permanent database error stays 500, and a fault is never answered as an unknown agent, a missing share or an allowed run. The same answer covers the other reads of the run lane: the agent load of an invocation, the knowledge areas bound to the agent, the owned-agent list of the Copilot lane, the provider pin and the project or MCP connector resolution of a preview, the stamp of a task envelope and the load of a fenced task, a resumed run or a conversation, and the webhook trigger. On stream: true, a fault that hits after the stream has opened ends the stream with an error event (service_unavailable for a retryable fault, internal_error otherwise) and sets no Retry-After header, since the headers are already sent. Nothing is written or executed on a 503.

Knowledge areas

An agent can be linked to one or more knowledge areas (Wissensbereiche — chat_project spaces, each with its own access control). At retrieval time the agent's search_knowledge tool searches the union of the bound areas' documents and returns passages with their [file | page | section] citation unchanged.

Create / update body

Field Shape Notes
project_ids string[] The authoritative set of bound areas. Replaces the binding on PATCH. Max 16 ids. Each must be a project in the gateway's tenant that the agent owner can access. An id the caller cannot see (unknown, malformed, deleted, another tenant's, or not shared with them) answers the shared 404 {"error":"not found"}, byte-identical to a random id and recorded as an access.denied event (see Error codes); an area the caller can see but the agent owner cannot access stays 400 (fail closed). Duplicates collapse. [] clears all bindings.
project_id string Legacy, single-area. On create it seeds a one-element set. On PATCH it is honored only for a true legacy agent (no project_ids binding yet) — once an agent has area rows, a stray project_id is ignored so it can't silently collapse a multi-area agent.

A deleted knowledge area restricts the run (fail closed). A knowledge area is soft-deleted, and deleting one does not unbind the agents that use it — so an agent can outlive one of its areas. When the gateway resolves an agent's areas at invoke time and finds that a bound area no longer exists (deleted, or not a live project of this tenant), it cannot tell what policy that area carried. Because the missing area may have been the one that made the agent local only or PII mandatory, the run is forced to the most restrictive setting on both axes: local models only, PII masking on, and every externally-egressing tool (web search, URL fetch, external MCP, sub-agent delegation, image generation, code interpreter) disabled.

What you will see. If the agent is pinned to a cloud model, the run is refused with 403 agent_area_unresolved — "A knowledge area bound to this agent no longer exists, so the run is restricted to local models. Open the agent and save its knowledge areas to fix it." That is permanent, not retried: a scheduled agent in this state fails every run until it is fixed. If the agent runs on a local model it still completes, silently restricted; the agent_area_unresolved step in the run's trace is where that shows up.

How to see it. The agent list badges such an agent Knowledge area missing (a warning, not an info tag — it is not a working agent), and opening it shows the same explanation directly above the knowledge-area picker. On the API this is areas_unresolved: true on the owner view of GET-one and the list; the field is present only when true, so its presence is the signal.

How to fix it. Open the agent and save its knowledge areas. The save writes the live set and prunes the dead binding. A PATCH that omits project_ids does not clear it — the binding is only rewritten when the field is present.

This is deliberate: before it, a deleted area simply vanished from the agent's area set, and an agent whose only area was local only silently became unrestricted — its scheduled runs kept working, on cloud models, with no residency guarantee.

A purged area fails closed too. The guarantee covers a hard delete — a right-to-erasure purge that removes the project row itself, not just its deleted_at — as well as the ordinary soft delete. (A whole-workspace purge deletes the agents with the areas, so nothing survives to be restricted there.) The binding row is deliberately left behind by such a purge (it is an asserted area id, and its liveness is resolved at read time), so the agent still asserts an area the gateway cannot classify and is restricted exactly as above. Before this, the purge removed the assertion with the project and the agent silently ran unrestricted.

Scope

This restricts what the RUN may reach. It does not change what the scheduler does with the finished output: delivery (email / webhook / chat) is gated on PII activity, not on residency, exactly as it is for a genuinely local_only area.

Responses. GET-one, create (201), update (200) and the list return project_ids (the area set) alongside project_id (the derived primary = the first area, kept for backward compat), plus areas_unresolved: true when at least one asserted area no longer resolves (absent otherwise). For a non-owner (shared/catalog) view both project_id and project_ids are redacted. On create/update/restore/curation the write is authoritative and commits before the areas are read back for the response, so a rare transient failure of that read-back does not turn a succeeded write into a 500 (which would desync the list from the detail): the committed agent is returned with project_ids as [], and the true set reloads cleanly on the next fetch. (The read-only GET answers the retry 503 — nothing is committed there.)

Rejected input (each → 400): a non-array project_ids, a non-string element, more than 16 ids, or an id the owner can see but cannot use for this agent. An id the caller cannot see is the shared 404 not found, not a 400. An id the agent is already bound to is the exception — it is kept without re-validation, so an owner who has since lost access to an area (or whose area was deleted or purged) can still save the agent, and the area's restriction is not silently dropped. Only newly-added ids are access-checked.

Retrieval & ACL. The union is resolved per invocation against the run-as-owner identity: an area the owner cannot access is dropped from the union (never searched, no citation) — the union never widens access. The corpus is capped at 50 documents. Documents are chosen by relevance to the query (the closest-matching chunks decide which documents are loaded first); documents with no close match fill the remainder in round-robin order across the areas. It is a document-count cap plus a total size budget. Egress tiers are unioned per axis: if any bound area is local_only the whole invoke is egress-blocked, and if any is pii_mandatory PII scrubbing is forced (the two are independent — binding one of each keeps both protections).


Model pin offer validation

An agent pins a model (and an optional provider) that every invocation of that agent dispatches to on the agent's gateway. When a create (POST) or edit (PATCH) sets that pin, the server validates the resolved (provider, model) the agent would dispatch to against the gateway's dispatch gates — the same EU data-residency and provider-allowlist checks the inference path enforces — evaluated on the gateway's resolved (tenant-floor-folded) config. This is the same authority the project default pin is validated against (providers.pin_gate). A pin the gateway would refuse at dispatch is rejected at save time rather than accepted and then failing every conversation with a 403:

  • The model resolves to a provider the gateway's EU data-residency enforcement blocks → 400 with code: "data_residency_blocked".
  • The model resolves to a provider not on the gateway's approved provider allowlist → 400 with code: "provider_not_allowed".
  • The pair cannot be judged because a read it depends on failed (the model catalogue, the gateway's routing rules or its provider opt-in set) → 503 { "error": "temporarily unavailable; retry later" } (nothing written — retry). A read fault never turns into a 400 verdict, nor into an accepted pin.

Details:

  • Dispatch-faithful resolution. The provider checked is the one the invoke path would actually use: a provider-remapping routing rule wins over the pin, and every load-balance fan-out target is checked (a single blocked target blocks the save).
  • Touch-guarded (PATCH). The pin is re-validated only when the request touches model or provider. An unrelated edit (rename, new instructions) on an agent that already carries a pin — including a legacy pin that predates this validation — is never re-validated, so it stays editable.
  • Routing-default agents (no model pinned) have nothing to validate and are unaffected.
  • Fail closed. If the gateway cannot be read at save time (a transient database error), the save fails with 503 { "error": "temporarily unavailable; retry later" } (nothing written — retry); a gateway whose configuration is stored corrupt fails with the sanitised 500 { "error": "internal error", "request_id": "…" } (permanent; a held four-eyes change fails apply_failed internal). Neither silently stores an unvalidated pin.

Provider availability (the explicit provider field)

provider is an optional, client-supplied pin. It is validated at the server as an untrusted input — the client is never the authority. The value is accepted when the provider can actually be served on the agent's gateway, which is the same credential-sourcing decision the inference (chat) path makes — so a provider that works for chat on this gateway is pinnable, and save == invoke by construction. Accepted when the provider is:

  • platform-managed (the Myra-hosted myra provider) — always routable, no key, no opt-in;
  • a BYO provider the gateway opted into (a provider-config key → the gateway's configured_providers);
  • available via the managed Anthropic pool — either a granted managed model (managed_models) or a model entitled by the gateway's self-serve plan. On a managed/wallet gateway configured_providers is empty, yet Claude models are served keylessly on Myra's pool; this is exactly the case that was fixed (create previously rejected provider: "anthropic" here with "not configured on this gateway" even though Haiku chat worked).

Rejected (400), each a distinct answer — a malformed value never degrades to the inferred path:

  • an unknown provider string → unknown provider: <value>;
  • a provider that does not serve the pinned model → provider '<p>' does not serve model '<m>';
  • a provider not available on this gateway (not platform-managed, not configured, not on the managed pool) → provider '<p>' is not configured on this gateway. This is a fail-closed control — it is NOT dropped for the managed case, so a genuinely unavailable provider (e.g. a BYO provider with no key on this gateway) is still refused rather than accepted and then failing at the credential read;
  • a Myra-provided model that is enabled but unusable because this gateway sends that provider to a custom base URL (provider_base_urls) — Myra's managed key is never sent there → provider '<p>' is sent to a custom base URL on this gateway (provider_base_urls); Myra-provided models are not available there — add your own <p> API key or remove the base URL override;
  • a present but non-string provider (123, [...], {}) → provider must be a string. A present-but-malformed value is rejected; it is not silently treated as absent.

Absent (null / "" / omitted) → the provider is inferred from the model: the agent is stored unpinned when the inferred provider is not runnable here (routing re-infers at each invoke), or pinned to the resolved provider when it is. A transient failure to verify availability fails the save with a retryable 5xx (never a spurious 400).

The invoke / preview path validates a stored pin with the same predicate (core.provider_runnable.on_gateway), so an agent pinned to a managed-pool provider runs; a pin to a provider no longer available fails with pinned provider '<p>' is not configured on this gateway (or, for a Myra-provided model blocked by a custom base URL, pinned provider '<p>' is sent to a custom base URL … with the same remedy as above).

Known limitation. A provider-prefixed model id (e.g. anthropic/claude-haiku-4-5) combined with an explicit provider is not normalized before the availability check, so a managed-pool match on the bare id is missed and the request reports the generic … is not configured on this gateway. Pass the bare model id (claude-haiku-4-5) with the explicit provider — which is what the Agents UI sends.

Tool-capability guard

A model curated as tool-incapable (e.g. Perplexity Sonar — see supports_function_calling in Models) breaks the moment the gateway injects any function tool. So a create (POST) or edit (PATCH) whose effective model is tool-incapable is rejected 400 with code: "model_capability_mismatch" when it would leave any function-tool affordance enabled — web search, URL fetch (agentic_fetch), the file tool, connectors (mcp / mcp_allow), sub-agents (agents), or a bound knowledge area (which arms search_knowledge). This is the config-time prevention counterpart to the runtime model_capability_mismatch net (the same code), refused consistently across every affordance rather than one leaky toggle.

  • Permissive on the unknown space. Only a curated tool-incapable model is blocked; an uncatalogued model (and a routing-default agent with no model) is never blocked here — the runtime net owns those, so a tool-capable model whose flag is unknown is never wrongly refused.
  • Effective (patch-merged) evaluation. A tool_config-only PATCH keeps the existing provider / model; a model-only PATCH to a tool-incapable model still catches tools already enabled on the stored row. The guard runs only when the request touches model, tool_config, or the knowledge areas — a benign rename of a legacy tool-incapable+tools agent is not blocked.

Tool-use is enforced server-side per run

At invoke time the gateway mints a short-lived, signed capability principal for the run and enforces it at the single tool-dispatch point: an agent can only call a tool that its own tool_config actually offers on that turn — a hallucinated or gated-off gateway tool (a built-in such as read_file/web_search, or an MCP tool) is refused server-side (invariant 11 — the client is never the authz boundary), not merely hidden. A sub-agent inherits a strictly-narrowed capability for those gateway tools: its allowlist is the intersection with its calling agent's, so it cannot use a built-in or MCP tool its caller could not. Sub-agent spawning itself stays governed by the delegation guards (same-owner, depth, cycle and budget limits). This is transparent for a correctly-configured agent — the set of usable gateway tools is exactly what you configured.

Phase-1 limitation. Provider-native tools (e.g. a model provider's own server-side web search) run on the upstream, not through the gateway's tool dispatcher, so they are governed by the agent's own tool_config but are not yet narrowed by the sub-agent intersection. Narrowing native tools across delegation is a later phase.


Sharing and running a shared agent

Sharing controls who discovers, reads and clones an agent on the admin plane, and who may run it (see below). Access resolves uniformly from rows + a flag: a user sees an agent if they own it, or it is shared with them directly, via a group they belong to, or it is org-shared (and the tenant's org_share_enabled is on). visibility (private | users | group | org) is a derived display value.

Running a shared agent

A user-bound caller who is a sharee of an agent (direct, group or org share) may invoke its slug on the data plane. Rules:

  • Who may run. The owner, and any caller to whom the agent is visible through a share. The agent must be approved for a sharee (the owner may still run a draft). Everyone else, an unapproved org share included, gets 404 AGENT_NOT_FOUND (the same answer as an unknown slug). A database fault while checking visibility is a 500, never a 404.
  • The sharee runs as themselves. The run is the caller's: budgets, wallet and quota are charged to the caller, the caller's own role and department apply, the request log records the caller as both user_id and invoker_id, and guardrail detectors use the caller's role. The owner's department must also allow the gateway, and the owner must be active.
  • Connectors are the caller's. Connector credentials and consent are the caller's, never the owner's. The requester source ACL on knowledge is the caller's too, so a sharee can see less than the owner would, never more.
  • Knowledge scope. The agent's own knowledge areas (and only those) are readable, read-only. Other projects of the owner stay unreachable: reading one is refused as for any non-owner.
  • No delegation, no write. A sharee run cannot delegate to other agents, and write_file and edit_file are neither offered nor executed. read_file and search_knowledge work on the agent's areas.
  • Chat bridge stays owner-bound. A chat-bridge turn keeps using the asking user's own MCP credentials and the owner binding; sharing does not change it. A per-agent proxy token bound to a sharee is refused with 404.
  • Holds. When a sharee run is held for approval, the approver is the caller (the holder of the credentials). The decision record carries the real agent owner.
  • Owner run detail. The owner's run-detail route for a sharee's run answers 200 but omits the result field: the owner never sees a sharee's answer. The run's trace steps are cut to metadata (step type, timings, counts, tool and model names, code-shaped status values); prompts, tool arguments and answers are removed. This applies equally to an admin or tenant admin who opens the run: what is hidden depends on who drove the run, not on who is looking. A non-creator admin still never receives result, but sees the full steps of the owner's own runs. Runs produced by the owner's own bridge/grant legs, and unattended runs, remain fully visible. A non-creator reader gets the step bodies only with the REQUEST_LOGS_VIEW permission and a valid X-Read-Reason (the read is audited as request_log.content_read); without the permission the steps stay metadata-only whatever the header says (no 400, no audit row). An administrator in a View as user session is never the owner: the run detail and the delegation steps of the viewed user's agent carry no result and no result_expired, and the steps follow this non-owner rule using the viewed user's permissions (the audit row also records the impersonating administrator as impersonator_id).

Previously a sharee could only see and clone an agent; direct use now works as described above. (A private agent is still invokable by the gateway service token, unchanged.)

External agents (hosting)

An agent is hosting: "internal" (default: runs on the gateway) or hosting: "external" (runs elsewhere and is served only by the MCP proxy). Every agent row carries hosting and, for external agents, external_platform (copilot, copilot_studio, claude_code, cursor, custom).

Create with hosting: "external": external_platform and purpose are required. The run-only fields model, instructions, provider, response_schema, max_tokens, max_steps, constraints and protection are refused with 400 external_agent_field_not_allowed; tool_config may contain only mcp, mcp_allow and approval with the single key ttl_seconds (the waiting time of the proxy's holds, same bounds and 400 invalid_approval_ttl as for an internal agent, see Approval window). Any other tool_config key, approval.tools and any other approval key are refused (create and update) with 400 external_agent_field_not_allowed, for example external_agent_field_not_allowed: tool_config.approval.tools does not apply to an external agent (only approval.ttl_seconds); nothing is written. An update that sends tool_config replaces the stored one, so send mcp and mcp_allow back unchanged next to approval to keep them. An external agent without a stored ttl_seconds waits 7 days. An unknown hosting is 400 invalid_hosting. A missing or empty external_platform is 400 external_platform_required; a null, non-string or unknown platform is 400 invalid_external_platform (on update any value that is not a valid platform is too). A platform on an internal agent is 400. The earlier spellings hosting_invalid and external_platform_invalid are no longer sent; clients may accept both during the change. Update: hosting is immutable (re-sending the current value is a no-op; any change is 400).

OAuth client mapping. An external agent may carry oauth_client_id: the Client ID Metadata Document URL of the MCP client that may act through it (see MCP proxy OAuth). It is accepted on create and update for an external agent only (an internal agent: 400 oauth_client_id_not_allowed), checked for shape only (an https URL; otherwise 400 invalid_oauth_client_id), and returned in the agent JSON. On update, absent leaves it unchanged and an explicit null clears it (null on create is 400 invalid_oauth_client_id). The URL is unique per gateway and compared case-sensitively: a second agent claiming it is 409 oauth_client_already_mapped.

oauth_client_id may also be the dcr_ id of a registered (unverified) MCP client, to promote it to this named agent (400 unknown_oauth_client if no such client is registered; 503 if the lookup itself fails - retry). The gateway's own unverified-clients agent (system_role = unverified_mcp_clients, created at the first approval, one per gateway) cannot be given or changed system_role through the API (400 system_role_not_allowed - on create for any agent, on update unless re-sending the unchanged value) and its oauth_client_id cannot be set or cleared (400 oauth_client_id_not_allowed). Its write and destructive tool calls are always held for approval; see MCP proxy OAuth.

Filter: GET .../agents?hosting=internal|external; any other value is 400 invalid_hosting.

Activity figures (last_call_at, calls_24h, blocked_24h, pending_approvals, connected_clients)

GET .../agents?hosting=external and GET .../agents/{id} add four activity figures to every external agent row the caller owns or administers (tenant admin), and a connected_clients count on the unverified-clients agent (see the table). The four figures are computed on read from the access decisions the MCP proxy records; internal agents, and the list without ?hosting=external, carry none.

Field Meaning
calls_24h Number of calls in the last 24 hours (0 when none)
blocked_24h Number of those calls that were refused (0 when none)
last_call_at Unix time in seconds of the most recent call within the last 90 days, or null when there is none
pending_approvals Number of this agent's tool calls held for approval that are still waiting for a decision right now (pending, or awaiting_second for a second approver) and have not expired (0 when none). Not limited to 24 hours: it is the open queue, not history
connected_clients Only on the gateway's unverified-clients agent (system_role = unverified_mcp_clients); the key is absent on every other agent. The number of distinct registered (dcr_) clients that currently have a live grant acting through this agent (0 when none, and 0 while unverified clients are switched off for the workspace). A count only, no client list. Like calls_24h, it rides only on the owner/admin GET .../agents/{id} and the ?hosting=external list

A call is one request that reached a policy decision; the several records one request can leave count once. A call is blocked when it was refused and nothing allowed it: a call held for approval is waiting, not blocked, and a call whose only refusals are approval holds, and which an approver then allowed, is not blocked; a call refused by policy after approval still counts as blocked. A retry that carries the approval id while that approval is still pending counts as a waiting call, not a blocked one. A repeat call without the approval id counts as a new waiting call. A call refused because the project is locked, because the connector's outbound calls are blocked by policy, or because the connector's address points to a private or blocked network counts as a blocked call. A retry with an unknown, already used, rejected or expired approval id counts as a blocked call. The approval's own rejected or expired records are not counted as calls. The window ends now and reaches back 24 hours (a call exactly 24 hours old is inside; a record dated in the future, from clock skew, is left out until the clock reaches it). A call is classified by its records inside the window only: a held call whose hold record just precedes the window boundary, with nothing after it inside the window, is not counted.

If the figures cannot be read the request fails with 503 (retry) rather than showing zeros. An unknown ?hosting value is 400 invalid_hosting.

Owner and access state (owner, access)

The same two reads (GET .../agents?hosting=external and GET .../agents/{id}) add two more fields to the external agent rows the caller owns or administers. In the list, an external agent the caller can only see (for example one that is shared with them) carries neither owner nor access, nor the activity figures. Internal agents, and the list without ?hosting=external, carry none of them. No field is an email address or a user id.

owner names the account that owns the agent:

Value Meaning
{"state": "active", "name": "..."} The owner's account is live (name is null when the account has no display name)
{"state": "former"} The owner's account is disabled, erased or no longer exists

access says whether the agent can reach the MCP proxy right now:

state Meaning
connected The agent has a live MCP token, an active OAuth grant, a registered OAuth client, or is a system agent
revoked Its access was withdrawn (token revoked or rotated away, or the owner's credentials revoked) and nothing connects it now
expired Every token it had has run out and nothing connects it now
not_connected_yet It has never had a token or grant

Precedence is connected, then revoked, then expired, then not_connected_yet: a newer live connection always wins over an older withdrawal. A revoked row adds revoked_at (Unix time in seconds) and revoked_by, which is {"state": "active", "name": "..."} (name may be null) for the admin who withdrew access, {"state": "former"} when that admin is no longer active, or null when the withdrawal was automatic (for example a bulk credential revoke). revoked_by is the identity the request acted as: while a support person is signed in as a user, that user is recorded (the audit log keeps both). Other states carry neither key.

A revocation made before this tracking existed cannot be tied to an agent, so such an agent shows expired or not_connected_yet instead of revoked.

If the owner or access state, the pending_approvals count, or the connected_clients count cannot be read the request fails with 503 (retry) rather than showing a guess.

An agent that is deleted while the list is being read is simply left out of that list; the list does not fail. A GET .../agents/{id} for an agent deleted in the same moment answers 404, exactly as for an agent that never existed.

Run gates. An external agent is refused (agent_external) on: slug invoke (409), version restore (409), schedule create and webhook-trigger create (400), chat-bridge connection, and delegation (it is not offered as an agent__<slug> tool). It is excluded from agent pickers and workflow agent lists.

MCP tokens for an external agent

Route Result
GET .../agents/{id}/mcp-tokens [{id, label, created_at, expires_at, hint}], never the token. hint is the last 4 characters of the token (lowercase hex) so a token can be recognised in a list, or null for a token issued before hints were stored; it cannot be used to sign in. If a stored hint is unreadable the request fails with 500 {"error": "a stored token record of this agent is invalid; rotate the agent's tokens", "code": "invalid_token_hint"} rather than showing a guess; this is a permanent data fault, so retrying fails the same way. Recover primarily with POST .../mcp-tokens {"rotate": true}, which revokes every token of the agent and needs no token id, or with DELETE .../mcp-tokens/{token_id} using the id from the original 201 response. The fault is logged once at ERROR with the gateway, agent and token id and never the value. Only the agent's mcp_proxy tokens are listed; any other token bound to the agent is not
POST .../agents/{id}/mcp-tokens body {label?, expires_at?, rotate?} (an unknown field is 400 unknown_field with field; a body that is not a JSON object is 400 malformed_body); 201 {id, token, expires_at, hint}, the plaintext once. The token has the scope mcp_proxy and is bound to the agent's owner. rotate: true revokes the previous tokens in the same transaction. An internal agent: 409 agent_not_external. A transient database fault with no token stored answers 503 with Retry-After (mint again), any other storage fault the sanitised 500. Acting for another user's account, the caller must reach and out-rank the owner (see below): otherwise 403 target_outranks_caller
DELETE .../agents/{id}/mcp-tokens/{token_id} 200 {ok: true}; a token of another agent, a token that is not an mcp_proxy token, or an unknown id is 404. Revoking a token bound to another user's account needs reach and rank over that token's user (otherwise 403 target_outranks_caller)

Minting and rotating an MCP token obey the tenant token lifetime policy: under a cap, an expires_at that is missing, null or beyond the cap answers 400 with code: "token_lifetime_exceeded" and nothing is created or revoked. Each successful mint or rotate writes one token.minted audit row (route agent_mcp_tokens, with rotate, agent_id and label, never the token). This replaces the former agent.mcp_token_created / agent.mcp_token_rotated actions: filter the audit log on token.minted instead.

The generic POST /gateways/{gw}/tokens accepts an external agent_id only with exactly scopes: ["mcp_proxy"] and the owner's user_id; anything else is 400 external_agent_token_scope. Deleting the agent revokes its tokens: the tombstones and the agent delete are one transaction, so a failure leaves the agent and all its tokens untouched (503, retry).

Who may mint, rotate or revoke. The agent's owner, or an admin who reaches the owner (same tenant, never a platform admin unless the caller is one) and whose role out-ranks the owner's. This is the same rule as for any token of another user's account. A tenant_admin therefore cannot mint, rotate or revoke tokens on the agent of a peer tenant_admin or of a platform admin (403 target_outranks_caller). Listing (GET) is not rank-gated: it is read-only and never returns the secret, like the generic token list.

List agents

GET /admin/v1/gateways/{gw}/agents

Returns the caller's own + shared agents (admins: all in the gateway). Non-owned (shared) rows are redacted: tool_config is filtered to an allow-list of non-sensitive display flags (web_search, file, agentic_fetch, sources_footer) — every other key is dropped, so the owner's bound MCP connector ids (tool_config.mcp / mcp_allow), sub-agent bindings (tool_config.agents), the task-envelope template (tool_config.task_envelope), and any future credential-bearing key never reach a non-owner. The knowledge project_id / project_ids and source_metadata are removed too. Query params: ?shared=1 ("shared with me" only), ?usage=1 (annotate each owner row with usage_count, see below). Name search: POST /admin/v1/gateways/{gw}/agents/search with the JSON body {"q": "<name>"} (substring, case-insensitive; same ?shared= / ?usage= query params, same response) — the search text travels in the body, never in the URL. An absent or empty q → 400 q_required; malformed → 400 invalid_q. The former ?q=<name> on this GET still filters until 11 January 2027 and is marked Deprecation / Sunset; a repeated or valueless ?q is now 400 invalid_q (it used to return the unfiltered list). See Search and lookup values travel in the request body. The per-agent annotations (schedule_count / schedule_next_run_at, project_ids, areas_unresolved, and usage_count when ?usage=1) are read with the list: if any of those reads fails the request answers 503 { "error": "temporarily unavailable; retry later" } — never a list with zero counts, empty area sets or a missing areas_unresolved warning. The management UI additionally applies, client-side over the returned page (no extra request per keystroke), a tool facet (web search / knowledge files / fetch / MCP connectors), a tag facet (the curation category), a usage facet (used / never used), and a sort order (newest / recently updated / name / most used). Because facets/sort run over the returned page and the list is capped at 500 (created_at DESC), an agent outside the newest 500 is not surfaced by "most used" — the cap is shared by all sorts.

usage_count (?usage=1 only). Invocation count for the agent over the last 90 days on this gateway, counted from request_log (every agent-channel row, including blocked/failed — "how often invoked"). Emitted only for owner rows (it is the owner's own activity, like schedule_count; sharees don't get it) and only when the caller passes ?usage=1. The aggregate scans the high-volume request_log, so it is opt-in — the UI requests it lazily, only when the user engages the popularity sort or usage facet. Absent = treat as 0.

List signals: owner_name, compliance, connection_risk. Every row of the list carries these three keys (always present; null when not available).

  • owner_name -- the owner's display name only (never the email), shown to everyone who can see the row, including sharees. It is null only for a deleted owner or an owner without a name; a disabled owner's name still shows.
  • compliance -- from the review status: approved = reviewed; in_review and draft = not_yet_reviewed; flagged = needs_a_look; disabled = failed_review. Any other stored value is null (never guessed).
  • connection_risk -- from the bound MCP connectors and their tool classes: reads_only when no tool the agent may call can write, asks_before_writing when one can. Only tools the effective contract allows count; a tool blocked by the connector's policy, or not granted by the agent's consent, does not. A connector that is not available is skipped; a malformed consent grants nothing (reads_only); a malformed tool-class setting on a connector fails closed (the tool counts as destructive, so asks_before_writing). A connector-level consent for all tools (with other tools allowed) always yields asks_before_writing: unlisted tools cannot be enumerated and an unclassified tool is treated as destructive. This rule is coarse but fail-closed; it is awaiting confirmation by the product owner. A row whose tenant differs from the gateway's tenant is asks_before_writing. The set of values is open: a future wide_scope may be added, so clients must tolerate unknown values.
Caller owner_name compliance / connection_risk
owner of the agent, tenant admin, admin shown values
holder of AGENTS_REVIEW (any row) shown values
anyone else (sharee, org member) shown null

The signals add one connector read per request (only when a row that qualifies has MCP connectors) and no per-row queries. If that read, or the permission check, fails the request answers 503 { "error": "temporarily unavailable; retry later" }, never a guessed reads_only. The 500-row cap is unchanged.

Read an agent

GET /admin/v1/gateways/{gw}/agents/{id}

Owner/admin get the full config; a sharee gets the redacted view; everyone else 404.

Purpose (purpose, purpose_status)

An agent carries a short, human-written statement of what it is for. It is a versioned config field like name or instructions: every create/edit snapshots it into the agent_version history, and reads (GET agent, GET version, the versions list) return both fields. Runs do not read it.

  • purpose — string, required on create, optional on update. Edge whitespace (including newlines) is trimmed; the trimmed text must be non-empty and at most 1000 characters (the cap applies after trimming). Unicode spaces (NBSP, ideographic space, ...) count as whitespace; they are normalised to ASCII spaces and edge whitespace is trimmed, so a value of only Unicode spaces is empty, and the normalised text is what is stored. Control characters (C0 incl. tab/newline/CR, DEL, C1 U+0080–U+009F), the line/paragraph separators U+2028/U+2029, the interlinear annotation controls U+FFF9–U+FFFB, the braille blank U+2800, and every Unicode default-ignorable code point (zero-width and bidi controls, soft hyphen, byte-order mark, word joiner / invisible operators, Hangul fillers, Unicode tag characters …) are rejected anywhere in the value, edges included (they are not treated as trimmable whitespace). A variation selector (U+180B–U+180D, U+180F, U+FE00–U+FE0F, U+E0100–U+E01EF) is accepted only directly after a base of its own kind (a symbol or emoji, a CJK ideograph, a Mongolian letter), at most one per base; a selector anywhere else is rejected (exact bases: refused characters). The purpose is a single line: an interior newline or tab is rejected (invalid_purpose).
  • purpose_status — confirmed or unconfirmed, server-managed and read-only. Supplying the key in a create or update body at all — including a value echoed back from a GET — is refused with 400 purpose_status_server_managed; nothing is applied.
  • Confirm by sending the text: PATCH {"purpose": "..."}. Any accepted purpose sets the status to confirmed (also when the text is unchanged). Creating with a purpose stores it confirmed.
  • Absent on create is refused with 400 purpose_required (purpose is required); nothing is created. A key that is present but null, blank or too long keeps its own code below, so an omitted purpose and a malformed one are told apart. A PATCH without purpose leaves both fields as they are, and carries them into the new version snapshot. A create that was held for four-eyes approval before this rule and is applied after it ends apply_failed with the reason purpose is required; submit it again with a purpose.
  • Compare-and-set confirm. A PATCH may carry expected_version (a positive integer: the agent version the confirmer saw) together with purpose. If the agent has moved on, nothing is written and the answer is 409 { "error": "...", "code": "agent_version_conflict" }; reload and confirm again. The general rules of expected_version are in Compare-and-set updates; with a purpose the write additionally requires the purpose and its status to be the ones the server read.
  • Who may confirm. The agent's owner, an admin / tenant_admin, and a holder of the AGENTS_REVIEW permission (ki_manager) in the same tenant. Every PATCH also requires AGENTS_AUTHOR, so a reviewer needs both permissions. A reviewer who is not the owner must send purpose and expected_version (so the write is always a compare-and-set against the version they saw) and no other key, so the one-click confirm cannot be used to edit the agent. A reviewer confirms the text shown, never edits it: the purpose they send must equal the stored purpose (compared after the usual trimming and Unicode-space normalisation), otherwise the request is answered 404 agent_not_found and a held four-eyes replay is refused as requester_unauthorized. A reviewer can only confirm a purpose that is still unconfirmed: an owner-confirmed purpose is never overwritten by a reviewer (the same 404 agent_not_found, and a held four-eyes replay on an agent that became confirmed meanwhile is refused as requester_unauthorized). A request a non-owner is not eligible for (a missing expected_version, a wider body, a different purpose text, an already confirmed purpose, no AGENTS_REVIEW, another tenant, an agent the AGENTS_REVIEW holder cannot see, or a body that is not valid JSON) is answered 404 agent_not_found - the same answer as an id that does not exist. The request body is read before the agent is looked up, so a body the server refuses (too large, malformed) is answered identically for an existing and a missing id; only the agent's owner (or an admin) sees the 400 malformed_body. The governance dashboard lists the agents waiting for this.
  • A PATCH that changes only purpose is not run-affecting: it does not reset an approved agent's review status. Any other field alongside it still does.
  • Pre-history: versions written before this field existed return purpose: null and purpose_status: null. Agents that existed before read "" / unconfirmed.
  • Backfill: a background job gives every existing agent without a purpose a model-proposed purpose, stored as a new version with purpose_status: unconfirmed (see Purpose backfill). The review status is not touched and runs are unaffected. A human edit made in the meantime always wins.

Rejections are 400 with the error code:

Code Cause
purpose_required purpose absent on create, or empty / whitespace only (Unicode spaces included)
invalid_purpose not a string (including null, numbers, objects), not valid UTF-8, or contains a control / format / zero-width / soft-hyphen / tag / BOM / bidi character anywhere (edges included), or an interior newline or tab
purpose_too_long more than 1000 characters
purpose_status_server_managed purpose_status present in the body

Compare-and-set updates (expected_version)

A PATCH .../agents/{id} replaces every field it carries as a whole — tool_config included — so two writers that each read the agent, change different keys of tool_config and save would silently undo each other. Any PATCH may therefore carry expected_version: the agent version the client read (every GET returns it; every saved change raises it by one).

  • Accepted: a whole number >= 1, next to at least one field to change. It is never stored.
  • Stale: the agent's version is not expected_version any more → 409, nothing written: { "error": "the agent changed since you loaded it; reload and try again", "code": "agent_version_conflict" }. The same 409 answers a save that lands between the server's read and its write (the write itself is conditional on the version). Read the agent again and re-apply the change.
  • Rejected: expected_version that is not a positive whole number (a string, 0, a negative, a fraction, null, a boolean, an array or object), or a body that carries nothing but expected_version → 400 invalid_expected_version, nothing written (the earlier spelling expected_version_invalid is no longer sent; clients may accept both during the change). A malformed token is never treated as "no check".
  • Absent: the PATCH writes unconditionally (last write wins), as before.
  • With purpose: the write additionally requires the purpose and its status to be the ones the server read (the purpose confirm).
  • Four-eyes: the version is checked when the change is requested; a change held for approval (202 pending_approval) does not carry expected_version. A held change that replaces tool_config records the tool_config stored when it was requested. On approval it is applied only while the agent's tool_config is still exactly that one; if another change replaced it meanwhile, the approval ends apply_failed with the reason tool_config_changed, nothing is written, and the requester submits the change again on the current state. A save landing between the approval's read and its write leaves the approval pending (503; approve again). A held change that does not replace tool_config, and one requested before this check existed, applies as before.

The web app sends expected_version on every agent save that replaces tool_config:

  • Agent editor: the version of the agent it shows (as opened, then as returned by its own last save). An agent read without a usable version is never saved without the check (the save fails).
  • External agent permissions page and Approvals section: they read the agent again right before the write, take the keys they do not edit from that read (a concurrent change of those is kept) and send its version. If the keys they DO edit (the grants mcp / mcp_allow, or approval.ttl_seconds) changed since the page was opened, nothing is sent.

In every case the page then says the agent was changed elsewhere and nothing was saved.

Agent name

The name of an agent is required on create and may be sent on PATCH. It is checked in this order:

Input Create PATCH and restore
over 255 bytes 400 invalid_request, name must be a non-empty string (max 255 bytes) the same
not valid UTF-8 400 invalid_name, name is not valid UTF-8 400 invalid_name, name is not valid UTF-8
empty, or with nothing visible (spaces, no-break and ideographic spaces, zero-width and format characters, the braille blank, tag characters) 400 invalid_request, name is required 400 invalid_request, name must be a non-empty string (max 255 bytes)
anything else stored exactly as sent stored exactly as sent

A value with nothing visible gets the same answer as "" on the same route. A visible name is never trimmed, so a name wrapped in invisible characters is stored byte for byte. The draft preview runs the check too and answers 400 invalid_request with the message PATCH would give (the blank message, or name is not valid UTF-8). The purpose proposal keeps its own codes (name_required, name_too_long, malformed_body). A version whose stored name is blank or not valid UTF-8 cannot be restored (the restore gives the same answer as a PATCH sending that name); set its fields by editing the agent instead. A create, PATCH or restore held for four-eyes approval is validated again when it is approved; one whose name has since become invalid ends apply_failed.

The agent editor in the web app applies the same rule before it sends: an invisible-only name shows the "name is required" message and nothing is sent.

Instructions limit

instructions on POST …/agents and PATCH …/agents/{id} is at most 40000 characters (Unicode code points, not bytes; one emoji counts as one). The limit is served as limits.agent_instructions_max_chars on GET /admin/auth/me; the web app counts against it as you type and refuses an over-limit save, but the gateway enforces the same limit regardless. Rejections are 400 with a machine code and nothing is written:

Code Cause
instructions_too_long more than 40000 characters
invalid_instructions present but not a string (numbers, booleans, objects, arrays), or not valid UTF-8 (including lone surrogates and overlong encodings)

An omitted instructions on PATCH leaves the stored text unchanged. The purpose-proposal draft, Tidy the wording and the draft preview are held to the same limit; the draft preview answers 400 invalid_request (the message names the cause) instead of the specific instructions_* codes.

Review decisions: note, reason and history

The five review decisions (submit, approve, flag, disable, reactivate) take a JSON body, read before the agent is looked up:

Decision Body Allowed from
flag optional { "note": "<text>" } in_review, approved
disable required { "reason": "<text>" } as before
approve none ({} or no body) in_review, flagged (a flagged agent can be approved straight away)
submit, reactivate none ({} or no body) as before

note and reason are plain text: at most 1000 characters (after trimming), valid UTF-8, no control or invisible formatting characters. A decision that takes no input refuses any key. Every refusal is a 400 and nothing is written:

  • reason absent, null or blank on disable is 400 review_reason_required; too long is review_reason_too_long; control or formatting characters (or invalid UTF-8) is invalid_review_reason (formerly review_reason_invalid).
  • note too long is review_note_too_long; control or formatting characters is invalid_review_note (formerly review_note_invalid). A note that is present but blank is invalid_review_note: an absent note and a malformed one are not the same.
  • A body that is not a JSON object, an unknown key, or a value that is not a string is 400 invalid_request.

The decision, its text and the actor are stored in the review history in the same transaction as the status change. If the status change loses (invalid transition or a concurrent change) the answer is 409 and no history row exists.

GET /admin/v1/gateways/{gw}/agents/{id}/review-events returns { "events": [ … ] }, newest first, at most 100. Each event carries decision, actor, agent_version and created_at; a disable event also carries reason, and a flag event carries note only for a caller holding AGENTS_REVIEW: for anyone else the note key is absent (not null). The filtering is done on the server. Audience: the agent's owner, an admin / tenant_admin, and an AGENTS_REVIEW holder who can see the agent (own, shared with them or their group, or in the org catalog); anyone else, including an agent the reviewer cannot see, gets the same 404 agent_not_found as a missing id (MAP-3530). A ki_manager sees a catalog agent only while it is approved; after a flag or disable, only the owner, a tenant_admin, or a user or group share can approve or reactivate it, and an in_review agent is reviewable by a ki_manager only through a user or group share. actor is deliberately visible to the owner as well as to reviewers. actor is null when the deciding user was erased (GDPR): the event is kept, the pointer to the person is removed, and the note and reason that person wrote are erased (null) with them. Erasing the user who created an agent likewise erases the note and reason of the events of every agent that erasure deletes; the events themselves stay. The route is not behind the agents_enabled gate (like the other review decisions).

GET /admin/v1/gateways/{gw}/agents/{id}/review-history returns { "entries": [ … ], "truncated": false }: the whole story of the agent in one uniform list, newest first, at most 100 entries (the cap applies after the sources are merged; truncated is true when older entries are left out). Each entry is { "type", "actor_name", "actor_role", "created_at", "version", "text"? }.

  • type is one of created, published, submitted, approved, flagged, disabled, reactivated. A stored decision this version does not know is skipped, never echoed.
  • created comes from version 1 of the agent (its creator and time); an agent without a version-1 row (created before versions existed) still gets a created entry from the agent's own creation time, with actor_name: null. published has one entry per saved version from 2 on; its actor is the person who saved that version (the caller of the edit, restore or consent revoke; the requester of a change held for approval). Versions saved before this was recorded, and versions written by the system (the purpose backfill), have no actor (actor_name and actor_role are null). A hand-over of the agent writes neither a version nor an event, so it does not appear in the history.
  • actor_name is the person's display name, read in the agent's tenant. It is null when there is no actor, the user has no display name (for example an account created by the pay-first sign-up or an invitation without a name), the user was erased or deleted, or the user belongs to another tenant. The e-mail address and the user id are never returned.
  • actor_role says who acted relative to the agent, so an entry without a display name still names a role: owner (the agent's current owner), reviewer (anyone else on approved / flagged / disabled / reactivated), member (anyone else on created / submitted / published, for example the original creator after a hand-over), or null when no actor is recorded. The Governance tab shows the display name, otherwise "The owner" / "A reviewer" / "A team member", never the e-mail address.
  • created_at is unix seconds. version is an integer, or null for a decision stored without one.
  • text is the reason of a disabled entry (every caller allowed to read the history) and the note of a flagged entry only for a caller holding AGENTS_REVIEW; otherwise the key is absent (a blank or missing text also leaves it absent).
  • Entries are ordered by created_at descending; within the same second a decision comes before a publish before the creation, then the higher version, then the storage order.

Audience and gates are those of review-events: an authoring role, access to the gateway, then the agent's owner, an admin / tenant_admin, or an AGENTS_REVIEW holder who can see the agent; anyone else gets the same 404 agent_not_found as a missing id. The route is not behind the agents_enabled gate. Any failed read is a 503 (retry), never a partial history.

The agent read (Read an agent) of the owner carries review_disable_reason: the reason of the latest disable event while the agent is disabled, otherwise null (also null for an agent disabled before the history existed). It is never part of the shared or catalog view of an agent. A failed history read is a 503, never null.

Agents waiting for review (Approvals inbox)

GET /admin/v1/me/agent-reviews lists the agents of the caller's tenant that wait for a review decision. It feeds the agent rows and the count badge of the Approvals inbox (its Open tab).

  • Accepted callers: tenant_admin, or admin with a tenant. An ai_manager (ki_manager), a member and a custom role without the tenant-admin gate get 403. A session without a tenant (a platform admin who has not selected one) gets 401 unauthenticated. An impersonated session gets 403.
  • Response: { "agents": [ { "id", "name", "gateway_id", "owner_name", "submitted_at" } ], "total": <n> }. owner_name is always present, a string or null (null when the owner no longer exists). Unlike the owner_name of the agent list, it may be the owner's email address when the owner has no display name. submitted_at is unix seconds when the agent's newest review event is a submit, otherwise null. Oldest submitted first.
  • Scope: status in_review, in the caller's tenant only, only while the tenant has agent_review_required on, and only on gateways the caller's gateway lists show: disabled gateways are listed, while test and archived gateways are left out unless the caller is a test-TLD user (the hide_for_caller rule). At most 200 rows are returned; total is the count after the filters, taken over the 2000 oldest in-review agents of the tenant (above that it understates).
  • Errors: 401 (no session or tenant), 403 (role or impersonation), 503 (storage fault; never an empty list, so a client cannot read a fault as "nothing pending").

Purpose proposal

The model can propose a purpose for you to review. Nothing is stored: the endpoints return text only, and saving it is a separate, explicit PATCH {"purpose": "..."} (which validates it again). The call runs on the Myra fleet model (local, never an external provider), bound by the gateway's residency and guardrail configuration; a proposal that would be blocked is never returned.

  • POST /admin/v1/gateways/:gw/agents/purpose-proposal — for a draft that is not saved yet. Body: {"name": string, "instructions": string, "connectors": [string, ...]}. name is required; instructions and connectors are optional (absent = none).
  • POST /admin/v1/gateways/:gw/agents/:id/purpose-proposal — for a stored agent, built from its saved config. No body is needed; any body is ignored (it is not even parsed, so malformed JSON is fine). An unknown agent, or one that is not in your tenant, is 404.

Both need an authoring role on the gateway and the agents_enabled gate. They are rate limited to 20 calls per minute per user (429 rate_limited, Retry-After: 60).

Responses. A model failure is not an HTTP error: the call answers 200 and the UI falls back to manual entry.

Status Body Meaning
200 {"purpose": "...", "source": "model"} a proposal, already passed through the same validation as a saved purpose (1 to 1000 characters, single line, no control / format characters)
200 {"purpose": "", "source": "none", "reason": R} no proposal; R is one of dispatch_blocked (a dispatch gate refused the internal model, or the tenant is suspended with the tenancy switch on, which carries dispatch_reason: "other"; the body then also carries dispatch_reason, see Dispatch refusal reasons), model_unavailable, guardrail_blocked, guardrail_unavailable (the guardrail service could not decide, so the call fails closed), unusable_output (empty, cut off at the token limit, or invalid)
400 {"error": ..., "code": C} the request is malformed
404 {"error": ..., "code": "agent_not_found"} stored-agent route: unknown or foreign agent
429 {"error": ..., "code": "rate_limited"} rate limit

Draft-route 400 codes:

Code Cause
malformed_body invalid JSON, or invalid UTF-8 / lone surrogates anywhere in the body
invalid_body absent, scalar or array body
name_required missing, empty, or nothing visible (only whitespace, Unicode spaces, control, zero-width / format characters or the braille blank, see blank)
invalid_name present but not a string
name_too_long over 255 bytes
invalid_instructions present but not a string (including null)
instructions_too_long over 40000 characters
invalid_connectors not an array ({} counts as the empty array), more than 10 entries, or an entry that is not a string, has nothing visible (see blank), or is over 128 characters

A field that is present but has the wrong type is always rejected, never treated as absent.

Unknown keys are ignored.

The web app leaves connectors with no visible name out of the draft.

Invalid UTF-8 in a name is also invalid_name (a name that is both over 255 bytes and not valid UTF-8 answers name_too_long: the byte length is checked first), but over HTTP invalid UTF-8 in a purpose-proposal body is already rejected by the body parser as malformed_body. (Agent create and update answer invalid_instructions for the instructions; see Instructions limit.)

The draft is held to the same input rule as creating or updating an agent: control characters (C0 incl. tab/newline/CR, DEL, C1 U+0080–U+009F), the line/paragraph separators U+2028/U+2029, the interlinear annotation controls U+FFF9–U+FFFB, the braille blank U+2800, and every Unicode default-ignorable code point (zero-width and bidi controls, soft hyphen, byte-order mark, word joiner / invisible operators, Hangul fillers, Unicode tag characters …) in name, instructions or a connector name are not rejected on a draft. A variation selector (U+180B–U+180D, U+180F, U+FE00–U+FE0F, U+E0100–U+E01EF) is kept only directly after a base of its own kind (a symbol or emoji, a CJK ideograph, a Mongolian letter; exact bases: refused characters), at most one per base; a misplaced or repeated selector is treated like the rest of that set. Before the text is sent to the model, both routes strip every character of that set that is not in its proper place (TAB, LF and CR are kept; a kept selector such as the one in ❤️ stays), so the model sees the same cleaned text for a draft and for the saved agent.

Plan proposal

POST /admin/v1/gateways/:gw/agents/plan-proposal helps an author turn a task into an agent plan. Given a short task description (and, optionally, files and connectors the task is about), the model either asks up to three clarifying questions or proposes a plan. Nothing is stored. The plan is text for the author to review; creating the agent is a separate, explicit call.

Body (every other key is refused, never ignored):

{
  "task": "Summarise the weekly sales report and mail me the result",
  "file_ids": ["<chat attachment id>"],
  "connector_ids": ["<connector id>"],
  "answers": [{"q": "Which team?", "a": "Finance"}]
}
Field Rule
task required text (absent, null or blank is 400 task_required, over 2000 characters is 400 task_too_long), 1 to 2000 characters after trimming; control and invisible formatting characters are refused (tab and newline are kept)
file_ids optional (absent or null = none) array of chat attachment ids (UUIDs), at most 20, duplicates dropped
connector_ids optional (absent or null = none) array of connector ids, at most 10 (the same limit as an agent), duplicates dropped
answers optional array of {"q", "a"} text pairs: q up to 300 characters, a up to 1000. At most 3

A field that is present but has the wrong type (a non-array, a non-string id, a malformed id) is 400 invalid_plan_proposal (formerly plan_proposal_invalid); it is never treated as absent. A fourth answer is its own refusal, 400 too_many_answers (formerly plan_proposal_too_many_answers): the question budget is used up, so ask for the plan.

The three questions are one budget across the whole conversation: send each question you were asked back in answers, and the model is told how many questions it has left. With none left it can only return a plan; a reply that still asks questions is answered 502 plan_proposal_unusable_output.

Which ids are read. Only the ids the caller may actually reach are used. A connector must be one the caller can see in this tenant; a file must be one of the caller's own chat attachments. An id the caller cannot read (unknown, another tenant's, another user's) is silently omitted: the answer is identical to the one for an id that does not exist, so the call cannot be used to probe for ids. A storage fault while looking an id up is a 503, never a silent omission. Only the attachment's id and file name are read; no file content and no conversation reaches the model. Connector and file names are cleaned of control and invisible characters before they go into the prompt.

Needs an authoring role on the gateway and the agents_enabled gate. Rate limited to 30 calls per hour per user (429 rate_limited, Retry-After: 3600).

Responses.

Status Body Meaning
200 {"questions": [...], "can_reach": [...], "cannot_do": [...]} the model needs more information: 1 to (3 minus the answers sent) questions, each {"q": string, "hint"?: string, "options"?: [string, ...]} (at most 6 options)
200 {"plan": {...}, "can_reach": [...], "cannot_do": [...]} a plan: name (up to 255 bytes), purpose (passes the same validation as a saved purpose), steps (1 to 10 short strings), instructions (multi-line, within the agent instruction limit)
400 {"error": {"code": C, "message": ...}} task_required, task_too_long, invalid_plan_proposal, too_many_answers
402 / 403 / 429 refusal body the same account-state, budget and wallet refusals as every other model call (see below), plus the rate limit; the department (team) budget answers 429 team_budget_exceeded
401 / 500 / 503 unauthorized, configuration_error, spend_unverified the caller no longer exists; the department binding is malformed or points to a missing department; the department binding could not be read (retryable); on a partner-billed workspace also an unreadable gateway, per-user or team spend (retryable)
403 plan_proposal_dispatch_blocked a dispatch gate of the gateway does not allow the internal model (Myra) the builder runs on; reason says which and message matches it, see Dispatch refusal reasons
422 plan_proposal_guardrail_blocked a guardrail blocked the request; for an admin the error object names the rule (rule.name, rule.type), see Tidy the wording
502 plan_proposal_unusable_output the model reply was empty, cut off, invalid, or asked questions with none left
503 plan_proposal_model_unavailable, plan_proposal_guardrail_unavailable, or a storage fault the call could not be made; the guardrail case fails closed

The model is told what the agent can reach and cannot do (the same can_reach and cannot_do the response carries) as hard constraints: its questions and options may only offer what the agent can reach and do, and its plan steps and instructions may not use anything listed in cannot_do. With no reach it is told the agent has no connectors and no files. It is also asked for schema-constrained JSON (questions are not offered once the question budget is spent), but the server does not rely on that: it still validates every reply and answers 502 plan_proposal_unusable_output on any deviation.

The reply is validated strictly: a closed set of keys, bounded text, valid UTF-8 without control or formatting characters. Anything else is plan_proposal_unusable_output; a half-valid plan is never returned.

can_reach and cannot_do are computed by the server, never by the model. A model reply that contains either key is refused.

  • can_reach lists the connectors and files from the request that the caller can read, connectors first, then files, in request order: {"id": ..., "name": ..., "type": "connector" | "file"} (empty array when none).
  • cannot_do lists what an agent built for this task could not do on this gateway, in the fixed order write, external_send, web:
    • write is listed when no reachable connector can change anything. A connector counts as able to write when its consent is not read-only for every tool, judged by the same rule as the connection_risk signal of the agent list.
    • external_send is listed when the agent cannot send anything out of the gateway: it has no writable connector and no web access.
    • web is listed unless the gateway has a configured web-search provider and is not local-only. When the gateway's locality cannot be determined it is treated as local-only (listed).

Metering and wallet. The call runs on the Myra fleet model (never an external provider), is billed like the other off-chat model calls, and appears in the usage log as kind agent_plan_proposal with the caller's user id. A prepaid wallet is claimed before the model is called and settled with the tokens the model reports; a reply with no usable token count bills nothing (never an estimate), and a call that is refused before it reaches the model (account state, budget, wallet, residency, guardrail) spends nothing. A model failure after the call was made is logged as a 502 with zero tokens.

Tidy the wording

POST /admin/v1/gateways/:gw/agents/instructions-tidy asks the model to rewrite an agent's instructions in clear, plain language. Nothing is stored. The answer is a proposal for the author to compare with the current text; saving it is the ordinary PATCH …/agents/{id} (or the create call), which validates it again.

Body (exactly one key; every other key is refused, never ignored):

{ "instructions": "<the current instructions>" }

instructions is held to the same rule as a saved agent's instructions (see Instructions limit): a string, valid UTF-8, at most 40000 characters (Unicode code points). Control and invisible formatting characters are accepted, as they are on save, but they are removed before the text goes to the model. A text with nothing visible left is refused.

Status Code Cause
400 instructions_required no body, {}, instructions absent or null, or blank (only whitespace, invisible or control characters)
400 invalid_instructions instructions is not a string (number, boolean, object, array), or not valid UTF-8 (defence in depth: over HTTP, invalid UTF-8 is already refused by the body parser as malformed_body)
400 instructions_too_long more than 40000 characters
400 invalid_request the body is not a JSON object (array, string, number, null), or it has a key other than instructions
400 malformed_body the body is not valid JSON, or carries invalid UTF-8 (including an encoded or JSON-escaped lone surrogate such as "\ud800")

These 400 answers are {"error": "<message>", "code": "<code>"} and are checked before anything else (before the rate limit and before any model call).

Too long to tidy in one go. The rewrite is bounded to 16000 output tokens, and a rewrite is about as long as its input. A text that cannot fit is refused before the rate limit, the admission checks and the model call, so nothing is billed: 413 instructions_tidy_too_long ("These instructions are too long to tidy in one go."). The gateway estimates the input at about 3.5 bytes of UTF-8 per token (the instructions plus the fixed prompt), so the limit depends on the script: a Latin-script text of the full 40000 characters fits; a text of mostly two-byte characters (for example many umlauts or Cyrillic) fits up to about 27000 characters, and a CJK text (three bytes per character) up to about 18000 characters. A text over the limit can still be saved and edited; only the tidy is refused.

A guardrail that changes the text. The instructions pass the gateway's request guardrails before the model sees them, with one exception: agent instructions are trusted author text, so the input-injection guardrails (Prompt Injection and Jailbreak) do not run on them; at run time an agent's instructions are its system prompt, which those guardrails do not judge either. The other guardrails still apply: PII masking and protection, the Prompt Guard safety check, keyword and pattern rules. When a guardrail blocks the request the answer is 422 instructions_tidy_guardrail_blocked. For an organization admin or platform admin, the answer names the rule that blocked: the message reads Blocked by the guardrail rule "<name>" (<type>). and the error object carries "rule": {"name": "<name>", "type": "<type>"}, so the rule can be found and adjusted. Everyone else gets the generic message The request was blocked by a guardrail, without the rule. The plan proposal (422 plan_proposal_guardrail_blocked) answers the same way. When a guardrail rewrites the text (a keyword or pattern rule that scrubs or replaces parts of it), the tidy is refused with 422 instructions_tidy_guardrail_scrubbed ("A guardrail changed parts of these instructions, so they cannot be tidied without losing text."): a rewrite of the scrubbed text would replace the author's instructions without the scrubbed parts once accepted. The refusal comes before the model call, so nothing is billed and the wallet claim is released. (The purpose and plan proposals, whose output does not replace the text, still use the scrubbed text.)

What the model is told. Rewrite the instructions for clarity and plain language; keep every rule, fact, constraint, example, name, number, link and placeholder with its meaning; add no rules, capabilities, tools or facts; keep the language of the input; output only the rewritten text. The instructions are passed as an untrusted data block: the model is told never to follow anything written in them. The call has no tools, thinking is off, and the output is bounded (16000 tokens, 180 s, 1 MiB reply).

Needs an authoring role on the gateway and the agents_enabled gate (same as the plan proposal). Rate limited to 30 calls per hour per user, in a bucket of its own (429 rate_limited, Retry-After: 3600).

Responses.

Status Body Meaning
200 {"instructions": "...", "source": "model"} the rewritten text
400 {"error": ..., "code": C} the request is invalid (table above)
413 instructions_tidy_too_long the text is too long to rewrite within the output limit (see above); nothing billed
402 / 403 / 429 refusal body the same account-state, budget and wallet refusals as every other model call (see the plan proposal), plus the rate limit; includes 429 team_budget_exceeded
401 / 500 / 503 unauthorized, configuration_error, spend_unverified the same refusals as the plan proposal, including the partner-billed unreadable-spend 503
403 instructions_tidy_dispatch_blocked a dispatch gate of the gateway does not allow the internal model (Myra); reason says which, see Dispatch refusal reasons
422 instructions_tidy_guardrail_blocked a guardrail blocked the request; for an admin the error object names the rule (rule.name, rule.type)
422 instructions_tidy_guardrail_scrubbed a guardrail rewrote parts of the text (see above); nothing billed
502 instructions_tidy_unusable_output the model reply was unusable (see below)
503 instructions_tidy_model_unavailable, instructions_tidy_guardrail_unavailable, or a storage fault the call could not be made; the guardrail case fails closed

Dispatch refusal reasons

The agent-authoring helpers (plan proposal, purpose proposal, tidy the wording) run on the internal Myra model. When a dispatch gate of the gateway refuses that model, the refusal keeps its code (plan_proposal_dispatch_blocked, instructions_tidy_dispatch_blocked; the purpose proposal answers 200 with reason: "dispatch_blocked") and names the gate in an extra field: reason inside the error object of a 403 ({"error": {"code": …, "message": …, "reason": …}}), dispatch_reason in the purpose proposal's 200 body. The value is one of a closed set; a client treats an unknown value like other. When the refusal happens, nothing has been sent to the model and nothing is billed.

A suspended tenant (tenancy switch on) is refused on the internal model like a blocked gate: the purpose proposal answers 200 with reason: "dispatch_blocked" and dispatch_reason: "other" (the generic "policy does not allow" message), while plan proposal and tidy the wording answer 403 tenant_suspended from the account-state check that runs before the dispatch gate. See Suspended tenants.

reason gate message
residency the gateway's data residency This gateway's residency policy does not allow the internal model
provider_not_allowed the gateway's provider allowlist does not include Myra (for example an access tier for one external provider) This gateway's provider allowlist does not allow the internal model (Myra)
model_disabled an administrator switched the internal model off on this gateway The internal model is disabled on this gateway
provider_not_configured the internal model is not set up on this gateway The internal model is not set up on this gateway
plan_not_allowed the workspace's plan does not include Myra-hosted models Your plan does not include the internal model
provider_objected the organization objected to Myra as a sub-processor Your organization has objected to the provider of the internal model
other any other gate This gateway's policy does not allow the internal model

When the refusal happens is unchanged by the reason. The Build tab shows a sentence per reason that says what to do (for provider_not_allowed: choose another access tier in the composer, or, with a single access tier, ask an administrator or use Advanced setup); the other helpers keep their general sentence.

The 413, the model-failure and the guardrail answers use the error envelope {"error": {"code": C, "message": ...}}, like the plan proposal.

The reply is untrusted and checked before it is returned. Line endings are normalised to LF and the edges trimmed. The reply is refused as 502 instructions_tidy_unusable_output when it was cut off at the token limit, is not a string, is blank, is not valid UTF-8, is over 40000 characters, contains a control or invisible formatting character (tab and newline are allowed), or prints the data-block markers. A text that passes is also checked by the same validator a typed text passes on save. Part of a reply is never returned.

Metering and wallet. As for the plan proposal: the call runs on the Myra fleet model (never an external provider), is billed to the caller and appears in the usage log as kind agent_instructions_tidy. A prepaid wallet is claimed before the model is called (sized on the 16000-token output cap) and settled with the tokens the model reports. An unusable reply is still billed for the tokens it used; a reply with no usable token count bills nothing; a call refused before it reaches the model (account state, budget, wallet, residency, guardrail block or rewrite) spends nothing and releases the claim; a text that is too long to tidy is refused before the claim; a model failure after the call was made is logged as a 502 with zero tokens.

Purpose backfill (platform operations)

Existing agents that have no purpose ("" / unconfirmed) are filled by a background job with the purpose proposal described above, stored as a new version that stays unconfirmed until a human confirms it with PATCH {"purpose": "..."}. It runs on a timer in the backend (a small batch per tick, with a pause between model calls) and never changes the review status. When no usable proposal is available the purpose stays "" and the job retries later. Agents of a suspended tenant (tenancy switch on) are skipped when the candidates are selected and are picked up after the resume; a tenant suspended in the middle of a pass gets the 1 hour transient retry (outcome error).

POST /admin/v1/agent-purpose-backfill/run (platform admin only) runs a pass right away. The body is optional: {"gateway_id": "<gateway uuid>"} limits the pass to that gateway's agents. An absent, empty or {} body runs an unscoped pass over all gateways. An unscoped pass skips agents created less than 10 minutes ago (so an agent that is still being set up is not proposed on); a scoped pass has no such grace. A body that is present but malformed is refused and nothing is queued.

Status Meaning
202 {"scheduled": true, "scoped": false} - a pass was queued; it runs in the background (scoped is true when a gateway_id was given)
202 {"scheduled": false, "already_pending": true, "scoped": ...} - a trigger for the same scope (global, or the same gateway_id) is still waiting for or holding the lease on this worker; nothing new was queued and that pending pass covers the request. A trigger for a different gateway is queued normally
400 {"code": ...} with one of invalid_body (not a JSON object), unknown_field (a key other than gateway_id), invalid_gateway_id (not a gateway uuid), unknown_gateway (no such gateway)
401 / 403 not authenticated / not a platform admin
503 {"code": "schedule_failed"} - the pass could not be queued; retry. {"code": "gateway_lookup_failed"} - the gateway could not be checked; retry

Deleting an agent

DELETE /admin/v1/gateways/{gw}/agents/{id}

Deletes the agent. Restricted to the agent's owner or a tenant_admin/admin (a non-owned / cross-tenant / missing id → 404, no existence leak — the same gate as the other agent routes). On success the response is 200 { "ok": true }, and the deletion is recorded in the audit trail as agent.deleted.

The agent's review history is not deleted with the agent: the decisions, their text and the actors stay for 730 days from each decision, as governance evidence, and are then deleted by the retention sweep. When a user is erased, the free-text note and reason of the review history of the agents the erasure deletes are removed first; the decision and time stay, and so does the actor, except where the erased user made the decision: there the actor is removed (null). The note and reason the erased user wrote as a reviewer are removed as well, also on agents that remain.

Confirming a hand-over

When an agent's owner is erased (or an administrator hands it over, see Erasing a user), the agent's created_by becomes the successor and two fields appear on the agent: handed_over_at (unix seconds) and handover_confirmed_at (unix seconds, null until confirmed). While handed_over_at is set and handover_confirmed_at is null the agent is paused:

  • invoking it answers 409 { "code": "agent_handover_pending" } (a caller who cannot see the agent still gets 404);
  • delegating to it as a sub-agent is refused with the same code;
  • its schedules do not fire (those slots are skipped without a failure strike or notification) and its webhook triggers are refused with 403;
  • queued runs for it are cancelled when the hand-over happens;
  • a run that is already executing is stopped at its next MCP tool call, which is refused with reason agent_paused;
  • a chat-bridge turn gets a dedicated reply saying the assistant is being handed over, instead of a generic failure;
  • no result is delivered: an e-mail delivery answers 409 agent_handover_pending, and approved held deliveries wait until the agent runs again (they are neither sent nor expired). A delivery the scheduler had already started and that is refused for this reason is recorded as delivery_status: skipped_paused — not a failure, so no strike and no owner notice. skipped_paused is terminal: that hold is not re-sent after the agent is confirmed again — the owner re-runs the agent.

GET /admin/v1/gateways/{gw}/agents/{id} also names the successor for a handed-over agent, in a derived successor object (it is read from created_by at request time; nothing extra is stored). The key is absent when the agent was never handed over, and it stays present after the hand-over is confirmed. It is resolved within the agent's own tenant:

  • { "state": "active", "name": "Jonas Weber", "email": "jonas@example.com" } - the successor has a live account. name is the trimmed display name, or JSON null when it is blank. email is included only for the agent's owner and tenant administrators; anyone else who can see the agent (for example an organisation-shared member) gets name alone, with no email key.
  • { "state": "former" } - the successor was deleted, disabled, no longer exists, or belongs to another tenant. It carries no name and no e-mail.

If the lookup itself fails, the request answers 503 { "error": "temporarily unavailable; retry later" } (never former and never a response without the field).

POST /admin/v1/gateways/{gw}/agents/{id}/handover/confirm

Re-enables the agent. Only the agent's current owner (the successor) may confirm: any other caller, including a tenant administrator, gets 403 { "code": "handover_owner_only" }; an agent of another tenant, a missing id, or an agent the caller cannot see is 404. The body must be absent or {}; any other body is 400 invalid_request. A second confirmation, or an agent that was never handed over, answers 409 { "code": "handover_not_pending" }. On success 200 { "ok": true }, handover_confirmed_at is set, and schedules and triggers resume.

The successor learns of the hand-over in two ways: one e-mail per erasure, and a "handed over to you" section in the notification bell (fed by handover_pending on GET /admin/auth/me) whose entries link straight to the agent and disappear once it is confirmed.

Agent paused by automatic protection

In the console, the pause shows on the agent list and the agent page, with the evidence and an inline Resume agent form: see When automatic protection pauses an agent.

An agent can be paused by automatic protection. The agent then carries protection_paused_at (unix seconds; absent or null when not paused). A paused agent runs nothing:

  • invoking it answers 409 { "code": "agent_protection_paused" } (a caller who cannot see the agent still gets 404);
  • delegating to it as a sub-agent is refused with the same code, and schedule run-now answers 409 agent_protection_paused;
  • its schedules do not fire (skipped without a failure strike or notification) and its webhook triggers are refused with 403;
  • queued runs for it are cancelled when the pause is set;
  • a run that is already executing is stopped at its next MCP tool call, which is refused with reason agent_paused;
  • a chat-bridge turn gets a dedicated reply saying the assistant is paused, instead of a generic failure;
  • no result is delivered: an e-mail delivery answers 409 agent_protection_paused, and approved held deliveries wait until the agent runs again (they are neither sent nor expired). A delivery the scheduler had already claimed when the pause landed and that is refused for this reason is recorded as delivery_status: skipped_paused — not a failure, so no strike and no owner notice. skipped_paused is terminal: that hold is not re-sent after the agent resumes — the owner re-runs the agent;
  • it is not offered as a delegate tool to other agents.

What the pause does not do: it cannot interrupt a model call or a built-in tool that is already in flight; it takes effect at the run's next MCP tool call. The pause is recorded in the audit trail with the evidence that triggered it, and repeating it changes nothing.

Automatic deny-burst detection

A stored agent whose tool calls are refused over and over is paused automatically. When one agent collects at least N refused (deny) tool-call access decisions within M seconds, the gateway pauses it with the same pause described above. The evidence stored with the pause (read it with GET .../protection) is { "signal": "deny_burst", "count": <denies counted>, "threshold": N, "window_s": M, "last_decision_id": <id> }.

  • Thresholds are per tenant. The defaults are 20 refusals within 300 seconds. A tenant administrator (own organisation) or a platform administrator can change them with the tenant PATCH (see Updating a tenant): protection_deny_burst_count (whole number 5 to 1000) and protection_deny_burst_window_s (whole number 60 to 86400, i.e. one minute to one day). A field you do not send keeps its value; a value that is out of range, not a whole number, a string or null is refused with 400 and nothing is changed. A change is audited as tenant.protection_thresholds_changed with the old and new values. In the console the thresholds of all three signals (and protection_count_expiries) are also editable on Organisation settings › Agents › Agent protection (see Agent protection). Under config approval (four-eyes) a tenant administrator's change is held for a second administrator (202 pending_approval) and applies only when it is approved; see Updating a tenant.
  • After a resume, only newer denials count. Refusals recorded before the agent was resumed are not counted again: only denials newer than the resume count towards the threshold, so a resumed agent is not paused again by the burst it was just released from.
  • What counts. Only refusals recorded for that agent. Calls that were allowed, calls held for approval, or refused where no hold is possible (approval_required, approval_awaiting, untrusted_egress, approval_rejected, approval_expired; repeated rejections are a separate signal, see below) and calls refused only because the agent is already paused (agent_paused) are not counted, so a pause is never extended or re-triggered by the calls it blocks. approval_required is not counted because a client that repeats a call waiting for approval is following the approval flow, not misbehaving. untrusted_egress is not counted either: it is the hold, or where no hold is possible the refusal, of the untrusted-content control. Waiting for the credential holder is not misbehaviour and nothing is sent; a hold that is then rejected or expired is counted by the repeated-rejection signal. A built-in egress call (fetch_url, agentic_fetch, web_search) refused for a missing, mismatched or already-used waiver is recorded as untrusted_egress and is likewise not counted (nothing is sent). Refusals that signal a real anomaly still count: a call over the per-token pending-approval cap (approval_pending_cap), and a retry with another token, an unknown approval id or an already used, rejected or expired approval (approval_retry_*). Open approvals raised through the MCP proxy are bounded by the per-token cap (mcp_proxy_max_pending_holds, default 20 per token), so one agent can hold at most its number of tokens times that cap through the MCP proxy; repeated calls waiting for approval are limited only by the MCP request rate limit, not by the automatic pause. Refusals of the project lock (project_lock), of the outbound-call block of a connector (egress_blocked) and of a connector address on a private or blocked network (connector_url_blocked) appear in the activity figures but are not counted here either: they say nothing about the agent's behaviour. The reasons agent_paused, approval_awaiting, approval_required, untrusted_egress, approval_rejected, approval_expired, project_lock, egress_blocked and connector_url_blocked are never counted, whatever the caller; neither are the delegation guards working as designed (delegation_depth_exceeded, delegation_cycle_detected, delegation_fanout_exceeded, delegation_budget_exceeded, delegation_time_exceeded, delegation_deadline_exceeded, agent_delegation_forbidden), a sub-agent that cannot be called (agent_not_found, agent_misconfigured, agent_not_configured, agent_external, agent_handover_pending, agent_protection_paused), the tool permission policy and chat confirmations (agent_tool_policy, interactive_confirm, interactive_approval, approval_not_held, confirm_requested, confirm_cancelled, chat_approval_awaiting, chat_approval_rejected, chat_approval_expired, chat_approval_withdrawn, chat_approval_not_opened); neither are the web-call refusals written before a send (web_exfiltration_blocked, web_pii_blocked, web_pii_mandate, web_scrub_failed, web_residency_blocked, web_turn_cap, web_address_blocked, web_domain_blocked: nothing left the gateway); neither are the agent's own settings working as designed (agent_constraint, agent_constraint_malformed and agent_protection, a model call refused by the agent's protection). Decisions that are not tied to a stored agent are not counted either. Holds raised by the gateway's own tool loop are not bounded by the per-token pending-approval cap (mcp_proxy_max_pending_holds).
  • When it runs. Detection happens just after the refusal is recorded, outside the request: the call that crosses the threshold is still answered as a normal refusal, and the pause applies to the agent's next call. A call already in flight is not interrupted.
  • Fail safe. If the detector itself cannot run (for example the database cannot be read), it does not pause and does not resume any agent: it logs an error and raises a platform alert (at most one per ten minutes). No user notification is sent.
  • Pausing an agent that is already paused changes nothing; resume it as described below.
  • Who is told, once per pause. The pause that actually takes effect sends one e-mail per recipient, in the recipient's language and branded with the tenant's product name (template agent-protection-paused). Recipients are the agent's owner plus the tenant's active administrators and KI managers, de-duplicated by address (case-insensitive); an account that is deleted or disabled is never mailed. The mail names the agent, the signal and the observed count, and links to the agent: for refused calls the count of refusals (at least 1); for repeated approval rejections the number of approvals rejected within the window ("5 approvals rejected within 1 hour", or "rejected or expired" when the organisation counts expired approvals), followed by the list of what counted and the settings in force; for a volume spike the number of read or write calls in the run and the agent's usual per-run figure ("240 read calls in one run (usually about 12 per run)"). Only whitelisted whole numbers and the read/write class are ever written into the mail, never a stored evidence string. The window is written in the largest whole unit that fits (hours, else minutes, else seconds: a 90-second window reads "90 seconds", never a rounded figure). A tenant that is deleted has no recipients. It is best-effort and sent right after the pause is written: a mail failure never undoes the pause. A second detection of an agent that is already paused sends nothing; a pause after a resume is a new pause and is announced again. The owner additionally gets a direct message in each chat workspace (Slack, Mattermost) they are connected to, once per pause, with the same reason text as the mail and a link to the agent; it is best-effort (a failure never undoes the pause or the mail) and Teams is not supported. See Protection pause DMs.
  • In-app notice. GET /admin/auth/me carries protection_paused, a live list of the caller's own agents that are currently paused by automatic protection (see there). Nothing is stored for it, so it empties as soon as the agent is resumed.

Automatic repeated-rejection detection

A stored agent whose held tool calls are refused by people over and over is paused automatically, with the same pause described above. When at least N different held actions of one agent are rejected within M seconds, the gateway pauses it and tells the owner as for any automatic pause. Approvals that expire undecided count too only when the organisation turned that on (protection_count_expiries, below). The owner is warned before the pause. The evidence (read it with GET .../protection) is { "signal": "approval_rejections", "count": <distinct holds counted>, "threshold": N, "window_s": M, "count_expiries": <true|false>, "warned_at_ms": <unix ms>, "warned_count": <count the warning reported>, "last_decision_id": <id of the newest counted record> }. count_expiries is the setting that applied when the agent was paused, and warned_at_ms is present only when the owner was warned in the same window. warned_count is the count the early warning reported (the console shows "warning sent 10:39 (at 4 of 5)"). It is present only together with warned_at_ms, and only when the warning was sent under the same settings as the pause (the same threshold N, window and protection_count_expiries). If one of them was changed between the warning and the pause, only the time is kept. A pause recorded before these fields existed has none of them, and it reads exactly as before. A present but malformed field makes the whole evidence unreadable: a non-boolean count_expiries, a warned_count that is not a whole number, a warned_count without warned_at_ms, or a warned_count that is not below threshold. Unreadable evidence gives the generic text.

  • Thresholds are per tenant. The defaults are 5 rejections within 3600 seconds. A tenant administrator (own organisation) or a platform administrator can change them with the tenant PATCH (see Updating a tenant): protection_rejection_count (whole number 2 to 100) and protection_rejection_window_s (whole number 300 to 604800, i.e. five minutes to one week). Validation, the 400 answer and the audit entry tenant.protection_thresholds_changed are the same as for the deny-burst thresholds.
  • What counts. The approval_rejected records of that agent (plus its approval_expired records when protection_count_expiries is on), counted once per held action (per review id): a hold with several held calls, or a hold rejected and then recorded again by the resumed run, counts once. Approved and still-waiting holds are not counted. The deny-burst detector above does not count these records either; the two signals are independent.
  • Expired approvals do not count by default. protection_count_expiries on the tenant (a JSON boolean, default false) decides whether an approval that nobody decides within its deadline counts towards this pause. When it is false, only approvals someone actively rejects count. When it is true, an approval nobody decides in time counts too, so an agent whose requests go unanswered can pause, and holds that expire together can pause the agent in one expiry sweep. A tenant administrator (own organisation) or a platform administrator sets it with the tenant PATCH (see Updating a tenant). Any value other than true or false (including 0, 1, "true" and null) is refused with 400 { "code": "invalid_field", "field": "protection_count_expiries" } and nothing is changed. A change is audited as tenant.protection_thresholds_changed with the old and new value next to the thresholds; sending the stored value again writes and audits nothing. It applies from the next check (it is read from the tenant record, not a cache). If the stored value cannot be read, expired approvals are counted, which is the stricter choice, and a warning is logged. The setting changes only this pause count: an expired hold itself is still refused, its run still fails and its owner is still mailed, and the activity record still shows the hold as expired.
  • After a resume, only newer rejections count. As for the deny-burst signal, records from before the resume are not counted again.
  • When it runs. Outside the request, about 3 seconds after the rejection is recorded (rejections of one agent that arrive together are checked once). A rejection of a hold that belongs to an agent run is recorded, and so counted, when that run resumes; a rejection of a run-less proxy hold (a tool call held at the MCP proxy) is counted when it is rejected. The pause applies to the agent's next call.
  • Mail. The pause mail (see "Who is told, once per pause" above) says it in plain language in the recipient's language, e.g. "2 approvals rejected within 10 minutes" (German: "2 Freigaben innerhalb von 10 Minuten abgelehnt"; one approval reads "1 approval rejected"). It says "rejected or expired" ("abgelehnt oder abgelaufen") when expired approvals counted, and for a pause recorded before the setting existed. The window is written in the largest whole unit that fits (a 7-day window reads "168 hours"). Only whitelisted whole numbers are written into the sentence, never the stored evidence; evidence that cannot be read gives the generic "unusual activity" text. Below the sentence, What counted lists the counted held actions of the window, newest first: date and time (UTC; a window can span several days), outcome (Rejected or Expired) and who decided. A person is shown by display name, a deleted account as "former member", an expiry as "nobody decided", and a platform operator by the staff label. At most 10 rows are shown, then "and N more". A settings line follows, for example "Settings: 5 within 1 hour · expired approvals not counted · warning sent at 9 Nov 2026, 10:39 UTC.". Names are escaped in the HTML part. The chat DM keeps its short text.
  • Fail safe. If the check cannot run (for example the database cannot be read) it does not pause and does not resume any agent: it logs an error and raises a platform alert. Remaining hole: a hard kill or crash of the gateway inside that few-second window loses that check; the agent's next rejection within the window counts all of them again. An expired hold whose expiry record was lost (see the expiry gap in Access decisions) is not counted.

Early warning before a repeated-rejection pause

Before the repeated-rejection signal pauses an agent, its owner is warned once. The warning threshold is W = max(1, min(N − 1, ceil(0.8 × N))), where N is protection_rejection_count: N=2 warns at 1, N=5 at 4, N=10 at 8 and N=100 at 80. When a check finds W or more counted held actions but fewer than N, and the agent is not paused (neither by automatic protection nor by an unconfirmed hand-over), the owner is warned.

  • Once per window. The warning is sent at most once per agent per window (protection_rejection_window_s). A further rejection below N in the same window sends nothing. A new warning is possible once the window has passed since the last one, or after the agent was resumed (a resume starts a new window). Two checks that run at the same time send one warning.
  • Owner only. The agent's live owner gets the warning; administrators and KI managers do not (the pause mail stays their notice). An owner whose account is deleted or disabled gets nothing.
  • Channels.
    • Mail (template agent-protection-warning), in the owner's language. Example subject: "CRM sync" is close to being paused automatically. Example body: "4 of 5 approvals of your agent "CRM sync" were rejected within 1 hour. At 5 the agent pauses automatically and runs nothing until it is resumed." It says "rejected or expired" when the organisation counts expired approvals, and links to the agent page.
    • Direct message in each chat workspace the owner is connected to (Slack, Mattermost), for example "4 of 5 approvals rejected within 1 hour. At 5 it pauses automatically." with a link to the agent page.
    • In-app: GET /admin/auth/me and GET /admin/v1/me/notifications carry protection_warnings, a live list of the caller's own warned agents: [{ "agent_id", "gateway_id", "name", "count", "threshold", "window_s", "count_expiries", "warned_at_ms" }]. An item disappears when the agent is paused (the pause has its own notices), when it is resumed, or when the window has passed since warned_at_ms. The list is [] while an operator views the workspace as the user.
  • Numbers only. Only whitelisted whole numbers and the window, in the largest whole unit, reach the text. A warning whose stored numbers cannot be read is not listed in-app, and its mail falls back to a generic sentence without numbers.
  • Best-effort. A failure to send the warning never blocks counting or the pause. It is logged with ids only. A stored warning time that cannot be read counts as "no warning" (a warning is logged); it never turns off any of the automatic pause signals.
  • The deny-burst and volume-spike signals send no warning: a flood crosses from 80 % to 100 % within seconds, so the warning would arrive together with the pause mail.

Automatic volume-spike detection

An unattended run (one request, no person in the loop) that makes far more connector tool calls than the same agent normally does is paused automatically, with the same pause described above. Calls are counted per run and per class group: read calls, and write calls (write and destructive together). Only allowed, non-interactive calls of an agent actor count, and only connector tool calls that carry a tool class (read / write / destructive).

  • Baseline. The agent's own previous runs of the last 30 days, excluding the current run and any run that may still be in flight (the last two hours). With fewer than 10 completed runs there is no baseline (cold start) and the agent is never paused by this signal.
  • Threshold. The run is paused when its count in a group reaches max(base, longest earlier run in that group + 1), where base is the tenant factor F if the agent averages less than one call per run in that group, else F times the per-run average, rounded up. The lowest possible threshold is 2.
  • Factor. protection_volume_factor on the tenant, a whole number from 2 to 100, default 10 (see Updating a tenant). A change applies to each agent within 15 minutes (the per-agent baseline, including the factor, is cached for 900 seconds).
  • Evidence. GET .../protection returns { "signal": "volume_spike", "class": "read" | "write", "count", "threshold", "factor", "runs", "baseline_per_run_x100", "max_per_run", "last_decision_id" } (last_decision_id when known). baseline_per_run_x100 is the per-run average times 100.
  • Mail. The pause mail (see "Who is told, once per pause" above) says it in plain language in the recipient's language, e.g. "240 read calls in one run (usually about 12 per run)"; the usual figure is rounded to the nearest whole number; a baseline under half a call per run reads "fewer than 1 per run", none at all "usually none".
  • When it runs. Outside the request, after the call is recorded; the pause is confirmed by a fresh recount of that run before it is written. If the detector cannot run it does not pause. Once a run's count reaches the threshold it is re-checked every max(5, threshold / 10, rounded up) calls (the first check is at the threshold itself); a check that fails (for example a database error) simply happens again at the next such call, so a failing database never causes more than one check per that many calls. When the very first baseline is being computed, only the run that triggered the computation is re-checked afterwards: another run of the same agent that crossed the threshold in that short window and then stopped calling is not confirmed (accepted; a run that keeps calling is).
  • Resume starts a new run. After a resume the calls of the run that was already counted do not pause the agent again; the next invocation is a new run with a new count.

Foreign-caller chat-bridge turns never trigger an automatic pause

A chat-bridge turn run for a foreign caller (a person whose rights do not cover the connection's egress, see Who approves a foreign-caller turn) and the sub-agents it delegates to never count towards the deny-burst, volume-spike or repeated-rejection signals above: their refusals, calls and rejected or expired holds are left out of the counts, so one outside caller cannot pause the agent for everyone. The turn is still checked, audited and refused as usual. The first-destination notice still fires (it only informs). There is no per-caller pause. A turn whose foreign-caller marker is missing or unreadable is counted as before.

Inspect and resume a protection-paused agent

GET /admin/v1/gateways/{gw}/agents/{id}/protection returns { agent_id, protection_paused, protection_paused_at, evidence }. protection_paused_at and evidence are null when the agent is not paused (and evidence is also null if the stored record cannot be read). The evidence is exposed only here, never in the agent payload.

For a repeated-rejection pause whose evidence carries count_expiries, the answer also has:

  • settings: { "threshold", "window_s", "count_expiries" }, the values that applied when the agent was paused (taken from the evidence, not from today's tenant settings);
  • events: the held actions of the window that ends at the pause, newest first, at most 20:

    [{ "ts_ms": 1794220985000, "outcome": "rejected", "review_id": "…", "tool": "crm.update_contact",
       "decided_by": { "display_name": "Lena Hoffmann" }, "counted": true, "wait_s": null },
     { "ts_ms": 1794220560000, "outcome": "expired", "review_id": "…", "tool": "mail.send",
       "decided_by": null, "counted": false, "wait_s": 300 }]
    

    The window is [paused_at − window_s, paused_at], and it starts no earlier than the previous resume. There is one row per held action (review id). Expired holds are listed even when they did not count (counted: false), so the owner can see why the count is lower than the activity record suggests. outcome is rejected or expired. tool is the recorded connector tool name, or null. decided_by is null for an expiry. wait_s is how long the expired approval waited for a decision, in seconds (its deadline minus the time it was requested, 1 second to 31 days). When a workflow run ends while its approval is still open, the deadline is moved to that moment, so the wait shown is the shorter time the approval actually stayed open. The console shows it in the largest whole unit, for example "— nobody decided (5 min wait)". wait_s is null for a rejection, and also when the approval record is gone or its times are not usable (the console then shows "— nobody decided" without a wait). A deleted account has display_name: null, which the console shows as "former member". For a caller who is not a platform administrator, a platform operator is shown by the staff label, never by name. Held actions of foreign-caller chat-bridge turns are left out, exactly as in the count. If the records cannot be read, the answer is an error, never an empty list. If the stored time of the previous resume cannot be read, events is left out (settings stay), so rows from before that resume are never listed.

Older evidence and the other signals return neither key. The audience is the same as for the rest of the answer: anyone else gets 404. The people who see these rows already see the same approvers on the approvals page.

POST /admin/v1/gateways/{gw}/agents/{id}/protection/resume with body { "note": "<why it is safe>" } lifts the pause and answers 200 { "ok": true }.

  • Who may call: the agent's owner, a workspace or platform administrator, or a same-tenant user holding the agents-review permission who can see the agent (own, shared with them or their group, or in the org catalog; MAP-3530). An agent the reviewer cannot see answers exactly like a missing id, and a resume on it changes nothing and writes no audit entry. Both routes need the agents-author role and access to the gateway, and work even while Agents are switched off for the tenant.
  • A caller who may not act on the agent gets 404 agent_not_found, exactly as for an agent that does not exist, so the routes reveal nothing about other users' agents. This is deliberately 404 where other agent routes answer 403 for a visible but forbidden agent. A viewer or demo user gets 403. If the permission store cannot be read the answer is 503, never a guess.
  • The note is required: a non-empty string of at most 1000 characters and 4000 bytes, valid UTF-8, without control characters other than tab and line break (line breaks may be LF or CRLF; CRLF is stored as LF, and a lone CR inside the text is rejected; CRs at the very edges are trimmed with the whitespace) and without characters from the gateway's shared invisible-formatting set (zero-width, bidi controls, tag characters, byte-order mark and similar). A variation selector (as in ❤️) is accepted only directly after a base of its own kind, one per base; every other default-ignorable character, and every misplaced or repeated variation selector (including one that follows a tab, a line break or a space), is refused. A note that is whitespace-only or invisible-only (for example only no-break spaces, ideographic spaces, fillers or variation selectors) counts as missing, and so does a note made only of Braille blank (U+2800). Joined emoji (zero-width joiner sequences) are refused as invisible formatting. Leading and trailing whitespace is trimmed, and the stored note is the trimmed one; the overall size limit on the submitted value (5024 bytes) is measured before trimming, so a note padded with more than that is rejected even if the trimmed text is short; the body may carry no other key, and a JSON object that repeats the note key is refused with 400 duplicate_key and nothing is written. A bad or missing note is 400 invalid_request. The note is checked only after the caller is authorised.
  • An agent that is not protection-paused answers 409 agent_not_protection_paused; two concurrent resumes produce exactly one success.
  • Enabled schedules of the agent that are not currently claimed are re-armed with the same logic as a hand-over confirm: an interval schedule fires promptly, a daily or weekly one waits for its next occurrence. Occurrences missed during the pause are not replayed. A pause that comes from an unconfirmed hand-over is separate and stays in force.
  • The resume is audited as agent.protection_resumed (acting user, the pause time and evidence it lifted, and the note). If the audit record cannot be written the resume does not happen.

First use of a connector in an unattended run

When an agent that runs unattended (a schedule, a webhook trigger, a delegated run or an API-token call; not a person driving it in the playground) uses an MCP connector for the first time, the gateway informs the people responsible. It does not pause the agent: this is a notice, never a block.

  • What counts as first use. The agent's earliest allow access decision for that connector in the retained decision record. A call that was held for approval and then approved counts as an unattended use. Refused calls do not count. A person-driven (interactive) call is never a first use.
  • Once per agent and connector. The first use writes one audit row agent.first_destination (actor system, entity the agent) whose after carries { "signal": "first_destination", "connector_id": "<connector>", "decision_id": <id of the allow decision> }, and sends one e-mail per recipient (template agent-first-destination; subject "An agent used a connector for the first time"). Recipients are the agent's owner plus the tenant's active administrators and KI managers, de-duplicated by address, in the recipient's language. Further calls of the same agent on the same connector add nothing; a different connector or a different agent is a new first use.
  • Best-effort. The notice is sent right after the decision is recorded, outside the request. A mail that fails is not retried and is lost; the audit row and the answer to the call are unaffected. If the check itself cannot run, it logs an error and raises a platform alert (at most one per ten minutes) and never pauses the agent.
  • Retention. "First" is judged on the retained access decisions. When all earlier allow decisions of that agent for that connector have been purged by retention, the next unattended use counts as a first use again and is announced again.
  • Scope. This covers connectors only; other destinations are not yet covered.

An agent's versioned tool_config is the owner's consent: mcp lists the consented connector ids and mcp_allow[cid] optionally narrows one connector to a tool list. mcp is always an array of connector ids; with no consented connector it is [], which is also what the gateway's unverified-clients agent stores while the workspace has no shared connectors. An empty object ({}) in mcp, as older versions of that agent stored, is read as the same empty list. Any other value that is not an array (a non-empty object, a string, a number) is malformed: it grants nothing and the console shows the consent as unreadable. The check is per element: mcp must be an array of non-empty connector id strings, and a single bad element (a number, true, null, "", a nested array) makes the whole consent malformed, so one bad id never leaves the other ids granted. mcp_allow[cid] must be an array of non-empty tool names; any other value, or a bad element in it, makes that one connector grant no tool (fail-closed, not malformed). An mcp_allow entry for a connector that is not in mcp is inert. Create and PATCH refuse a bad mcp element, an "" tool name or a non-array mcp_allow entry with 400 and { "error": "<message>", "code": "invalid_request" } (the exact messages are in the input table); only the preview answers 400 invalid_tool_config for a bad mcp id. What a run may actually use is the effective contract: the owner's consent intersected with the connector's admin tool_policy cap. These routes show and shrink it. They need the agents-author role and the agents gateway.

GET /admin/v1/gateways/{gw}/agents/{id}/contract returns { agent_id, version, consent_valid, connectors }. Each connector entry has connector_id, grant (all for the whole connector, tools for a narrowed list), tools (one { tool, verdict, reason, class } row per consented tool, and per tool the admin cap names, including a tool named only by a reason under default: "block"; class is the tool's class (read, write, destructive) when an admin or the catalog set one, else null, and is returned by this route and the preview below; reason is the admin's text only when it passes the reason rule (1-300 bytes, valid UTF-8, no control characters), else null; verdict is allowed, capped (blocked by the admin cap, with the admin's reason when one was set) or not_granted), other_tools (the verdict for every tool not listed), cap and available. When available is false (the connector was deleted, so nothing can be called through it) the entry has tools: [] and other_tools: "not_granted", never allowed. A malformed stored consent gives consent_valid: false and no connectors, because it grants nothing. An unknown or invisible agent is 404.

GET /admin/v1/gateways/{gw}/agents/{id}/blocked-tools returns the tools the organisation blocks for the agent to everyone who can see the agent: its owner, administrators, and users it is shared with (directly, through a group or the organisation catalog). Unlike the contract it needs no agents-author role. The answer is { agent_id, tools, others_blocked }. Each entry of tools is exactly { tool, class, reason } for a tool with the verdict capped on a connector the agent is bound to that still exists in the agent's tenant. class and reason follow the contract's rules (null when unclassified, or when the reason is absent or fails the reason rule). A tool blocked the same way on two bound connectors is listed once; blocked with different reasons, it is listed once per reason. others_blocked is true when such a connector also blocks tools it does not name (its cap is default: "block" over a grant of all its tools, or the stored cap is unreadable, which blocks every call), so a cap that blocks everything else never reads like one that blocks nothing. The answer carries no connector id or name, grant, cap or allowed tool. A malformed stored consent grants nothing and gives tools: [] and others_blocked: false. An unknown agent, an agent the caller cannot see, or an agent of another tenant is 404 agent_not_found; the Agents feature switched off is 403 feature_disabled; a storage fault is 503 (never an empty list).

POST /admin/v1/gateways/{gw}/agents/contract/search previews the contract of a proposed { "tool_config": { … } } (optionally with agent_id to resolve connectors as that agent's owner) without storing anything. A missing or null tool_config is 400 tool_config_required; a malformed one is 400 invalid_tool_config; a connector that does not exist or is not available to the owner is 400 unknown_connector. The preview does not validate tool_config.task_envelope; create, update and draft preview reject a malformed or non-consented one.

DELETE /admin/v1/gateways/{gw}/agents/{id}/consents/{cid} revokes one connector. The agent's owner or a workspace administrator may call it; the body must be absent or {}. It removes cid from mcp and mcp_allow and appends a new agent version (the old one stays in the history and can be restored). Success is 200 { agent_id, connector_id, version, revoked: true } and the change applies to the agent's next tool call, including a run that is already in progress. A connector the agent has not consented to is 404 consent_not_found and writes nothing, so a repeated revoke is safe. Errors: 400 invalid_connector_id, 403 consent_revoke_forbidden, 409 concurrent_update, 422 consent_malformed (a malformed consent cannot be revoked per connector; repair it with a full PATCH). The change is audited as agent.consent_revoked.

When the platform introduced per-tool approval for connector tools, it froze a snapshot of every agent that already existed at that moment: the agent's tool_config exactly as stored, copied once and never updated. The snapshot decides which tool calls an existing agent is exempt from the new approval requirement.

  • What is exempt. A tool call is exempt only if the frozen consent would have allowed it: the connector was consented (mcp) and the tool was either allow-listed in mcp_allow[cid] or the connector was consented as a whole. The same parsing rules as for live enforcement apply, so a malformed snapshot exempts nothing, a tool name is compared byte for byte (Send_Mail is not send_mail) and * is just a tool name.
  • A whole-connector consent also covers tools added later. If the snapshot consented to a connector without narrowing it to a tool list, every tool that connector exposes, including tools it adds afterwards, is exempt. To stop that, narrow the connector with mcp_allow or revoke it; a later change does not alter the snapshot, so it can never extend the exemption, and it does not remove an exemption already granted by the snapshot for a still-consented tool either. Revoking the connector ends the use of it altogether.
  • Not exempt. An agent created after the upgrade has no snapshot and is not exempt. Tools that a narrowed connector (mcp_allow) did not list at snapshot time are not exempt, and neither are connectors consented after the snapshot.
  • Fixed. Editing, restoring or cloning an agent never rewrites its snapshot. The snapshot is part of the tenant export (agent_consent_snapshots) and is erased with the agent.

A refused built-in tool stays refused for the reply

When a built-in tool (for example web_search, fetch_url, agentic_fetch, generate_image, create_video, remove_background or code_interpreter) is refused by a policy that is fixed for the reply, the agent run withdraws the tool for the rest of the reply: the model is no longer offered it (unless it is the only tool offered; then the run ends with one final answer written without tools, see tools_exhausted in Inference) and a repeat call is refused without running (it is still recorded as a deny access decision). The fixed refusals are an agent constraint that blocks the tool (reason agent_constraint, also a malformed constraint, agent_constraint_malformed), a block level of the agent's tool permission policy tightening (reason agent_tool_policy, also a malformed tightening; not when the policy could not be read), a chat turn that cannot confirm or approve the call (a confirm or approval level with no card or approval possible there: reason interactive_confirm or interactive_approval, rule id tool_policy:interactive:<level>:<tool>), a built-in tool the agent's capability token does not list (reason agent_capability), and the egress blocks: the project block (reason egress_blocked, rule id project_policy:no_egress) and the local-only floor of the tool policy (reason egress_blocked, rule id tool_policy:floor:<tool>). A call held for approval, a confirmation the chat asks for with a card, and a refusal that depends on the call's arguments are not withdrawn, so a later call with different arguments is judged on its own. The run then ends with the model's answer rather than a repeated_tool_call stop. A scheduled prompt task is recorded with no agent id on its access decisions (its actor is the gateway), so these decisions stay stored.

Tool permission policy (tool_config.tool_policy)

The connector's tool permission policy sets a level per tool for the interactive column (chat, Try it) and the unattended column (runs, API tokens, chat-bridge turns, the MCP proxy). An agent may only tighten it, with tool_config.tool_policy:

{
  "connectors": {
    "<connector id>": {
      "classes": { "write": { "unattended": "approval_2" } },
      "tools":   { "add_note": { "interactive": "confirm" } }
    }
  },
  "builtins": { "fetch_url": { "unattended": "approval_1" } },
  "once_per_run": ["write"]
}
  • Accepted shape (400 invalid_tool_policy otherwise, on create and PATCH, and again when a change held for config approval is applied). Only the keys connectors, builtins, once_per_run and sources (see Source policy below). A connectors key must be a connector of the same tool_config.mcp; each entry has classes (read, write, destructive) and/or tools (at most 500, the connector tool-name rule). builtins names gateway tools (at most 32 names of at most 64 bytes; a name that is no gateway tool never matches). Each cell sets interactive and/or unattended with the connector levels (allow / confirm / approval / block; allow / approval_1 / approval_2 / block); an empty cell, an unknown level or a level of the other column is refused. once_per_run is an array of at most 64 tool or class names.
  • Only stricter (400 tool_policy_loosens). Each cell is compared with the organisation's current level: the connector's class line for a classes cell, the tool's level (by its class) for a tools cell, allow for a builtin (block for fetch_url, agentic_fetch and web_search when one of the agent's areas is local-only). A looser value is refused with { "code": "tool_policy_loosens", "error": "…tool 'add_note' of connector <id> interactive 'allow' is looser than the organisation allows ('confirm')", "field": "tool_config.tool_policy.connectors.<id>.tools.add_note.interactive" }. A cell equal to the value already stored on the agent is not re-checked, so an unrelated save after the organisation tightened the connector does not fail; at run time the stricter value wins and the contract reports the agent's value as stale_override: true. A restore re-checks the version's policy against today's organisation policy. A failed connector read is a 503.
  • once_per_run. An unattended approval_1 is lifted for the rest of the run after its first approval. Every entry must name a tool or class whose effective unattended level is approval_1 (for a bound connector, or a builtin) → else 400 invalid_tool_policy_once_per_run; an entry already stored on the agent is not re-checked. It never lifts an approval the organisation requires (approval_required).
  • Enforcement. The tool gate takes every level from this effective policy: the connector's policy, the class, the agent's tightening and its legacy fields, the legacy consent exemption and the automatic rules. Kept outside it, unchanged: the task envelope (outside_task), untrusted content holds and parameter rules.
    • Unattended column (scheduled, triggered and webhook runs, API-token invokes, delegated sub-agents, chat-bridge turns and the MCP proxy). block refuses the call: reason tool_policy when the organisation blocks it; for an agent block, agent_constraint or agent_constraint_malformed (a legacy constraint) or agent_tool_policy (the agent's tightening, also when it cannot be read). approval_1 and approval_2 hold the call as before, with the same hold reasons: approval_required, agent_constraint_write / agent_constraint_egress when the level comes from a migrated constraint, and the owner's approval list. A hold needs two people (four-eyes, review_item.four_eyes_required = 1) when any held call's level is approval_2, set by the organisation or by the agent. It also needs two people when the gateway could not read a held call's policy (for example the connector could not be read when the hold opened), and when the MCP proxy could not determine the number of approvers: never fewer approvers on a fault. A connector without a version-2 policy keeps the legacy connector-wide flag (PATCH /mcp/{id}/four-eyes), which applies to every hold on that connector. once_per_run lifts an approval_1 after the run's first approved hold of the same kind; a migrated ask_once_per_run behaves exactly as before. Untrusted input also holds a write that the organisation lets run unattended (allow).
    • Interactive column (chat with connectors, Try it). block refuses the call. confirm stops the turn before the call and shows the user a confirmation card (reason confirm_requested); the call runs only after the user's Run (confirm_run), and "Allow for this conversation" lets later calls of the tool run without a card (confirm_allowed_for_conversation) — see Chat tool confirmation. Where no card can be shown (a private chat, a plain API call without the chat's turn id) a confirm call is refused with reason interactive_confirm. approval (Approval by someone else) in a chat with connectors opens an approval request for the policy's interactive approvers (never the asker) and the call waits (reason chat_approval_awaiting, hold_reason: "chat_approval"); the user keeps chatting, and an approved call runs as the asker — see Approval by someone else. In an agent's Try it, a chat with an agent or a private chat an approval call is refused with reason interactive_approval; nothing runs, and the model is told why. When the conversation contains untrusted content, a write, delete or outbound tool whose interactive level is allow asks first (confirm, source automatic).
    • Built-in tools. The agent's tightening of a gateway tool (builtins) is enforced at that tool's own check: block and the interim interactive approval refuse it; an interactive confirm shows the confirmation card like a connector call (Try it); an unattended approval holds it like a connector call, and a call that reaches its check without an approved hold is refused with reason approval_not_held.
    • Not covered. Only the organisation's block applies, as before, to a workflow Connector node, connector sync, an administrator's own test call from the connector page, and a plain API chat completion made without an agent and without the playground token.
  • Legacy fields (deprecated). The agent's constraints and tool_config.approval.tools keep working and are read as tightening too: write: never / egress: never → block in both columns; always_ask → unattended approval_1 and interactive block (a constraint hold in chat is refused today); ask_once_per_run → the same plus once_per_run; an unreadable list → block for every write / egress tool; approval.tools → unattended approval_1 where a run can be held (not the MCP proxy). The local-only floor raises an egress always_ask to block.
  • Deprecation headers. A POST …/agents or PATCH …/agents/{id} body that carries constraints or tool_config.approval.tools (any value, null and [] included) is answered with Deprecation: @1794268800 and Sunset: Mon, 01 Mar 2027 00:00:00 GMT (RFC 9745 and RFC 8594). This applies to every answer given after the body is read, refusals included. An answer given before the body is read, such as a 401 without a session, carries no deprecation headers. The fields will be removed after the sunset date; set the same tightening in tool_config.tool_policy instead. tool_config.tool_policy and tool_config.approval.ttl_seconds carry no deprecation headers.
  • Legacy consent. A write the agent's grandfathered consent covers runs unattended without the class-default approval: the contract shows it as source: "legacy_consent". It is the only per-agent exception, it can never be added (an agent allow below the organisation's approval is tool_policy_loosens), and the owner or an admin removes it by setting that tool or class to approval_1 (or stricter). Untrusted input still holds it, as before.
  • Who may change it. The same people who may edit the agent (PATCH); any other member gets the agent's 403 / 404. External agents may carry tool_policy too; the MCP proxy uses the unattended column. The change is part of the agent's version history like every tool_config field.

Source policy (tool_config.tool_policy.sources)

Each source the agent takes data from has a source policy: the connector's trust class, or the gateway's setting for a built-in source (web_search, web_pages, knowledge_files), raised by the organisation's minimum for every source. The agent may make its personal-data and keyword cells stricter, never looser, and never changes the trust class:

{ "sources": {
    "connectors": { "<connector id>": { "pii": { "delivery": "approval_1" } } },
    "builtins":   { "web_pages": { "pii": { "delivery": "approval_2" } } } } }
  • Accepted shape (400 invalid_tool_policy). Only connectors (keys = connectors of the same tool_config.mcp) and builtins (keys web_search, web_pages, knowledge_files); each entry has pii (input, result, delivery) and / or keywords (input, result) with the source levels (pii.input allow/mask/block, pii.result allow/mask, pii.delivery allow/internal_only/approval_1/approval_2/block, keywords.input allow/flag/block, keywords.result allow/flag/withhold). A trust key, an unknown level or key is refused.
  • Only stricter. A cell below the organisation's minimum → 400 { "code": "source_policy_below_floor", "field": "tool_config.tool_policy.sources.builtins.web_pages.pii.delivery", … }; a cell looser than the source's current level (its trust class or override, raised by the floor) → 400 tool_policy_loosens with the same field. approval_1 → approval_2 is a tightening, approval_2 → approval_1 loosens. A cell equal to the value already stored on the agent is not re-checked (the organisation may have tightened since); the stricter value wins at run time and the contract reports stale_override: true. A failed gateway or tenant read is a 503.
  • Enforced now: pii.delivery (the run's delivery disposition). The other cells are stored and shown and are enforced in a later release.

The effective policy in the contract. Both contract routes above add, per listed tool, policy:

{ "tool": "add_note", "verdict": "allowed", "reason": null, "class": "write",
  "policy": {
    "interactive": { "level": "confirm",    "source": "agent",        "reason": null, "stale_override": false },
    "unattended":  { "level": "approval_2", "source": "organisation", "reason": null, "stale_override": false,
                     "approvers_needed": 2, "once_per_run": false } } }

source is organisation (the connector's policy or the built-in default), agent (the agent's tightening or its legacy constraints), automatic (the local-only floor, the unverified MCP clients agent, untrusted content) or legacy_consent. approvers_needed is 1 / 2 for an unattended approval, else null; reason is the admin's block reason when the organisation blocks the tool in that column. Each connector entry also carries class_policy (read / write / destructive → the same { interactive, unattended } for a tool of that class the list does not name), and the response carries builtins: [{ "tool", "policy" }] for the builtins the agent enables (web_search; fetch_url and agentic_fetch with agentic_fetch) or names in its tightening or approval list. The values come from the same effective-policy function the gateway's tool gate enforces (see above); the unattended column shows the scheduled-run surface without untrusted content. verdict, capped and reason are unchanged.

The source policy in the contract. Each available connector entry also carries source_policy, and each entry of builtins that reads a built-in source (web_search; fetch_url and agentic_fetch → web_pages; search_knowledge and read_file → knowledge_files) carries source_group and source_policy:

"source_policy": {
  "trust":    { "level": "internal", "source": "organisation" },
  "pii":      { "input":    { "level": "allow",      "source": "organisation", "stale_override": false },
                "result":   { "level": "mask",       "source": "tenant_floor", "stale_override": false },
                "delivery": { "level": "approval_1", "source": "agent",        "stale_override": false } },
  "keywords": { "input":    { "level": "flag",       "source": "gateway",      "stale_override": false },
                "result":   { "level": "flag",       "source": "gateway",      "stale_override": false } } }

Each personal-data and keyword cell also carries org_level: the organisation's level of that cell (the source's class or override, raised by the minimum for every source, without this agent's tightening). It is the bound the agent's own value may not go below (400 tool_policy_loosens / source_policy_below_floor); the agent page disables the looser options against it. A cell's source is platform (the trust-class table, nothing configured), legacy (a connector whose policy predates the source policy: read as external), organisation (the connector's own setting, or its trusted-subprocessor flag for pii.input), gateway (the gateway's built-in source setting, or its keyword detectors for a keyword cell), tenant_floor, agent or automatic (a document that could not be read: the strictest class). The response (GET …/agents/{id}/contract, and the draft contract) also carries:

  • sources: [{ "kind": "connector" | "builtin", "id", "name", "source_policy" }] — every available connector and the gateway's three built-in source groups;
  • delivery: the delivery summary input, { "applies_to": "external", "level": "<strictest>", "sources": [{ "kind", "id", "name", "level", "source" }], "channels": [{ "kind", "label", "external" }] } — per source the pii.delivery level that applies to external channels (internal delivery is never limited), and the strictest of them. The UI never computes a level; it reads these.
  • delivery.channels: the agent's configured delivery channels, computed by the server from the stored output_action of the agent's schedules on this gateway, one entry per distinct channel in schedule order, then the owner's e-mail:

    kind label external
    mattermost Mattermost <channel id> true, or false when the organisation classed Mattermost internal (delivery channel class)
    webhook the URL's host only (never its path, query or credentials) true, or false when the organisation classed webhooks internal
    email the address false only when the address belongs to an active user of the same tenant (or the organisation classed e-mail internal) and the tenant allows internal delivery of personal-data results; any doubt or read fault is true
    owner_email the agent owner's address (also a schedule that mails the owner's own address) false

    A schedule whose output_action cannot be decoded, is not an object, has an unknown kind, or carries an invalid channel id, URL or address is skipped (it delivers nothing, so it is no channel); kind: "none" is no channel. channels is [] for a draft contract without agent_id. A failed schedule or owner read answers 503, never an empty list.

Member view (GET /admin/v1/gateways/{gw}/agents/{id}/tool-policy). Every user who can see the agent (the owner, administrators, and users it is shared with) reads the agent's effective tool permissions here: { agent_id, version, consent_valid, connectors: [{ name, all_tools, tools: [{ tool, class, policy }], class_policy, source_policy }], builtins }. Each connector entry carries the connector's source_policy (same shape as above, including org_level), and builtins carries source_group / source_policy as in the contract. The view has no connector id, grant, cap, verdict, sources or delivery. A hidden, unknown or foreign-tenant agent is 404; a read fault is 503.

Version history & restore

Every create/edit snapshots the agent's full config into an append-only agent_version history (agent.version is a monotonic counter). These endpoints browse that history and restore an old version. All three are owner or tenant_admin/admin only — a non-owned / cross-tenant / missing agent id → 404 (no existence leak), same gate as the other agent routes. The publish model is always-latest: the org catalog keeps cloning the agent's current live config, so history is read-only and restore is non-destructive (there is no pinned "published" version).

A run records which agent_version produced it, so run-detail can reconstruct the exact config afterwards. Because invoke resolves the agent live (always latest), the version is stamped from the value the invoke actually ran — every agent invoke returns an X-AIG-Agent-Version response header, and the scheduler writes it onto the run at completion. This closes a window where a scheduled run pinned the version at poll time but a newer edit ran at invoke time, which would have made run-detail show a config that never ran. When the header is absent (an older gateway), the run keeps its poll-time snapshot.

GET /admin/v1/gateways/{gw}/agents/{id}/versions — the history, newest first (bounded to the most recent 200). Each entry: id, version, name, model, provider, created_by, created_at, purpose, purpose_status. Empty history encodes as [].

GET /admin/v1/gateways/{gw}/agents/{id}/versions/{version} — one version's full, decoded config. version must be a positive integer written canonically: decimal digits only, no leading zero, sign, whitespace, exponent, hex or fraction; at most 10 digits; 1..2147483647; anything else (01, 0x1, 1e0, +1, 1.0, padded or non-numeric, 0, negative, inf, over-range) → 400 { "error": "invalid version", "code": "invalid_field", "field": "version" }. A syntactically-valid but non-existent version → 404 { "error": "version not found", "code": "version_not_found" } (distinct from the retry 503 on a storage error).

POST /admin/v1/gateways/{gw}/agents/{id}/versions/{version}/restore — restore the chosen version. Not a mutation of history: it re-applies that version's config through the normal update path, bumping the agent to a new version whose body equals the old one (auditable, agent.version_restored). The request body is ignored — the config comes entirely from the stored snapshot keyed by the validated version. Blocked for viewer/demouser (403). The restored knowledge-area set is re-validated against the owner's current access, with one exception: an area the agent already asserts is carried through unvalidated, including one that was deleted or purged since — that is what keeps such an agent fail-closed instead of making its whole version history unrestorable. Only an id the agent does not currently assert is access-checked, and a failure there is a 400. An explicit empty snapshot ([]) clears the areas, while a pre-history (NULL-snapshot) version leaves the current area binding untouched. The tool_config (incl. MCP connector ids) is restored verbatim — faithful to the old config, no re-resolution. A tool_config.mcp connector that was deleted since the snapshot is not FK-backed: it is simply skipped at invoke (fail-closed) and pruned on the next edit, exactly as for any live agent whose connector was later removed — so it needs no restore-time re-validation.

The provider pin is re-validated for runnability (mirroring the edit path): restoring a historical pin whose provider is no longer configured or no longer serves the model on this gateway would otherwise land a silently non-invokable agent (the next invoke 502s as AGENT_MISCONFIGURED). If the historical pin is still runnable it is kept; if it is genuinely not runnable here it is cleared (the agent infers its provider at invoke, self-healing) and the response carries provider_reset: true so the UI can warn; a transient verification failure (a DB read error) fails the restore closed (the retry 503) rather than silently unpinning a valid agent. A version that was historically unpinned stays unpinned. source_metadata (import provenance, not run config) is not versioned, so restore leaves the current value. purpose and purpose_status are versioned, so restore re-applies the chosen version's pair; a pre-history version (purpose / purpose_status are null) leaves the agent's current purpose and status untouched. Restoring the current version is allowed and is a harmless no-op-content bump to a new version.

The restored pin is also run through the model pin offer validation: if the gateway's residency/allowlist has tightened since the version was saved (or the pin was never offerable), restoring an old US-only model onto a now-EU-enforced gateway is refused with 400 (data_residency_blocked / provider_not_allowed) rather than restored into an agent that then 403s every run.

Setting sharing

PUT /admin/v1/gateways/{gw}/agents/{id}/sharing

Atomically replaces the agent's sharing state. Owner (or admin/tenant_admin) only. Body:

visibility Extra body Gate
private — owner
users user_ids[] (≤200, each same-tenant) owner — member self-service
group group_ids[] (≤200, each same-tenant) AGENTS_REVIEW permission (ki_manager) + owner
org — AGENTS_REVIEW permission (ki_manager) + owner + tenant org_share_enabled=1 (else 403 org_share_disabled). On a tenant that requires review, an agent that is not approved → 403 agent_not_approved

Any other visibility → 400 visibility must be private|users|group|org. For users / group the list is required: absent (or not a list) → 400 user_ids is required / group_ids is required; more than 200 entries → 400 too many users (max 200) / too many groups (max 200). Every user_ids/group_ids entry must be an id string (non-blank, at most 64 bytes) — a number, object, null, empty or whitespace-only string → 400 (user_ids entries must be id strings / group_ids entries must be id strings); the field itself must be a JSON array ([] clears the list; an object → 400 user_ids must be an array / group_ids must be an array). A repeated id is shared once. A user_ids/group_ids entry that is unknown, belongs to another workspace, is a deleted user or is only a spelling variant of a real id (different case, trailing space, invisible or full-width characters; ids are matched byte-exact, so ["<id>", "<ID>"] is refused too) gets one answer, 404 { "error": "user not found", "code": "user_not_found" } / 404 { "error": "group not found", "code": "group_not_found" }, so the response does not reveal whether the id exists elsewhere. Each such request is recorded as one access.denied security event (status 404, no entity, the route path; the ids in the body are not stored), whoever the caller is, platform admins included. A malformed entry stays 400 and a storage fault stays 503; neither is recorded. See group and role ids. Nothing is written when any entry is refused, and the stored id is what is saved and audited. Success is 200 { "ok": true }. Audited (agent.sharing_changed, before/after subjects). The current state is read via GET …/agents/{id}/shares (owner/admin only), which returns { "org_shared": <boolean>, "users": [ … ], "groups": [ … ] }.

The replace is one transaction. A transient conflict that wrote nothing → 503 { "error": "temporarily unavailable; retry later" } (send the same PUT again); the agent deleted in the meantime → 404; a selected group deleted between validation and the write → 409 { "error": "a selected user or group no longer exists; reload and try again", "code": "share_target_gone" } (nothing changed — reload the subjects and send the PUT again); a selected user who was deleted, or who is not in the agent's workspace, by the time the write runs → the same 404 { "error": "user not found", "code": "user_not_found" } (and the same access.denied event) as the up-front check, because the check is repeated inside the write transaction against the user's current state (nothing changed). A caller without a workspace is never treated as being in the same workspace as anyone, so an agent or user without a workspace id can neither share to nor be shared to; any other database fault → 500 { "error": "internal error", "request_id": "<id>" }.

Org agent catalog

GET /admin/v1/tenants/{id}/agent-catalog

Tenant-wide list of org-shared agents (redacted), gated on require_tenant_access and the tenant org_share_enabled (read at query time, so disabling the capability empties the catalog). demouser is excluded (403 { "error": "forbidden" }). Reuse a catalog agent by cloning it (a fresh create validated as the cloner — the owner's private connector/project bindings are stripped/rejected, never copied).

Curation. Each row carries its curation metadata: category (a free-text section tag, or null) and featured (0|1). The list is ordered featured-first, then newest-first within each band — so pinned agents surface at the top (the catalog "featured section"). The admin UI renders a Featured badge, a per-row category chip, and a category filter over the returned page.

Rating signal. Each row also carries the community rating: rating_avg (mean of all 1–5 ratings, rounded to 1 dp, 0 when unrated), rating_count, the caller's own my_rating (1..5, or null), and can_rate (server-decided — false for the caller's own agent). These are computed with two grouped queries over the whole tenant page (no N+1); my_rating/can_rate make the response per-caller. The same four fields also appear on the shared (non-owner) Read an agent response.

Curate a catalog agent

PATCH /admin/v1/gateways/{gw}/agents/{id}/curation

Sets the org-catalog presentation of an agent. tenant_admin/admin only — an ordinary owner must not self-feature their agent, so this is admin-gated even though the owner can otherwise edit the agent (403 curation requires tenant_admin otherwise). It is a separate endpoint from the generic agent PATCH because curation is presentation, not run-affecting config: it does not bump agent.version or write an agent_version snapshot.

Field Shape Notes
category string | null Section tag, max 64 bytes. null clears it (uncategorized). Absent = left unchanged.
featured boolean true pins the agent to the top of the catalog. Absent (or null) = left unchanged.

Rejected input (each → 400): a non-string category (category must be a string), a category over 64 bytes (category too long (max 64 bytes)), a non-boolean featured (featured must be a boolean), or a body with neither field — a featured: null alone counts as neither (no curation fields (category, featured) provided). The permission check comes first: a caller without the curation permission gets the 403 before the body is validated. Featuring a non-org-shared agent is accepted but inert (it only surfaces once the agent is org-shared). Success is 200 with the updated agent. Audited (agent.curated, before/after).

In the admin UI this endpoint backs the Agent catalog, opened from the Agents page via its Agent catalog button — the page /agents/catalog with a searchable list of the org-shared agents and a per-row Clone action. The button is hidden when the tenant's org_share_enabled is off. Cloning targets the source agent's own gateway, so its pinned (provider, model) stays runnable; the clone becomes the caller's own editable agent with the owner's connectors/knowledge omitted (rebind your own after cloning).

Rate a catalog agent

PUT /admin/v1/gateways/{gw}/agents/{id}/rating — body { "rating": 1..5 } DELETE /admin/v1/gateways/{gw}/agents/{id}/rating — retract the caller's rating

A rating is the caller's own feedback (like conversation feedback), not agent config, so these use the catalog's visibility gate — require_gateway_access (tenant membership) plus a demouser block — not the author gate, so a viewer who can see the catalog can also rate. You may rate any agent you can see (org-shared / shared-to-you) except your own.

There is exactly one rating per (agent, user): the write is an upsert, so re-rating updates in place and can never inflate rating_count. Both routes return the fresh aggregate: { rating_avg, rating_count, my_rating } (my_rating is null after a DELETE).

Rejected input:

Condition Status
rating missing / null / not a JSON number / not a whole number / outside 1..5 (e.g. 0, 6, 3.5, "4") 400 (fail closed — not tonumber-coerced): rating is required, rating must be a number, rating must be a whole number or rating must be between 1 and 5
agent not visible to the caller (private, not shared, or another tenant) 404
the caller is the agent's owner (created_by) — anti-inflation self-rate 403 cannot rate your own agent
demouser 403
unauthenticated 401

Backing table agent_rating (migration 0133): PRIMARY KEY (agent_id, user_id) enforces the one-per-user rule; agent_id CASCADEs on agent hard-delete. In the admin UI the Agent catalog page renders each row's aggregate plus a 1–5 star picker (shown only when can_rate).

Per-agent stats

GET /admin/v1/gateways/{gw}/agents/{id}/stats?period=1d|7d|30d

Run count, spend and duration percentiles for one agent over a period, next to the same figures for the period of equal length right before it.

  • period is optional: 1d, 7d or 30d; absent means 7d. Anything else (empty period=, a bare ?period, a repeated parameter, 7D, 90d, ...) answers 400 invalid_period. The period is checked after the permission check, so a caller who may not see the agent gets the 404 whatever the parameter says. Audience: the owner, an admin / tenant_admin, or an AGENTS_REVIEW holder who can see the agent; an agent the reviewer cannot see answers like a missing id (MAP-3530).
  • Windows are half-open in unix seconds, taken from the server clock rounded down to the second: current = [now - P, now), previous = [now - 2P, now - P). A run created in the current second is not counted until the next request.

Response (no field is ever null; an agent without runs returns zeros):

Field Type Meaning
runs, runs_prev integer Number of runs created in the window, including pending and not yet started runs. These are exactly the rows the agent's Runs list shows for that window (the list itself is capped at 200 rows, the count is not).
spend, spend_prev number Cost in USD (currency), rounded to 6 decimal places. The raw provider cost at list price, before any markup, of the request-log entries of those runs. Retries of one run are summed. Cost of a delegated child agent is not included (it belongs to the child). A run without a trace reference, or whose request logs are disabled or already pruned, contributes 0. BYOK calls (your own provider key) are included at the same list-price raw cost, even though the provider bills you directly, because every priced leg is recorded in the request log.
p50_ms, p95_ms integer Exact nearest-rank percentiles of run duration (finished - started) in milliseconds, over the current window's finished runs only (started and finished, finish not before start). Unfinished runs are counted in runs but not here. Durations have whole-second granularity, so values are multiples of 1000. 0 when no run finished.
period string The period used.
currency string Always "USD".
runs_scope string Always "agent_run": only recorded runs (schedules, webhook triggers, workflows, chat-bridge and delegated runs) are counted. Ad-hoc invokes (Try-it, API, chat) are not runs, and their spend is not included.

All figures come from one consistent database snapshot.

Permissions. The caller needs the author role (AGENTS_AUTHOR) and must be the agent's owner, an admin, or hold AGENTS_REVIEW in the same tenant. Note that AGENTS_REVIEW holders can read these stats although the Runs list (/runs) is owner/admin-only. Everyone else gets the same 404 agent_not_found as for a missing id.

Errors. 400 invalid_period; 404 agent_not_found; 503 on a database fault, a permission-layer fault, or a snapshot that could not be read consistently (retry).

Agent credentials (identity)

GET /admin/v1/gateways/{gw}/agents/{id}/credentials

Every credential that acts as the agent, in one list: the read behind the agent's Identity & credentials view (the Identity tab of an internal agent, the section of the same name on an external agent; see Agents, identity and credentials). It takes no parameters and no body. To revoke a credential, use its existing route: DELETE /gateways/{gw}/tokens/{id} (agent token), DELETE …/agents/{id}/webhook-triggers/{trigger_id}, DELETE …/agents/{id}/mcp-tokens/{token_id}, DELETE /admin/v1/mcp-oauth/grants/{family} (OAuth connection).

Response 200: a JSON array ([] when no credential acts as the agent), one object per credential:

Field Type Meaning
kind string agent_token (a gateway token bound to the agent with agent_id), mcp_token (an mcp_proxy token of an external agent), webhook_trigger (a webhook trigger of the agent) or oauth_grant (an active MCP OAuth connection to the agent).
id string The credential's id: the token id, the trigger id, or the OAuth connection's family id.
label string | null The token label or the trigger name; for an oauth_grant the client's host. null when none is set.
hint string | null Tokens only: the last 4 characters of the token (lowercase hex), or null for a token minted before hints were stored. Always null for webhook_trigger and oauth_grant.
created_at integer | null Unix seconds.
created_by object | null {id, name}. For a token: the user of its token.minted audit row, null when there is none. For a trigger: its creator. For an oauth_grant: the approving user. Only a live user of the agent's tenant is named: anyone else (a user of another tenant such as a platform admin, an erased or disabled account) is null, so no foreign user id is disclosed. name is null when the user has no display name.
last_used_at integer | null Unix seconds of the latest successful authentication, null = never (or used only before this was recorded). For a webhook_trigger: when it last fired. For an oauth_grant: its current access token's last use. See below.
expires_at integer | null Unix seconds; null = no expiry. Always null for a webhook_trigger; for an oauth_grant the connection's absolute expiry.
status string active, expired (expires_at has passed) or disabled (a disabled webhook trigger).
acts_for_user object | null {id, name} of the user the credential acts for: the owner for an mcp_token, the approving user for an oauth_grant; null for agent_token and webhook_trigger, and null when that user is not a live user of the agent's tenant.

Metadata only. The list never contains a token, a token hash, the webhook URL token or url_path, a webhook secret, an access-token id or the scopes. Not listed: the credential-family token rows minted by the device-code and MCP OAuth flows (labels device / mcp_oauth; an OAuth connection appears once, as its oauth_grant) and the gateway's protected internal service credentials (the scheduler service token and the chat-bridge token).

last_used_at. Stored in auth_token.last_used_at (migration 0946) after a token passes every authentication check, off the request path and at most once per token per 5 minutes: a token used again within that window keeps the earlier time, so the value can be up to about five minutes older than the latest use. A failed stamp is logged and dropped; it never affects the request. The value is exposed only by this read: the MCP token list and the gateway token list do not include it.

Permissions. The agent's owner, or an admin / tenant_admin who manages the agent and, when not the owner, may act on the owner (same tenant, never a platform admin's agent unless the caller is one, and a role that out-ranks the owner's): the same rule as the agent's token writes. An agent without an owner (a pending hand-over) follows the manager rule alone. A user the agent is shared with or an AGENTS_REVIEW holder who is not the manager gets the 404.

Errors.

Status Body When
404 {"error": "agent not found", "code": "agent_not_found"} The agent does not exist on this gateway, belongs to another tenant, or the caller is not its owner or manager, or may not act on the owner. Every refusal answers the same, so the route does not reveal whether the agent exists.
404 {"error": "not found"} The gateway does not exist or belongs to another tenant (the gateway check, before the agent is read).
401 {"error": "unauthenticated", "code": "unauthenticated"} No admin session.
403 {"error": "feature_disabled", "code": "feature_disabled", "feature": "agents"} Agents are off for the tenant.
500 {"error": "a stored token record of this agent is invalid; rotate the agent's tokens", "code": "invalid_token_hint"} A stored token hint is malformed. A permanent data fault, logged once at ERROR with the gateway, agent and token id (never the value); recover by revoking or rotating the agent's tokens.
503 {"error": "temporarily unavailable; retry later"} A database fault in any of the reads, including the owner lookup of the permission check, which is never answered as a 404 (retry).

Clone lineage (source_agent_id) — for per-agent usage stats

The create endpoint (POST /admin/v1/gateways/:id/agents) accepts an optional source_agent_id — the id of the agent being cloned. The clone UI sends it automatically. It powers the per-agent distinct-users and conversations roll-up in /admin/v1/stats/analytics (each clone's usage counts toward the shared original; see the stats reference).

  • Accepted: a string id of an agent the caller can see (own, org-shared, or shared to them/their group), on the clone's target gateway. The server re-validates through that visibility gate and flattens the value to the source's own lineage root, so the lineage tree stays one level deep.
  • Rejected / ignored (fail-open to NULL): an absent, non-string, unknown, or not-visible source_agent_id is dropped to NULL — the new agent becomes its own lineage root and the create still succeeds. It is never an error (a share revoked between opening the catalog and cloning must not break a valid create), and a source the caller cannot see can never be attributed — so lineage cannot be forged across tenants or onto another member's private agent. Immutable after create (not editable via PATCH). Redacted from the catalog/sharee view.

System prompt on invoke

When an agent is invoked, the gateway assembles the agent's system message from these parts, in order:

  1. Today's date — a line such as Today's date is Tuesday, 2026-10-20 (ISO week 2026-W43; the current week runs Monday 2026-10-19 to Sunday 2026-10-25). is prepended to every invocation (from the same source the /easy chat surface uses). The date is the Europe/Berlin calendar day (not the server's UTC day), and it carries the weekday, the ISO week and the Monday-to-Sunday range of the current week because small models otherwise guess the weekday and miscompute "last week". Without it the model has no notion of the current date and treats "today" as unknown or future — a "Daily briefings" agent was observed refusing to run a web search, claiming the current date "lies in the future" and citing its training cutoff. The date is a plain fact and is injected unconditionally, for every provider and every agent (including structured-output agents).
  2. Organization policy — the tenant's system_instruction (if set), as a steering preface.
  3. Anti-fabrication guardrail — a tool-agnostic rule that the agent must not claim it searched the web, looked something up, read a document, or ran a tool unless a tool actually returned it (that turn or earlier in the conversation); answering from the model's own knowledge is still allowed, just not dressed up as a lookup. It also tells the agent to give a link only if that exact URL appeared in a search or fetch result in the conversation, the user wrote it, or the instructions give it, never one constructed or guessed from memory. This is the same rule the /easy chat surface carries — a single shared source — applied on every agent completion (invoke, draft preview, scheduled task) so smaller models don't announce-then-stop or invent a lookup's results. (The companion "emit the search call itself" nudge is added separately, only when the web_search tool is offered.)
  4. The agent's instructions — the agent owns its persona; caller-supplied system/developer turns are dropped and never override it.
  5. Structured-output directive — appended when the agent has a response_schema (see below).

Callers cannot influence any of this beyond the request input/messages: the agent is the sole source of truth for its system prompt.

When web search is enabled, the gateway appends a "Sources" (German: "Quellen") footer to the answer — a numbered list of the web result URLs the turn used, matching the inline [N] citation markers. The footer's wording follows the conversation language: the language detected for the conversation turn (chat conversations and agent runs, including an agent /invoke; any other bare API request without an x-aig-conv-id header skips this detection), else the account's interface language, else English. English conversations get Sources and German ones Quellen; any other language gets the English wording. This footer is added by the gateway after the model finishes, so a prompt instruction like "don't list sources" cannot remove it.

  • sources_footer (boolean, default true): set false on the agent to suppress the footer entirely. Editable in the agent editor as "Include sources list in the answer", shown under the Web Search toggle. Only affects web-search output; an agent without web search never emits the footer regardless.
  • Cap: even with the footer on, at most 100 sources render. Beyond that a single line reports how many further distinct sources were hidden (… (N more sources hidden), German: … (N weitere Quellen ausgeblendet)) — this bounds the runaway 300+-link footers that used to flood scheduled-agent email / Mattermost delivery. A citation whose number exceeds the cap degrades to plain [N] text in the web UI rather than a link.
  • Trade-off when off: sources_footer: false removes all web-source visibility, including the inline [N] links — web-search sources have no separate structured panel (that panel is for knowledge-area / file citations), so with the footer gone the [N] markers stay plain text.

Streamed interactive invoke (stream)

The invoke and draft-preview request bodies accept an optional stream field:

  • Accepted: a JSON boolean, JSON null, or nothing. false, null or absent → the historical buffered JSON response (the default; the scheduler and API integrations are unchanged). true → the response is SSE (text/event-stream). The same rule applies to stream on the /v1 inference endpoints.
  • Rejected: any other shape — "true", "false", 1, 0, "", an object or array — is refused with 400 INVALID_REQUEST (never coerced).

stream:true exists for the interactive surfaces (Try-It, draft Preview, the workflow step-test): a buffered invoke writes zero bytes until the tool loop finishes, so an idle CDN connection dies at the CDN's idle cap while a long agent is still working. A streamed invoke opens the wire immediately and the gateway emits an SSE comment heartbeat (: hb) roughly every 15 seconds, so the connection is provably live for the whole run.

Semantics of a streamed invoke:

  • Policy still wins. Runs that must be validated as a whole are executed internally buffered and the finished, validated body is then re-emitted onto the open SSE wire as ordinary chunks: agents with a response_schema (egress validation + STRUCTURED_OUTPUT_FAILED are enforced exactly as documented above), and gateways with a response-phase guardrail detector the live stream cannot satisfy (a content-safety block, or a regex/presidio scrub). A gateway whose only response detector is an inline PII token-restore masker (pii_protector / custom_pii) streams incrementally — tokens are restored on the live wire, no internal buffering. stream:true is a wire format, never a policy bypass.
  • Headers: the X-AIG-Trace-Id, X-AIG-Agent-Version, X-AIG-Tool-Warnings, X-AIG-PII-Active and X-AIG-Cost-Micros response headers are absent on a streamed invoke (they are committed before the run finishes). A caller that needs them — the scheduler's fail-closed PII-egress gate reads X-AIG-PII-Active — must call buffered; the scheduler always does.
  • Errors after the wire opens arrive as a terminal SSE event followed by data: [DONE]. A client that opted into the gateway's aig_* side channel (x-aig-turn-id, or x-aig-extensions: 1) gets aig_status:"provider_error" (error_class, message, user_message.body); a plain OpenAI-compatible client gets the OpenAI-shaped {"error":{"message":"…","type":"gateway_error","code":"<error_class>"}} instead, so its schema validation does not abort the stream. See Inference — what a plain client receives.
  • No response caching: a streamed invoke bypasses the response cache (parity with streamed chat). In fact no agent invoke — streamed or buffered — is ever served from or written to the gateway response cache, even when cache_ttl is set on the gateway: agent runs must return fresh output every run, and every buffered agent invoke must reach the full response path so its fail-closed X-AIG-PII-Active egress header is emitted for the scheduler (including when a request-phase guardrail blocks the run). See Response caching.

Guardrail-block marker on agent invoke

A guardrail block on an agent invoke carries a machine-readable marker, so an unattended caller (the workflow runner, the agent scheduler) never mistakes the refusal for an answer. It is added only on agent invoke; a chat completion's block keeps its response shape (the 200 refusal bubble / the 400 guardrail_blocked) unchanged.

Phase Status Header Body
Request guardrail 200 (synthetic refusal completion, id: "chatcmpl_guardrail") X-AIG-Guardrail-Block: request top-level aig_guardrail_block
Response guardrail 400, X-AIG-Error: guardrail_blocked X-AIG-Guardrail-Block: response error.aig_guardrail_block

aig_guardrail_block is { "blocked_by": "<guardrail name>", "block_reason": "<code>", "phase": "request|response", "class": "<block class>" }. class is the gateway's block class (guardrail_blocked, guardrail_unavailable, guardrail_doc_too_large, guardrail_unconfigured, guardrail_pii_mandatory, …; a response-phase block is always guardrail_blocked). blocked_by is at most 128 characters with control characters replaced (guardrail when the refusal names no detector). block_reason is present only for a closed-set code (prompt-guard S-codes, prompt_injection, built-in pattern names, fixed gateway slugs); for a keyword, custom regex, jailbreak phrase or custom PII name it is omitted. The header is absent on a streamed invoke (headers are committed earlier) — call buffered.

How the workflow runner reads it (fail closed). A block is a failed step when the header and the body object are both present and well formed. It is never retried, except a temporary outage class (guardrail_unavailable, guardrail_doc_too_large), which follows the step's retry policy; an absent class counts as a content block and a class that is not a lowercase slug of at most 48 characters makes the marker malformed. When the signal is missing or malformed while the response is a block — the header without the object or the reverse, an unknown phase, a phase that disagrees with the header, a blocked_by that is empty / not a string / longer than 128 characters / contains a control character, a non-string block_reason, a synthetic refusal body with no marker, or a 400 guardrail_blocked with no marker — the step fails the same way, without a guardrail name. It is never read as success.

How the agent scheduler reads it. A scheduled, webhook-triggered or resumed agent run applies the same fail-closed rule. A block (or a missing or malformed signal on a refusal) makes the run failed with error_class = guardrail_blocked, the guardrail name and reason when the marker carried them, and an error such as Blocked by guardrail <name>; not retried. The refusal text is never delivered to the schedule's email, Mattermost or webhook destination. Instead the owner gets the usual failure notice. An agent schedule has no in-run retry, so a temporary outage class also fails the run (the error says temporary guardrail outage); the next scheduled run tries again. An agent answer whose text only reads like a refusal is not a block.

Why a run failed, in the server's own marker. Besides guardrail_blocked, the gateway records two server-only markers on a failed run (error_class, never settable through a request body: a guardrail_block object carrying an error_class key is refused as malformed): approval_expired (a held tool call nobody decided within the approval window) and cancelled (a queued run cancelled by a kill switch: a disabled or deleted trigger or agent, a hand-over, a protection pause or an erasure). Both are an outcome the owner or an administrator caused, not a gateway fault: the failed run is not filed as a systemic server error and nobody on call is paged for it. A run that failed without such a marker (for example a lease timeout) is still treated as before. Runs failed before this change carry no marker and are not re-classified.

Delivery disposition (X-AIG-PII-Active, X-AIG-Delivery)

Every buffered agent-invoke 200 carries two headers that tell an unattended caller whether the result may leave on an external channel (webhook, Mattermost, an outside e-mail address). Internal delivery — the owner's e-mail, e-mail to an active user of the same tenant under the tenant's internal-delivery opt-in, the in-app run result — is never gated by them. Which delivery channels count as internal is the organisation's delivery channel class (default: webhook, Mattermost and outside e-mail are external). For a channel classed internal the scheduler's and the workflow runner's clearance answers 200 { "cleared": true, "disposition", "reasons", "internal_channel": "<webhook|mattermost|email>" } whatever the disposition; a runner accepts it only for the channel it is delivering to.

Header Value Meaning
X-AIG-PII-Active 0 | 1 1 when the run masked personal data anywhere: in the prompt, or in anything a tool brought back — a fetched page, a web search result, the web search query itself, a file (read_file), a knowledge passage (search_knowledge), or a connector (MCP) result — or when any of these (the prompt and the web search query included) was passed on unscanned during a PII-analyzer outage (see below). An absent header is read as 1.
X-AIG-Delivery <level> or <level>; <reason>, <reason>, … The run's delivery disposition and where the personal data was found.

Levels, loose to strict: allow < internal_only < approval_1 < approval_2 < block. Each personal-data mask counts with the delivery level of the source it came from: the connector's source policy (its trust class or pii.delivery override), the gateway's setting for a built-in source, raised by the organisation's minimum for every source and the agent's own stricter setting. The run's disposition is the strictest of them; a run that masked nothing gives allow. A source nobody configured is external, so its personal data gives internal_only (external delivery refused, internal delivery unchanged) — the behaviour before source policies. An internal source gives allow, an untrusted one block. Personal data in the prompt, or masked without a recorded place, counts as the default class under the floor and the agent. A connector whose policy cannot be read when the run ends gives block. A connector tool's result always counts with that connector's source policy (reason <connector id>:tool_result:<tool>), also when it comes from a call a human approved and the run resumed, on the leg where a file request takes the connector tools away again to force the file, and in a chat when the model is told the outcome of a connector call a colleague approved (Approval by someone else): the told result counts with the connector the request was opened for, and when that connector cannot be named (the request carries none, or the same tool name belongs to different connectors in the outcomes told together) it fails closed as below (reason unknown:tool_result). A connector tool counts as its connector also when its name is that of a gateway tool (a file server's read_file); only a built-in tool counts as a built-in source. A tool result that cannot be attributed fails closed. A result of a tool that is neither one of the gateway's own tools (its built-in tools and sub-agent tools agent__<slug>) nor a connector tool of the run gives the strictest level, block — whatever the floor or the agent's setting — with the reason unknown:tool_result:<tool> (or unknown:tool_result when the tool's name does not fit the place format). It is never read as the default class: it may be a connector's result whose own source policy is stricter than internal_only. X-AIG-PII-Active is 1 exactly when the level is internal_only or stricter. A caller must treat approval_1, approval_2, block (and any value it does not know) as "do not deliver externally". For a scheduled agent run the gateway itself holds an approval_1 / approval_2 result for a delivery release: the scheduler's clearance answers held and the external delivery goes out only after the release.

A reason is <source>:<where> — the source (web_pages for fetched pages, web_search, knowledge_files for knowledge and files, a connector id, prompt) and the place (fetched:<host>, tool_result:<tool>, query, user), for example internal_only; web_pages:fetched:heise.de, web_search:query. Reasons name places only, never a masked value (a place is the fetched page's host name or the tool's name as they are). A page read by the agentic reader (agentic_fetch) is named by its host too; unknown means the place was not known (never a guess), and unknown:tool_result:<tool> a tool result whose source could not be attributed (it gives block, see above); unattributed means personal data was masked but no place was recorded; run:resumed means a run that paused for an approval had masked personal data before the pause. The list is cut to 1 KB, ending in +N more.

Only a reversible mask counts — a pii_protector or custom_pii token, which is restored in the answer and could therefore leave with it. The chat "personal data masked" chip counts exactly these, so the chip and the delivery gate always agree. A detector that only flags personal data (nothing masked), a request-phase block (the run answers with a content-free refusal) and an irreversible anonymization (a presidio detector with action scrub: no value is left to restore) do not restrict delivery.

Unscanned content counts too. When a personal-data detector cannot scan something a tool brought back — the PII analyzer is down or times out — and the content is passed on anyway (a pii_protector with fail_open: true, a presidio detector with action scrub, which passes tool results on by default during an outage), nothing is masked, but the content was never checked either. It is not read as clean: it restricts delivery exactly like a mask, with the place of the unscanned content as the reason (for example internal_only; web_pages:fetched:heise.de for a page fetched during an outage). This covers every tool result — fetched pages (also those read by the agentic reader), web search results, files, knowledge passages and connector (MCP) results. A web-reading agent on a fail_open gateway therefore loses webhook / Mattermost / outside e-mail delivery while the PII analyzer is down; the owner's e-mail and other internal delivery are unaffected. Nothing changes for a chat user (the chip still counts masks only) or for content that was withheld because it could not be scanned (it never reached the model). Only a detector that would have kept personal data out counts — one that masks or anonymizes it, or a presidio detector with action block; an outage of a detector that only flags does not restrict. The same holds for the prompt itself: when the request-phase scan of the prompt — the user's message, the system instructions where the gateway scans them, and, in a workflow agent step, the content a trigger brought in (a webhook payload, an e-mail, a form submission) — is skipped on an outage, the run restricts with the reason prompt:user; when the answer's scan is skipped, with prompt:response. A web search query sent to the search provider unscanned during an outage restricts with web_search:query, exactly like a masked query. The prompt is not exempt because its owner wrote it: the personal data in it, and in a trigger's payload, would reach the answer unmasked. A conversation-summary leg's outage restricts with the reason unknown:unknown, as its masks do.

Run records. For an unattended run bound to a workflow run or an agent run, the gateway also stores the disposition on the run itself — delivery_disposition (the level) and delivery_reasons (a JSON array of reasons, at most 4 KB) on workflow_run and agent_run — beside pii_active, before the response is sent. The stored level only ever rises (a later, cleaner step never lowers it); delivery_reasons is replaced together with a stricter level, and when a later step reaches the same level its reasons are added to the stored ones (stored first, no duplicates, at most 128), so a workflow run names the places of every step. A list that was already cut at the 4 KB cap (it ends in +N more) is left as it is. If the write fails, the invoke fails closed (500, the result is not sent); on a request-phase guardrail block the refusal goes out anyway — it carries no result. Runs recorded before this change carry no disposition (null); pii_active alone decides for them.

Clearance answers. The internal clearance routes (POST /internal/scheduler/deliver-clearance, POST /internal/workflow/deliver-clearance) and the PII refusals of POST /internal/workflow/deliver-email carry the disposition: 200 {"cleared": true, "disposition": "allow", "reasons": []}, or 403 {"error": "blocked_pii", "cleared": false, "disposition": "internal_only", "reasons": ["web_pages:fetched:heise.de"]}. A run is refused when pii_active is not exactly 0 or the stored level is stricter than allow or the stored level is not one of the five (reported as block). The scheduler route answers one more case: a run whose level is approval_1 / approval_2 and whose stored schedule delivers to an external channel is held for a delivery release — 200 {"cleared": false, "held": "<release id>", "disposition": "approval_1", "reasons": [...]}. The workflow route never holds: approval_1 / approval_2 are refused there with 403 blocked_pii.

What the scheduler and the workflow runner accept (both answers are untrusted input, fail-closed):

  • invoke response: external delivery only when X-AIG-PII-Active is exactly 0 and X-AIG-Delivery, when present, has the level exactly allow (text before the first ;, surrounding spaces ignored). An unknown level, a wrong case (Allow), an empty value → refused. No X-AIG-Delivery at all (an older gateway) → X-AIG-PII-Active alone.
  • clearance answer: delivered only on a 2xx JSON object with cleared exactly true and no disposition other than exactly "allow". The scheduler reads a hold only from a 2xx JSON object with cleared exactly false, held a 1-64 character id (A-Z a-z 0-9 -) and disposition exactly approval_1 or approval_2. A 2xx of any other shape whose disposition is not allow (approval_1 without held, null, a number) is a PII block — blocked_pii plus the content-free owner notice — never a delivery and never a hold.

A refused external delivery takes the existing blocked_pii path: the run records delivery_status: blocked_pii and the owner gets the content-free notice; the owner e-mail and opted-in internal e-mail are still delivered. A held delivery records delivery_status: waiting_release instead and the owner gets the release notice, with their own copy of the result attached when internal delivery allows it (see Delivery releases).


Running an invoke in the background (Prefer: respond-async)

A buffered invoke (stream absent, null or false) waits for the whole run and is cut at 360 s of waiting for a tool-using turn; a proxy or CDN in front of the gateway may cut the connection even earlier. Send Prefer: respond-async (RFC 7240) with POST /v1/{tenant}/{gateway}/agents/{slug}/invoke and the gateway accepts the run at once, keeps working on it after your connection is gone, and gives the turn the same 900 s budget as an unattended run. Read the result later.

POST /v1/{tenant}/{gateway}/agents/{slug}/invoke
Authorization: Bearer <API key>
Content-Type: application/json
Prefer: respond-async

{ "input": "..." }

The answer is 202 with Location: /v1/{tenant}/{gateway}/async/{id}, Preference-Applied: respond-async, Retry-After: 5, Cache-Control: no-store and Connection: close. Poll the Location with the same API key (see Fetching an asynchronous result). The stored final response is the one a synchronous invoke would have returned: the same status, body, content type, x-should-retry and x-aig-* headers, including X-AIG-Run-Id. An interrupted answer keeps x-should-retry: false: its tools may already have run, so do not retry it. The run is logged as one request. Do not send the invoke again: a second POST starts a second run.

  • Only a plain buffered POST to the invoke route is accepted. A streamed invoke (stream: true), any other method, the draft preview and the other agent routes ignore the header and answer synchronously.
  • Only gateway API keys create asynchronous results. Web-app session tokens, device sign-in tokens and MCP OAuth tokens, a key that expires within about 21 minutes, and a gateway that requires no API key are answered synchronously.
  • A malformed Prefer header on a request that would otherwise be accepted is refused with 400 invalid_prefer_header; the run does not start.
  • A run held for approval. If the run stops at a human-in-the-loop tool gate, the stored result is that held response. While the run is still being processed the poll answers 202 with a Retry-After header and {"id":"...","status":"running"}. A 202 without Retry-After is a finished response: the run is held for review, not still running. Resume it as described in that section.

Unattended runs — 900 s tool-loop budget

Every agent turn is bounded by a wall-clock budget on its server-side tool loop (web search, file tools, MCP), measured from the start of the request (the first model leg counts, and a round-limit compaction does not restart it): 900 s (15 min) for a streamed turn, also while the answer is held back for inspection or web search, and 360 s when the client receives nothing until the end (stream: false, or a held stream on a provider route other than /anthropic/v1/messages, which gets no keep-alive). A chat bridge turn is the one stream: false exception: it gets 900 s as well, because the bridge waits for the whole answer and posts it once; every other stream: false turn stays at 360 s. A bridge turn stopped by the limit still posts what it produced, followed by the time-limit note; reply in the thread to continue. The same budget is the last backstop of a reasoning-only model leg. That cap exists to protect interactive clients from silence timeouts; a streamed turn is kept alive with a heartbeat at least every 16 s, so it can run longer. An unattended caller — the built-in scheduler, or your own automation that owns its HTTP read timeout — gets at least 900 s (15 min) per invoke. The opt-in only ever extends: a stream: false run (silent 360 s) gets the full 900 s, the same as a streamed run:

X-AIG-Unattended: 1

Accepted shape and rejection (the gate fails closed to the interactive budget):

  • The value must be exactly the string 1. Any other value (true, 0, empty, whitespace-padded), a repeated header, or a non-string is ignored.
  • The request must authenticate with a non-user-bound gateway service token. A user-bound API token, an SPA session, or an auth-less gateway never gets the extended budget — the header is silently ignored, never an error.
  • Applies to POST …/agents/{slug}/invoke and the scheduled-task invoke. The scheduler sends it on every run it fires.

The header extends wall-clock only: the per-turn tool-round cap and the token's spend budget are unchanged. If your client opts in, raise your own read timeout above ~1250 s (budget + one in-flight tool round + the final partial-answer call); the gateway sends the response as a single JSON body at the end of the run.

Budget exhaustion delivers a partial answer

When the wall-clock budget runs out after tool results were already gathered, the run is not discarded: the gateway makes one final model call without tools (bounded to at most ~60 s and 4096 output tokens — the same 4096 on a model that always reasons, with reasoning kept to a minimum) over the results collected so far and delivers that partial answer, followed by an honest note — "Stopped early: the time budget ran out — this answer is based on partial results." (in a chat conversation it follows the language of the request, German or English; for any other language the account's UI language, else English. An agent run follows the language of its input in the same way: German or English, else the account's UI language, else English; a service-token run has no account, so for any other language its note is in English). The note is part of the answer text, so it persists with the turn.

This applies to interactive chats and unattended runs alike. If the budget runs out before any tool result exists, or the final call itself fails or produces nothing, the run ends with a plain stop note instead (same language rule, no number) — the gateway never invents an answer from tool calls that did not complete:

  • Interactive runs (chat, playground, compat API callers, and /invoke without the unattended header): "Stopped: this answer reached its time limit. Anything produced so far is kept, and you can ask to continue from here." A client sends its own message history, so it can ask to continue.
  • Unattended runs (scheduled and webhook-fired agent runs, scheduled prompt tasks, workflow agent steps, and any service-token call that sends X-AIG-Unattended: 1): "Stopped: this run reached its time limit before it finished. Anything produced so far is kept. If this repeats, make the task for each run smaller." (German: "Abgebrochen: Dieser Lauf hat sein Zeitlimit erreicht, bevor er fertig war. Alles bisher Erstellte bleibt erhalten. Wenn das wiederholt auftritt, verkleinern Sie die Aufgabe pro Lauf.") Text the run already produced in earlier rounds stays in the delivered answer. The recipient of such a run (an email, a webhook, a chat message) may have no conversation to continue, so the note promises no follow-up. A service-token call without the X-AIG-Unattended header gets the interactive note.

Round limit stop note

When a turn uses up its tool-call rounds (the default 25, or the agent's own max_steps), the gateway delivers the best answer it has and appends a note. The stop reason (max_rounds_reached), details.limit and can_continue: true are the same for every caller that receives the typed event (a streamed run that opted into the side channel with x-aig-turn-id or x-aig-extensions: 1; a plain stream or a stream:false turn does not get it, see What a plain client receives); only the wording of the note differs.

  • Interactive runs (chat, playground, compat API callers, and /invoke without the unattended header): "Reached the per-turn tool-call limit (25 rounds); this is my best answer so far. Ask me to continue to pick up where this left off."
  • Unattended runs (the same set as above, including any service-token call that sends X-AIG-Unattended: 1): "Reached the per-turn tool-call limit (25 rounds); this is the best answer from this run. If this repeats, make the task for each run smaller." An unattended run that is forwarded by email, webhook or chat has nobody to answer a request to continue, so the note makes no such promise. A service-token call without the header, or with any value other than 1, gets the interactive note, and so does a call made with a user-bound token.

In a chat conversation the note follows the language of the request (German or English; for any other language the account's UI language, else English). An agent run follows the language of its input in the same way (German or English, else the account's UI language, else English), so a scheduled run with German input sends a German note by email; a service-token run has no account, so for any other language its note is in English. Web search on an agent run also follows the input language, as in chat. The same unattended wording applies to the other two notes the gateway can append to an answer: when a tool call is cut off at the output limit the note asks to make the task for each run smaller (for a file: write it in several steps or as several smaller files), and when a model emits a tool call the gateway cannot parse the answer says the call was not run and, if the result is missing, to run the task again (if it repeats, simplify the task or use a different model). Neither asks for a follow-up turn; interactive runs keep the "ask me to continue" wording. On the unattended side, a turn that delivered no answer reads "... before this run finished. If this repeats, make the task for each run smaller."

Human-in-the-loop tool gate — suspend / review / resume

An agent can require a human to approve specific tool calls before they run in an unattended (scheduled / webhook) run. Configure it on the agent's tool_config:

{ "tool_config": { "approval": { "tools": ["write_file", "web_search"] } } }

approval.tools is a list of tool wire-names whose calls must be human-approved. Scope: the gate matches any tool that dispatches this run by its wire name — a gateway builtin (write_file, edit_file, fetch_url, web_search, agentic_fetch, read_file, search_knowledge, code_interpreter, generate_image), an MCP-connector tool (e.g. send_email), or a sub-agent tool (agent__<slug>). web_search matches the gateway's own web search tool — the one an agent on a Myra, OpenAI-style or Mistral model uses, and every agent on a gateway whose web search runs through its EU search provider (linkup) or under EU residency. A provider's built-in search (Anthropic, OpenRouter) on any other gateway runs inside the provider and cannot be held, and neither can the search of a run the gateway tool loop does not handle (an agent whose model cannot use tools: its search, if any, runs in the gateway's two-leg or Mistral's Agents API before the gate). A name in the list matches the tool the model called by its wire name; a listed name that dispatches to no tool this run never matches (it could not run anyway). One exception: an MCP tool whose own name collides with a builtin is offered under its connector's catalog slug (runway_generate_image, see MCP), and the gate matches it by either name — so listing generate_image gates both the builtin and that connector tool. The same holds for connector tool names the gateway adapts (see MCP — Tool names): a tool that two connectors both offer is github__create_issue / gitlab__create_issue only while both connectors are in the run, and a name outside A-Z a-z 0-9 _ - or longer than 64 bytes is rewritten. The gate matches a connector tool by every name it can be offered under — its own name, the rewritten name and each <prefix>__<name> form for its connector — so listing github__create_issue keeps gating GitHub's create_issue in a run where GitLab is missing (and it is then offered as plain create_issue), without gating GitLab's tool. Listing the plain create_issue gates the tool on every connector. A second exception: edit_file writes a file exactly like write_file, so listing write_file also gates edit_file (an approval list written before edit_file existed keeps gating every file write); listing edit_file gates only edit_file. Likewise edit_office_file (changing a .pptx/.docx/.pdf; the original is never changed; the edited file is saved as a new file, which gets a new name such as deck-2.pptx when the name is already taken, or is returned as a PDF only when asked) runs in the code interpreter's sandbox, so listing code_interpreter also gates edit_office_file; listing edit_office_file gates only edit_office_file (and a list naming only write_file does not gate it). edit_file makes one change per call: the calls of one model response that run in that round (up to the gateway's max_parallel_tools, default 4) are held and approved as one batch; further calls are re-issued by the model and approved with their own round — so a request with several changes can ask for more than one approval. Each approved round resumes as a fresh request, so edit_file's per-turn bookkeeping (its 20-calls-per-file limit and its "earlier changes are saved" note) counts within one round. Absent / empty approval.tools = OFF (today's behaviour, byte-for-byte). The list is validated at agent create/update (see the four-eyes/create contract): each entry is a non-empty, bounded, de-duplicated string; a malformed approval is rejected 400, never silently dropped (a dropped gate would run a tool the admin meant to hold).

A decided hold whose gateway cannot resume it waits; nothing fails. An approved or denied hold of an unattended run is picked up by the scheduler, which needs the gateway's scheduler resume credential (a service token) to continue the run. If that credential is missing on the gateway, the run stays suspended and the scheduler retries it on every sweep. The platform operators are alerted (once per gateway every few hours, after the decision has waited about 15 minutes) and provision the credential; the run then resumes by itself. The run is never failed because of this, and the approval or denial is not lost.

Approval authorizes the tool NAME/action — not a bypass of live controls. When a held MCP / sub-agent / egress-builtin call is approved and resumes, it still passes every runtime control at its execution chokepoint: the fail-closed egress gate (an approval granted before the project became local_only / no-egress does not egress after — the held tool is blocked on resume), the MCP-argument PII block (approved args carrying protected personal data are still refused), and connector tenant-isolation + sub-agent same-owner authz.

Behaviour. The gate applies only to unattended runs (the scheduler; a stream:false service-token invoke) — an interactive human invoke is never suspended (the human is present). When the server-side tool loop reaches a round whose executing batch contains a gated tool (builtin, MCP-connector, or sub-agent), the run suspends between legs: it persists enough state to resume — including the dispatch identity of any held MCP / sub-agent tool so it can run after approval, and, on a gateway that masks personal data, the run's file-name stand-ins (stand-in → stored name; read back as untrusted: only well-formed MYRA-FILE-<16 hex> keys with valid names of at most 255 characters are used, anything else is dropped and a held call naming it is refused), and, when the run carried a capability principal, the claims it was minted with (tool allowlist, envelope commitment, delegation depth; read back as untrusted and validated, never the token) so an approved held sub-agent call can be re-minted its parent scope on resume — records a review_item (status pending), and stops without running any tool in that batch (whole-batch hold — a non-gated sibling in the same round is held too, so no side effect fires while a gated call waits). The run's status becomes suspended; no output is delivered.

A tenant admin decides from the review inbox (see the decision API below):

  • Approve → the scheduler's resume sweep re-drives the run: the held tool(s) execute and the loop continues to completion (then delivers per the schedule, subject to the unchanged fail-closed PII egress gate + the optional delivery-approval hold). The decided batch executes exactly once — a retried or duplicate resume runs the held tools at most once (see X-AIG-Resume-Run). Each executed built-in call is a record in the agent's activity log (Access decisions): an approved non-egress built-in (for example code_interpreter) has its approval_approved row as its only record, an approved egress built-in writes its waiver allow row, and an unheld sibling of the batch writes one default_allow row.
  • Deny → the run resumes with the gated tool(s) returning a denial result ([denied] This action was declined by a human reviewer.); non-gated siblings still execute and the agent continues, adapting to the denial. The same exactly-once fence applies, so the non-gated siblings also run at most once under a retried resume.
  • Undecided within the approval window → the review expires and the run ends failed with the error approval expired: no decision within the approval window (counts as rejected) and the server-side marker approval_expired (not a gateway fault: it is never paged); the gated tool never runs (fail-closed). Expiry counts as a rejection with no side effect. The failed run keeps no copy of the request payload. For a webhook-fired run, the incoming body is discarded when the run fails. The agent's owner gets one email per expired hold (at most once, best-effort: a mail that cannot be sent is logged, not retried). When the owner is also the hold's holder, the mail links to the approval card (/approvals/tools/<review id>; the card shows the expired state and, for a scheduled run, rerun/extend); otherwise it links to the agent's activity tab (the card would answer 404 for the owner). No mail goes to an approver who is not the owner.

A held call resumes only for the user it was held for. When a run is held, the gateway records the user whose credentials the run was acting with. A resume is accepted only while the run acts for that same user. If the agent's owner changed in between (for example a handover to a successor), the resume is refused with run is not resumable: credential holder changed, no held tool runs, and the run ends failed; start a new run instead. Runs that were held before this record existed carry no holder and are not checked (they resume as before). When the user the call was held for is erased, the record is replaced by a marker that matches nobody, so such a run can no longer be resumed; the run itself is not failed by the erasure and is ended by the normal approval-window expiry.

Approval window. tool_config.approval.ttl_seconds sets how long a hold waits for a decision: a whole number of seconds from 300 (5 minutes) to 604800 (7 days); absent = 604800. Any other value is rejected with 400 invalid_approval_ttl. A tenant can set a default that is written into new agents at create time. A change applies to new holds only; a hold already waiting keeps the deadline it was created with. Details: Approval window.

🔒 Only a tool the gateway actually offered can run. The review queue shows the gated names, so a non-gated sibling in the same batch executes on resume with no separate approval. Whether each held call named a tool the gateway offered is therefore decided when the batch is suspended — the only moment that is knowable — and recorded with it; on resume a call marked unoffered is refused and the model receives [error] tool '<name>' is not available on this turn … in its place, while the batch keeps its original shape so every other call defers and executes exactly as it would have. The same check gates dispatch on the live path, so a model that invents a call for a tool that was never sent cannot execute it.

The parallel-tool cap in force when the batch was held is recorded with it for the same reason: a call that was beyond the cap — and so was never shown to the reviewer — still defers on resume even if max_parallel_tools is raised while the review is pending. It re-enters the executing window on a later round, and is reviewed then, exactly when it would run.

Reviews created before this shipped resume unchanged.

A resumed run that reaches another gated call in a later round suspends again (a fresh review). Personal-data masking is latched across the approval: if the pre-suspend legs masked PII, the resumed run's X-AIG-PII-Active stays 1 (X-AIG-Delivery: internal_only; run:resumed when the resumed leg masked nothing new), so restored PII can never egress because a run happened to pause.

Approval window (tool_config.approval.ttl_seconds)

tool_config.approval.ttl_seconds sets how long a hold waits for a decision. It applies to the run holds of an internal agent and to the MCP-proxy holds of an external agent.

Accepted shape (create and update): a whole number of seconds from 300 (5 minutes) to 604800 (7 days), both ends included, for example {"tool_config": {"approval": {"ttl_seconds": 900}}}. Absent = 604800 (7 days).

What is rejected: any other present value — below 300 (299), above 604800 (604801), a fraction (300.5), a string ("900"), a boolean, an array or object, or an explicit null — answers 400 with nothing written:

{ "error": "tool_config.approval.ttl_seconds must be a whole number of seconds between 300 (5 min) and 604800 (7 d)",
  "code": "invalid_approval_ttl" }

A malformed value is never silently replaced by the default (absent and malformed are different answers). A value stored before this check that is not valid any more is read as 300 seconds at run time (the shortest window, fail closed) and logged as a warning; the agent page asks for a new value before the next save.

A change applies to new holds only; a hold already waiting keeps the expires_at it was created with. When the window passes without a decision the hold expires and counts as rejected (see above): the run ends failed, the owner gets one email, and a proxy retry gets approval_retry_expired.

Organisation default at create time. A tenant may carry a default waiting time for new agents (approval_ttl_default_s, see Updating a tenant). A create (POST .../agents, internal or external, including a create held for four-eyes approval when it is applied) whose body has no tool_config.approval.ttl_seconds is stored with that default written in as tool_config.approval.ttl_seconds (other approval keys of the body are kept). An explicit ttl_seconds in the body always wins. A tenant without a default leaves the field absent (7 days at run time). The default is applied once, at create time only: it is not a run-time fallback, an update never applies it, and changing or clearing it never changes an existing agent. If the default cannot be read, the create answers 503 and nothing is created (retry); a stored default outside 300–604800 (only possible by changing the database directly) counts as malformed, never as "not set": the agent is created with the 300-second minimum (the same shortest-window answer a malformed agent value gets at run time) and the error is logged. The web app's agent create page and external-agent wizard always send the waiting time they show (the preselected organisation default, else 7 days, or the user's choice), so an agent created there is stored with exactly the value the user saw.

Correlation headers (service-token only)

The built-in scheduler carries two headers on its unattended invoke. Both are honored only for an unattended service-token invoke (the same gate as X-AIG-Unattended); a user-bound or browser caller's headers are ignored (fail-closed). They are re-validated server-side.

Header Value Meaning
X-AIG-Run-Id the agent_run id Attaches a suspension to this run. The run must belong to the URL's (gateway, agent) — a mismatched / unknown id is refused (no cross-run / cross-tenant resume). Exception: on an unattended service-token call (X-AIG-Unattended: 1) a well-formed id that is not a run of this agent is ignored and the call gets a fresh run of its own (see unattended calls without a run id); a malformed id is still a 400. An existing run of this agent that is not running (already succeeded, failed or suspended) cannot be attached to again: it is refused with 400 INVALID_REQUEST (run is not attachable) and no fresh run is created.
X-AIG-Resume-Run exactly 1 Re-drive a suspended run: the gateway rehydrates the persisted conversation and executes the decided batch. Requires the run to be claimed (running) with persisted suspend state; otherwise INVALID_REQUEST. The decided batch executes exactly once per decided review: a per-review execution fence (an atomic compare-and-swap that marks the review executed before any held tool fires) refuses a second/duplicate resume with INVALID_REQUEST once the first has claimed execution — so a side-effecting gated tool can never double-fire, even across a scheduler retry. (A crash after the fence is claimed but before the run finishes forfeits the remainder of the run rather than re-running the batch — at-most-once is the safe direction for side effects.) If the fence cannot be evaluated the resume refuses fail-closed and runs nothing — INTERNAL when the persisted review reference is missing/corrupt or the fence's datastore is unavailable.

Unattended calls without a run id

An unattended service-token /invoke that carries no X-AIG-Run-Id gets a run of its own, created by the gateway before the agent starts, so the same protections apply as for a scheduled run: content the agent reads from third parties marks the run (see untrusted content holds), and a write or destructive connector call is held for the agent owner instead of being refused. This also applies when the header names a well-formed id that is not a run of this agent (or is linked to a chat bridge): the id is ignored and a fresh run is created. Calls that are not given a run this way: workflow-runner steps (an unattended call whose X-AIG-Workflow-Run-Id names a running workflow run of the same tenant and gateway), chat-bridge turns that have a driver, delegated child agents, MCP-proxy calls, playground and OAuth-grant tokens, and browser sessions.

X-AIG-Workflow-Run-Id. Only the workflow runner sends this header, and only on an unattended call. It is a pointer, not a credential: the gateway looks the id up once and honours it only when it names a running workflow run of the caller's tenant and gateway. For every caller that is not unattended (user-bound tokens, other service tokens) the header is ignored entirely, with no error, and the call gets its own run as if the header were absent. The one exception is a chat-bridge driver connection, where the header (like X-AIG-Unattended) is refused with 403 INVALID_IDENTITY. For an unattended caller, a malformed id is refused with 400; a well-formed id that names no running run of this gateway (unknown, finished, other tenant or gateway), whose current agent step is not this agent, or that cannot be read is ignored and the call gets its own run (for an agent with a task-envelope template, a read error instead fails the call with 500 and the run is settled failed). The runner records which agent step of a run is in progress (every agent invoke is bracketed by two internal runner calls), and the header attaches the call to the run only while that step's agent is the invoked agent; at any other time (a different agent, no step in progress) the call gets its own run, holds its write calls for the owner, and never reports to that workflow run's PII latch. When the call is attached, the id is reported to that workflow run's PII latch, which only ever writes to a run of the caller's own tenant and gateway. Residual: an unattended service token of a gateway that names a running workflow run of that same gateway, while that run's current agent step is the invoked agent, is treated as that run's step: it gets no run of its own, and that workflow run's untrusted-content taint and PII latch apply.

input_spans (workflow runner only). The runner also sends, next to input, which bytes of the input are the workflow's template text, the platform's untrusted-data markers and each substituted value. The prompt-injection and jailbreak guardrails then judge only the values, each on its own (see Prompt Injection — In a workflow agent step).

  • Accepted shape: a JSON array of 1–256 entries [start, end, kind]. start / end are whole numbers, UTF-8 byte offsets into input, end exclusive. The first entry starts at 0, each entry starts where the previous one ended, and the last ends at the input's length. kind is "author", "platform" or "untrusted:<origin>" with origin form, webhook, email, manual, schedule, step or data. A "platform" entry must be exactly one or more of the runner's two marker lines for this run: [Untrusted <the run's trigger kind>: trigger.output] + newline (form, webhook and email runs only) and newline + [End of untrusted content].
  • Honoured only on the call that is attached to the workflow run as described above (unattended, and X-AIG-Workflow-Run-Id names the running run whose current agent step is this agent, or the call's X-AIG-Run-Id run belongs to that workflow run), and only with an input string (not messages). From any other caller the field is ignored.
  • The "author" entries are checked, not trusted: one entry each and in order, they must be exactly the non-empty text segments between the {{…}} references of an agent step for this agent in the run's published workflow version, and there may be no more value gaps than that template has references. Otherwise the list is ignored. So the only bytes ever left out of the two detectors are the platform's marker lines and the workflow's stored template text; a caller cannot mark its own text as trusted. A list without "author" entries needs no template: everything except the marker lines is then classified as one piece.
  • The classified unit is a whole gap between two template segments (its values joined), not a single entry, so a value cannot be cut into small pieces to slip past the detectors.
  • Not an error when wrong: an absent, malformed or out-of-range list is ignored (a warning is logged) and the whole input is classified, as without the field. The request itself is never refused because of it.

API-token invokes get a run too. A runless /invoke made with an API token is given a run of its own in the same way when the token is either (a) bound to a user who owns the agent (any personal API token of the owner, other than the playground token and an MCP OAuth grant), or (b) a service token that does not send X-AIG-Unattended. Every such invoke therefore creates a run that is visible in the agent's run history, and its write or destructive connector calls are held for the token's user (for a service token, the agent owner) instead of being refused with approval_required. The response carries X-AIG-Run-Id, and X-AIG-Run-Status: suspended while a call waits. If the holder approves, the call runs once and the run completes; if the holder rejects, the agent is told the call was denied and the run still succeeds. On these calls a supplied X-AIG-Run-Id / X-AIG-Resume-Run is ignored and a fresh run is created. An approved call on a run this gateway cannot resume waits; the platform operators are alerted; it is never failed. A review that is never decided still expires after the approval window.

The shape is checked strictly on an unattended call, and a malformed value is refused with 400 INVALID_REQUEST (nothing runs) rather than treated as absent:

  • X-AIG-Run-Id must be a single string of 1 to 64 characters (repeated, empty or longer than 64 is refused);
  • X-AIG-Resume-Run must be exactly 1, and is refused without X-AIG-Run-Id;
  • an X-AIG-Run-Id that names an existing run of this agent which is no longer running is refused with 400 INVALID_REQUEST (run is not attachable), nothing runs and no fresh run is created (an id that names no run of this agent still gets a fresh run, as above).
Response header Value Meaning
X-AIG-Run-Id the run id Set when the gateway created the run. Use it to find the run in the run history.
X-AIG-Run-Status suspended Set when the run was held for approval before the response started. The caller gets the partial answer so far; the run continues after the owner decides.

The run appears in the agent's run history like any other run and ends succeeded or failed with the call. The agent's answer is available to the owner as result on Read one agent run, including for a run that was held and resumed later. When the logged response of the run was deleted by the operator-run payload expiry, result is absent and result_expired is true (owner-only, like result); the field is absent otherwise, including when the result is present or was never logged.

Chat-bridge driver (X-AIG-Bridge-Driver)

A chat-bridge turn arrives on the connection's own service token and names the person who asked in X-AIG-Bridge-Driver. That person becomes the run's invoker and the holder of the run's user-scoped MCP credentials, so the header is honoured only when all of these hold; every other case is refused with 403 INVALID_IDENTITY and nothing runs (it never falls back to the agent owner):

  • the request is on a service token that is the token of an enabled chat-bridge connection of this tenant and gateway;
  • the value is one canonical UUID (8-4-4-4-12 hex) - an empty, malformed, or repeated header is refused;
  • it names a user of this tenant who may run inference (not unknown, cross-tenant, disabled, deleted, erasure-pending (Art. 18) or a viewer);
  • the request does not also carry X-AIG-Unattended or X-AIG-Workflow-Run-Id. X-AIG-Run-Id and X-AIG-Resume-Run are accepted only for a run the bridge itself created: the run's recorded bridge connection and driver must equal this token's connection and this header's driver, otherwise 403 INVALID_IDENTITY.

Malformed run headers on a bridge request are refused with 400 INVALID_REQUEST and nothing runs: X-AIG-Run-Id must be a single string of 1 to 64 characters (repeated, empty or longer than 64 is refused); X-AIG-Resume-Run must be exactly 1, and is refused without X-AIG-Run-Id; a plain attach (no resume) to a run that is not running is refused. A run that belongs to another bridge connection or driver is 403 INVALID_IDENTITY (see above).

A bridge token without the header is refused too (absent does not mean "the owner asked"). On a user-bound token the header is ignored: the caller's own id is invoker and holder. On a non-bridge service token or another gateway's bridge token it is refused with 403. The invoker id is always the canonical (lowercase) id of the user row, whatever case the header used. Only a non-bridge service token (scheduler, workflow runner) may run without a driver. If the connection or the user cannot be read, the response is 500 INTERNAL, not a silent downgrade. See Chat bridge.

A bridge turn is attached to an agent run, so a gated write call is held for the driver's approval instead of being denied; the run is resumed by the scheduler after the decision and the outcome is posted into the chat thread (see Chat bridge). Held bridge runs are not triaged and are failed if the driver is erased (Art. 17).

Connect-required response header (X-AIG-Connect-Required)

When a connector the agent uses needs the caller's own credential and the caller has none (or it expired), the tool is not run with anyone else's credential. The invoke response then carries X-AIG-Connect-Required: a comma-separated list of up to 10 distinct connector UUIDs (lowercase, de-duplicated, in first-seen order). It is derived from the same warnings as X-AIG-Tool-Warnings - both at tool discovery and when a tool is called (credential_required / credential_expired) - and carries ids only, never a connector name. The header is absent when no connector needs a credential. The chat bridge uses it to tell the person which connectors to connect.

Review decision API

Base URL https://ai-api-admin.myra.eu/admin/v1. All three require the EGRESS_APPROVE permission (admin / tenant_admin governance — the same permission as the agent delivery-approval inbox) and are tenant-scoped server-side (the client is never the authz boundary). Rows carry only the gated tool name(s) — never the tool arguments or any personal data. A delivery release (kind delivery_release) is never listed by these routes, and deciding its id here answers 404: it is decided only through /admin/v1/me/delivery-releases.

Each hold and its outcome (approval_awaiting, approval_approved, approval_rejected, approval_expired) is also recorded as an access decision with rule_id = the review id; see Access decisions.

Method Path Purpose
GET /admin/v1/review-items This tenant's reviews. ?status= (pending|awaiting_second|approved|denied|expired|closed|all) and ?kind= (tool_gate|flagged_prompt|flagged_output|all) filter — any other value, or a repeated or valueless parameter (?status=a&status=b), is rejected 400 (fail closed, never reaches the query). Returns { "items": [...] } ([] when none).
POST /admin/v1/review-items/{id}/approve Approve. Optional { "note": "<reviewer annotation>" } (a non-string or empty note is ignored; capped at 4096 characters).
POST /admin/v1/review-items/{id}/deny Deny. Optional { "note": "<reviewer annotation>" } (a non-string or empty note is ignored; capped at 4096 characters).

A review whose tenant or gateway no longer exists is not listed and not counted in /admin/v1/review-items and /admin/v1/me/tool-approvals (list and count). Reading, approving or denying it answers 404 { "error": "not found" }, exactly like an unknown id, and nothing is written. If the organisation is removed while a decision is being written, the answer is 404 { "error": "tenant_not_found" }. If the gateway is removed between the read and the decision, the answer is 404, not 409.

Each item that belongs to an agent also carries agent_purpose (the agent's current purpose text) and agent_purpose_status (its review status, e.g. confirmed or unconfirmed); both keys are absent when the agent has no purpose set, and — for review items only, since a review item can exist without an agent — when the item has no agent. Clients must show a purpose whose status is not confirmed as a suggestion. The delivery-approvals list (GET …/agent-approvals) carries the same two fields; an approval always has an agent, so there the fields are absent only when the agent has no purpose set.

Items of both lists (/admin/v1/review-items and /admin/v1/me/tool-approvals) also carry agent_external_platform: the platform of an external agent (for example copilot, claude_code, cursor), or null / absent for internal agents and items without an agent. It is display-only; clients show an unknown value as a generic "external agent" label.

Both lists also carry workflow_run_id (string) and workflow_name (string): they are set on a hold that belongs to a workflow run (a model-derived Fetch URL held for the workflow owner) and null on agent and proxy holds. workflow_name is "" when the workflow has no name.

The optional note (both decisions) is stored as review_item.decision_note — the reviewer annotation.

Who may decide a held tool call (tool_gate). EGRESS_APPROVE is necessary but not sufficient: the approver is the person whose credential the held call would use — the owner for the owner's own agent, the caller for a bridge call, the successor after an agent hand-over. That person is resolved once when the run is held and stored as approver_user_id on the item (visible in the list). The server enforces it twice: any other user — including a tenant admin — gets 403 { "error": "not_credential_holder" } (nothing is written), and the decision compare-and-swap itself binds the approver, so a concurrent request cannot slip past. A hold with no resolvable holder (a legacy row whose agent is gone, or whose holder was erased under Art. 17) cannot be decided by anyone and expires after the TTL (the tool is never called). The admin approve/deny route also refuses a tool_gate decision while impersonating (403 impersonation_forbidden): under impersonation the session user is the target, so an admin impersonating the holder cannot decide in the holder's name. flagged_prompt / flagged_output items are unaffected (any EGRESS_APPROVE holder decides).

Four-eyes (Approval by 2 people). A held tool call needs two people when its effective unattended level is approval_2 (the connector's tool permission policy, or the agent's own tightening). On a connector without a version-2 policy, the legacy four_eyes_required flag (PATCH /mcp/{id}/four-eyes, see MCP) still makes every hold on that connector need two people. The holder's approval is the first stage: the item moves to status awaiting_second (first_decided_by, first_decided_at and the first note are recorded) and the run stays suspended. A different user with GOVERNANCE_MANAGE then approves or denies, through the admin routes above (EGRESS_APPROVE) or /admin/v1/me/tool-approvals, which also lists the awaiting_second rows for a GOVERNANCE_MANAGE user. A deny at either stage is final. An awaiting_second item that nobody completes before the TTL expires and the tool is never called. The rule is fixed when the hold is created, so a later policy change does not alter holds already open.

Rejections of a decision on a four-eyes hold:

Status error When
403 not_credential_holder Stage 1: the caller is not the credential holder of the hold.
403 second_approver_role_required Stage 2: the caller does not hold GOVERNANCE_MANAGE.
403 second_approver_must_differ Stage 2: the caller is the first approver (or the first approver is no longer known).
409 already_decided The item is already decided, or another decision won the race.
409 expired An approve after the hold's TTL ran out.

A user who is not the credential holder and decides an awaiting_second item gets the stage-2 answers above (not not_credential_holder), so they learn the item's stage. This is intended: item ids are tenant-scoped (an id of another tenant is 404), and the stage tells a would-be second approver why the request was refused.

Both approvers are recorded. The first is stored on the item as first_decided_by and audited as review_item.first_approved. The final decider is stored as decided_by and appears as acting_user_id on the access decision record.

In the tenant view, approver_user_id, first_decided_by and decided_by can hold a label instead of a user id: erased for a removed account, or Myra staff stf_<16 hex> for Myra support staff (the names are then omitted). Treat these fields as display text only and never compare them with your own id. Each item carries two booleans computed by the server from the stored ids, is_holder (you are the credential holder) and is_first_decider (you gave the first approval); both are always present. The redaction rules are in Review item actors.

The holder's own queue. These routes need only an authenticated session (no EGRESS_APPROVE), are scoped to tool_gate items whose approver_user_id is the caller, and are refused (403) while impersonating:

Method Path Purpose
GET /admin/v1/me/tool-approvals My held tool calls. ?status= (pending|awaiting_second|approved|denied|expired|closed|all; any other value or a repeated parameter → 400). Returns { "items": [...] } ([] when none).
GET /admin/v1/me/tool-approvals/{id} One held tool call and its masked action preview (below).
GET /admin/v1/me/tool-approvals/count How many held tool calls await my decision right now (the actionable set of the list above: my pending holds, plus, with the governance permission, awaiting_second rows a different person approved first; expired holds are not counted). Returns { "count": N }. 401 without a session, refused under impersonation, 503 on a storage fault (never { "count": 0 }).
POST /admin/v1/me/tool-approvals/{id}/approve Approve. Optional { "note": "..." }.
POST /admin/v1/me/tool-approvals/{id}/deny Deny. Optional { "note": "..." }.

Detail and action preview. GET /admin/v1/me/tool-approvals/{id} returns { "item": {...}, "calls": [...], "preview": "available" | "unavailable" } for a hold the caller may decide (the credential holder; a governance holder (GOVERNANCE_MANAGE) also for the second stage of a four-eyes hold). Each call is { "tool", "connector_id", "connector_name", "args_masking", "args" }. args is the masked argument text from the hold's access decision record, so the approver sees what the access layer recorded, never a second copy of the raw arguments; it is null unless args_masking is masked or unmasked (withheld, unavailable, too_large, invalid_utf8 and erased carry no text). preview is unavailable when no record exists (calls is []) or no call has text. Render args and tool as plain text: they are model output. The item also carries run_schedule_id and run_trigger_id. Every item (list and detail) also carries agent_external_platform (copilot, copilot_studio, claude_code, cursor, custom, or null): the platform of an external agent, for display only. A hold raised through the MCP proxy has run_id: null and hold_reason: "approval_required"; the console marks it as an external-agent call. Treat an unknown agent_external_platform value as null. Errors: 400 an empty or over-64-character id, 401 no session user, 403 while impersonating, 404 for every miss (unknown id, another tenant, not a tool_gate, not yours; existence never leaks), 503 on a storage fault (never an empty preview).

An id longer than 64 characters → 400; an item that is not a tool_gate (or is another tenant's) → 404; the same 404 / 409 / 503 decision semantics as above apply.

Held model calls. A hold on a call to a model that searches the web on every call (hold_reason: "inherent_search") is a tool_gate item whose subject_ref is model:<model id> (for example model:perplexity/sonar) instead of a tool name. Treat the model: prefix as the marker for a model call: strip it to show the model id, and show the label as a model rather than a tool. The decision routes (approve, deny) are the same as for a tool call; the detail has calls with the model as tool when an access decision record exists.

Held tool calls

The list does not carry call arguments. The approver sees the exact call or calls being decided (the tool and its masked arguments, built-in tools such as fetch_url and web_search included) on the tool-approval detail, GET /admin/v1/me/tool-approvals/{id} (above): its calls list is read from the access-decision records written when the call was held, so the decision is made on what will be sent (for fetch_url the URL, for web_search the query). A built-in call has connector_id and connector_name null. A call whose connector required four-eyes approval when the call was held carries connector_four_eyes: true; otherwise the field is absent. The connectors are recorded with the hold, so turning a connector's four-eyes setting on or off afterwards does not change the answer. A hold created before this record existed answers with the connector's current setting instead. A call whose own tool policy asked for an approval when it was held (the connector's class or tool level, or the agent's tool settings) carries class_approval: approval_1 or approval_2, and class_approval_source: organisation (the connector's policy) or agent (the agent's tool settings). Both are absent for any other level, for example a call held only because the run handles untrusted input, and for a hold recorded without a level. They are also absent when the level is an approval but its approval rule did not hold the call: the level came only from the agent's safety constraint (that hold is named by its own hold reason), or the run had already lifted a "once per run" approval. The gateway records this with the hold; for a hold recorded before that record existed, the level alone decides, as before. A value outside these sets makes the client reject the detail. Because untrusted input wins the hold reason, an untrusted_egress hold uses class_approval to show that the call would have needed this approval anyway. For a call held inside a sub-agent, the list shows the sub-agent's own call. When no record can be read back, the detail answers preview: "unavailable" with no calls; that is never an error.

Chat approvals (hold_reason: "chat_approval", run_id and agent_id null): a chat call at Approval by someone else. Its approvers are the request's named users and, when the tool names "Organisation admins", every holder of the governance permission — never the asker. The personal list and count show it to them only; the item carries chat_asker_id, chat_asker_name (name, else e-mail), chat_conversation_title, chat_asking_text (the asking message, text only, at most 120 characters), chat_tool, chat_connector_name, chat_tool_class, and is_asker (true for the person who asked: never decidable). is_holder is true on the personal routes for a person who may decide it. The detail's calls is the one call with its masked arguments. Deciding: the asker gets 403 {"error": "own_request"} (also on the admin route), anyone else who may not decide 403 {"error": "not_approver"}; four-eyes does not apply. Approving runs the call as the asker under the current policy and access; rejecting or expiry posts the outcome into the chat.

Why the call was held. Every tool_gate item (the /admin/v1/me/tool-approvals list and detail, and /admin/v1/review-items) carries, next to hold_reason:

Field Values Meaning
trigger_kind email, webhook, form, schedule, manual (the workflow run's trigger), chat (a chat-bridge run), webhook / schedule (an agent trigger or schedule); absent otherwise What started the held run. An unknown stored trigger kind is absent, never echoed.
untrusted_origin email, webhook, form, chat, run_content (the workflow run's mid-run mark is set), workflow_connector, workflow_fetch; absent otherwise untrusted_egress holds only: where the untrusted content came from. Absent on such a hold means the origin is unknown (for example a run that marked itself by reading a tool result); the hold is untrusted either way.
run_workflow_run_id, run_workflow_name strings The workflow run (and its workflow's name) that owns the held agent run, for an agent step of a workflow.
trigger_name string, at most 120 characters Only on GET /admin/v1/me/tool-approvals/{id}, only when trigger_kind is webhook: the name of the webhook trigger that started the run (the workflow run's trigger for a workflow, else the agent run's trigger). Cleaned like email_from. Absent when the trigger was deleted, or for a workflow run fired before the gateway recorded its trigger.
hold_call_count, hold_tool, hold_connector_name, hold_target integer ≥ 1; strings, at most 120 characters Only on the personal list GET /admin/v1/me/tool-approvals (never the detail, never /admin/v1/review-items): how many calls the hold covers, and the first call's tool, connector name and its to argument. They come from the same access-decision records as the detail's calls (only the to argument is read; for a record without stored argument text, or a to that is not a single string, hold_target is absent). Cleaned like email_from. All four are absent when the hold has no such records; if the records cannot be read, the list still answers, without them. Never the email sender or subject, never another argument.
first_decided_by_name string Also on the lists now: the first approver's display name of a four-eyes hold, through the same staff-pseudonym rule as the detail.
email_from, email_subject strings, at most 120 characters Only on GET /admin/v1/me/tool-approvals/{id}, only for the credential holder (is_holder: true), and only for an untrusted_egress hold started by an inbound email: the sender and subject of that email. Control and format characters are removed, whitespace runs become one space, and a longer value is cut to 119 characters plus …. They are attacker-controlled: show them as plain text only. They are never in a list, never for a four-eyes second approver, never on /admin/v1/review-items, and never in the mail, the push, the chat message or the MCP error.

All of these are display-only and derived by the server from the hold's own rows (tenant-fenced joins); no request field sets them. A value of the wrong type is a malformed item for the client.

The count and the list can differ. The count only includes holds that can still be decided now: decided holds, and holds past their expires_at that the expiry sweep has not yet marked expired, are not counted, so the count can be smaller than the length of the ?status=pending list. The route takes no query input (any query string is ignored). It answers 401 without a session, 403 while impersonating, and 503 { "error": "temporarily unavailable; retry later" } on any storage fault.

The holder's own queue. The five /admin/v1/me/tool-approvals routes (list, count, detail, approve, deny) also serve a platform administrator (a session with no tenant) who is the credential holder of a hold. Such a caller sees, counts and decides only the tool_gate holds whose approver_user_id is themselves, across every live tenant; each follow-up read and write uses the tenant stored on the hold itself, never a value from the client. Rules:

  • A session without a tenant that is not a platform administrator, or a session whose tenant is malformed, gets 401. The agent_approval and /admin/v1/review-items routes keep their tenant-bound session requirement.
  • Another holder's hold, a hold of a deleted tenant, or an unknown id is 404; nothing about the hold is revealed and the row is not changed.
  • A platform administrator without a tenant is never a second approver of a four-eyes hold: deciding an awaiting_second hold gets 403 second_approver_must_differ. A platform administrator whose session has the hold's tenant holds GOVERNANCE_MANAGE and may give the second approval under the same stage-2 rules as any other user.

Hold notification. When a tool call is held for approval, the credential holder (the hold's approver_user_id) is told by mail (template approval-held, in the holder's locale, falling back to the tenant default; the link opens the approval card /approvals/tools/<review id>, also for a hold without an agent run) and by push. Rules:

  • Only the holder is notified; nothing from the call (arguments, user text) selects a recipient. A platform administrator who holds the credential is notified like any holder. The platform administrator then works the hold on the same /admin/v1/me/tool-approvals routes (see The holder's own queue above).
  • Delivery is at most once per hold, best-effort and off the request path: a mail relay or push failure, or a crash before delivery, loses the notification but never the hold. The hold stays in /admin/v1/me/tool-approvals and in the count.
  • Coalescing: a new hold sends no further mail or push when another hold of the same agent for the same holder is still undecided and unexpired and its notice was actually sent less than 15 minutes ago (the holder was just told). A hold that was never notified, or whose notice is 15 minutes old or older, does not suppress anything, so a stale hold cannot silence later holds and suppression cannot chain from hold to hold. The hold is still listed and counted. The send time is recorded just before delivery. A hold that was coalesced is never notified later, not even after the window ends or the coalescing hold is decided: the pending queue and the badge count are the durable surface. Two holds created at the same moment can each send a notice. A notice whose every channel failed still counts as sent for 15 minutes.
  • Nothing is sent when the hold is no longer pending by the time of delivery, when the hold has no approver, when the holder is deleted, disabled or belongs to another tenant, when the tenant is deleted, or when the holder is a test-fixture account (test-fixture accounts get neither mail nor push). A holder without a usable email still gets the push.
  • With four-eyes approval required, the mail adds one line saying that a second approver must also approve after the holder.

Second approver (four-eyes). When the holder's first approval moves a four-eyes hold to awaiting_second, every eligible second approver is told once, by mail (subject "Second approval needed", in their locale, linking to the in-app approval card /approvals/tools/<review id>) and by push (kind = "tool_approval", path = the same card). Eligible means: active, in the hold's tenant, holding GOVERNANCE_MANAGE (through a system role or a custom role of that tenant; an account with no system role at all qualifies through its custom role), and not the person who gave the first approval; each candidate is confirmed through the same permission resolver the decision route uses, and one whose check errors is skipped (fail closed). The mail names the tool, the request date and the hold's absolute deadline ("Due DD.MM.YYYY HH:MM UTC"; the first approval does not extend it), and the push reads "A tool call of <agent> was approved once and is waiting for your second approval". When no eligible approver exists no second-approval notice is sent; the hold stays decidable by anyone who later gains the governance permission and otherwise expires at its deadline (logged as a warning). At most 200 candidates are notified per hold. The same skip rules as for the holder apply (hold no longer awaiting_second or already past its deadline, deleted or disabled user, test-fixture account: test-fixture accounts get neither mail nor push; an approver without a usable email still gets the push; for stamping such an approver still counts as told), as does best-effort, at-most-once delivery off the request path. A recipient is not told again when another hold of the same agent is still awaiting its second approval, unexpired, and its second-stage notice was sent less than 15 minutes ago (the hold is still listed and counted; as for the holder stage, a coalesced hold is never notified later, two simultaneous holds can each notify, and a notice whose every channel failed still counts as sent for 15 minutes). The holder-stage notice does not count for the second stage, and a second-stage notice is only recorded when the whole candidate list was notified. The mail never contains the tool call's arguments. Each second approver additionally gets a chat direct message in every Slack or Mattermost workspace they are connected to (same recipients and rules as above, including the coalescing: a coalesced approver gets no DM either; see Approval DMs): it says the call was approved once and needs their second approval, and carries the deep link /approvals/tools/<review id> and a masked argument preview only.

The push payload is a flat map of strings: kind = "tool_approval", review_id, title, body (agent name and tool names, clamped to 200 characters each) and path (the approval card, /approvals/tools/<review_id>; always present). Tapping the notification in the iOS or Android app opens the held approval card (/approvals/tools/<review_id>) on the environment the app is signed in to (iOS cold start: prod). The app builds that address from review_id alone, and only when it is a lowercase UUID; the path field is never followed. A push without a valid review_id just opens the app. On Android the push uses its own "Approvals" notification channel.

Decision semantics (both): a POST-after-auth tenant-scoped compare-and-swap. A cross-tenant / unknown id → 404 (no existence leak). A second decision on an already-decided review → 409 already_decided; an approve after the approval window (ttl_seconds, default 7 d) lapsed → 409 expired (fail-closed — an approve can never beat the expiry sweep and run a tool that was never approved in time). A storage fault is never a 4xx: a failed read, or a decision that wrote nothing (a transient conflict) → 503 { "error": "temporarily unavailable; retry later" } — decide again; any other fault → 500 { "error": "internal error", "request_id": "<id>" } (the decision may or may not have landed — reload the item before deciding again). The decision is recorded in the audit trail as review_item.approved / review_item.denied. The decision and its audit row are committed together (one transaction): if the audit row cannot be written, nothing is decided — the review stays open, a retry is safe when the answer is the 503 (nothing was written, e.g. the row was busy for about 5 s), and any other fault is the sanitised 500. The same holds for agent_approval decisions (agent_approval.approved / .denied) and for both stages of a four-eyes decision.

The review_item table is a generic review queue (shared with the flagged-prompt / flagged-output moderation queue below): its run_id is nullable and un-foreign-keyed, so a review need not be tied to an agent run. The held tool-loop resume state lives on agent_run.suspend_state, not on the review row.

Review rows are decision evidence and are kept for 730 days, also after their gateway is deleted (a row of a deleted gateway is no longer listed and can no longer be decided); the retention rules are in Data retention.

Flagged-prompt / flagged-output moderation queue

The same inbox and decision API moderate guardrail-flagged interactions. When a guardrail detector's action is flag (observe-only — the request is not blocked; see Guardrails) on a top-level turn, the gateway records a review_item:

  • kind = flagged_prompt (a request-phase flag) or flagged_output (a response-phase flag); run_id is null (no agent run).
  • subject_ref = the interaction's trace reference (request_log.trace_id when the request is traced, else its request_id) — a display-only pointer. The prompt / output text and the detected entities are NEVER copied into the review row — a security reviewer correlates the subject_ref in the Request Logs view, which enforces its own access controls.
  • summary = the flag detector name(s) (admin-authored gateway config), never the matched content.

A security reviewer allows (approve), denies (deny), or annotates (note) each flagged interaction through the SAME /admin/v1/review-items decision API and inbox above (permission EGRESS_APPROVE; tenant-scoped; the same 404 / 409 / 503 semantics).

Scope + lifecycle:

  • Top-level turns only. Inner tool-loop / continuation legs, agent-as-tool delegated sub-agent legs, the scrub-preview draft path, and a count_tokens estimate (a local, non-egressing call a client issues right before the real completion) do not create moderation rows — no rows for un-sent drafts, internal fan-out, or duplicates of the completion. A top-level agent invoke (interactive or unattended scheduled) is moderated — a flagged unattended prompt/output is exactly what a reviewer wants.
  • One row per flagged top-level turn per phase (≤ 2 per turn); multiple flag detectors in a phase are joined into that row's summary.
  • Best-effort + fire-and-forget. The row is written from a background timer, so a moderation write never adds latency to the request and can never break it — the flag verdict already applied. A write failure is logged, not surfaced.
  • Retention. A still-pending flagged review moves to expired after a 30-day active window (it gates nothing, so nothing is failed on expiry — unlike a tool_gate). Terminal flagged rows (approved / denied / expired) are then pruned by the shared agent-history retention sweep.

Draft preview — run-as-self

POST /v1/{tenant}/{gateway}/agents/preview dry-runs an unsaved agent draft so the create/edit UI can show exactly how the agent will behave before it is saved. Like a sharee's /agents/{slug}/invoke (which runs as the caller), preview runs as the current user (the identity bound to the playground/personal token that calls it) — so it faithfully exercises the SAME server-side assembly a saved invoke uses (today's date, organization policy, instructions, web search, agentic fetch, MCP connector discovery, and knowledge-area/RAG binding) without needing a saved row.

The request body is an inline draft config and is treated as untrusted input, validated at the trust boundary against the caller's identity (fail closed):

Field Accepted Rejected → 400
model non-empty string (required) missing/empty/non-string
instructions string ≤ 40000 characters (code points; optional) non-string / invalid UTF-8 / more than 40000 characters → 400 invalid_request (the message names the cause)
provider optional pin: platform-managed (myra), a provider configured on this gateway, or one available via the managed pool (granted managed model / self-serve plan); absent → inferred from the model (see Provider availability) unknown provider; a provider that does not serve the model; a provider not available on this gateway; a present non-string value
max_tokens positive integer ≤ 200000 (optional; omit it for the default). Unlike the inference endpoints (/v1/chat/completions, /v1/messages), where null, 0 or an absent value means "use the provider default", a present agent / preview max_tokens must be at least 1 non-integer / numeric string such as "100" / ≤ 0 / too large → 400
max_steps 5, 10 or 20; absent or null = the gateway default of 25 tool rounds (see Step limit) any other value, a string ("10"), a non-integer, a boolean, an array or object → 400 invalid_max_steps
protection "protected", "masked" or "public"; absent or null = inherit the gateway's access tier (see Protection). The preview runs with the stricter of this value and the gateway's tier (it is not refused for the gateway floor or the pin: a model the value does not allow is refused when the preview calls it) any other value (another string, a different case, a number, a boolean, an array or object) → 400 invalid_protection
tool_config object with the known agent keys (web_search, agentic_fetch, sources_footer, mcp, mcp_allow, file, agents, approval, task_envelope) unknown key / malformed / oversized / a non-boolean web_search, file, agentic_fetch or sources_footer
tool_config.sources_footer boolean; absent = true (footer shown) any non-boolean ("false", 0, null, an object or array) → 400 tool_config.sources_footer must be a boolean
tool_config.mcp array of non-empty connector id strings the caller may use — in-tenant, and (if private) owned by the caller; at most 10 a foreign/private, cross-tenant, or non-existent connector; more than 10 connectors; a non-string element → 400 tool_config.mcp entries must be strings; an "" element → 400 tool_config.mcp entries must be non-empty strings; an object instead of an array → 400 tool_config.mcp must be an array of connector ids. On create and PATCH these refusals are {"error": "<message>"} with no code (the invalid_request envelope of this table is the draft preview's only)
tool_config.mcp_allow object mapping a connector id to an array of non-empty tool names (an empty array is fine) an entry that is not an array (an object, a string) → 400 tool_config.mcp_allow['<cid>'] must be an array of tool names; a non-string tool name → 400 tool_config.mcp_allow tool names must be strings; an "" tool name → 400 tool_config.mcp_allow tool names must be non-empty strings. On create and PATCH the body is {"error": "<message>"} with no code
tool_config.approval.ttl_seconds whole number of seconds, 300 (5 min) to 604800 (7 d); absent = 604800 (see Approval window) below 300, above 604800, a fraction, a string, a boolean, an array or object, or null → 400 tool_config.approval.ttl_seconds must be a whole number of seconds between 300 (5 min) and 604800 (7 d); on create and PATCH the body carries "code": "invalid_approval_ttl"
tool_config.task_envelope optional run-envelope template, see Task envelope template; absent or null = off any shape error, a connector not in tool_config.mcp, a duplicate binding
project_ids knowledge-area ids the caller can access (member/admin), in the gateway's tenant, ≤ 16 a foreign / inaccessible / cross-tenant / unknown / unshared area (404 {"error":{"code":"project_not_found","message":"Project not found or not accessible in this corpus."}}, the same body for every such id; not recorded as access.denied). A platform admin, who can see every project, naming another tenant's project gets 400 project is not in the gateway's tenant
input / messages a non-empty input string or a messages array neither present, or a malformed turn

Consent is enforced at run time. tool_config.mcp and tool_config.mcp_allow are the owner's consent for the agent's connector tools. A run is offered, and may call, only the tools that this consent and the connector's admin tool_policy both allow. A connector that is not in tool_config.mcp, a tool outside its mcp_allow entry, and a consent that is missing or malformed are all refused (nothing falls back to "all tools"). The check repeats against the agent's current configuration on every tool call, so removing a connector or tool takes effect on the running run's next call. The refusal reaches the model as an access_denied tool result and is counted in aig_access_decision_total with reason consent_missing or consent_tool_not_granted. A call by a paused agent (hand-over pending or paused by automatic protection) is refused first, with reason agent_paused. A refusal on a tool call is also stored as an access decision record (rule id consent:<reason>:<tool>), and an unattended run whose record cannot be written is refused with record_write_failed. A connector's admin argument rules can also refuse a call (reasons param_rule, param_schema_drift, param_rules_malformed), whatever the agent's consent says.

Task envelope (intent-bound runs)

A run can carry a server-stamped task envelope that narrows what its MCP calls may do. It is one more input of the single access decision and can only remove access, never add it. There is no client-supplied form: it is never read from a request header or request metadata. An unattended run is stamped from the agent's template and the trigger of the workflow run it belongs to (see Per-run derivation). Interactive runs are never stamped. A run started by an agent webhook trigger has no workflow trigger to derive from: its envelope is the static envelope the owner configured on that trigger (see Webhook-trigger envelope). With a required template and no configured envelope the run carries none and every connector call is refused with task_envelope_missing (the approval and outside-task holds never apply to such a call, not even under on_outside_task: "approval"; a tool on the agent's own gate list is not held either: a call the task envelope refuses is refused at once and never held for approval. In a held batch, a same-name sibling call the envelope refuses is shown to the reviewer and refused at execution).

{"v": 1, "connectors": {"<connector_id>": {"*": {"<arg>": ["<value>"]}, "<tool>": {"<arg>": ["<value>", "<value>"]}}}}
  • A connector that is not listed is out of scope for every MCP method, tools/list included. connectors: {} is valid and admits no connector at all (deny-all).
  • Each connector map is non-empty. With a "*" key every tool of the connector is in scope; without it only the listed tools are.
  • On tools/call the "*" bindings and the tool's own bindings both apply. Every bound argument must be present, be a string, and exactly equal one of the listed values. Numbers never match.
  • Discovery uses the same predicate: out-of-scope connectors are not probed and out-of-scope tools are not offered.

The parser is strict and fail-closed. These are all malformed: invalid JSON or a non-object, a raw string that is empty or longer than 16384 bytes, a missing or non-1 v, a missing connectors, any unknown top-level key, an empty tool map for a connector, arrays where objects are expected (or the reverse), empty or non-string keys or values, a present JSON null, and anything over the limits (32 connectors, 64 tools per connector, 16 bound arguments per tool, 1 to 64 values per argument, keys up to 128 bytes, values up to 512 bytes). A malformed envelope is never treated as "no limit".

Reason code Meaning
task_envelope_missing the run requires an envelope and none is present
task_envelope_malformed an envelope is present but fails the strict parse
outside_task connector, tool or bound argument is outside the envelope
approval_required an unattended agent call to a write or destructive connector tool that is not exempt (see Unattended write calls need approval)
untrusted_egress a write or destructive connector call, or a built-in fetch_url, agentic_fetch or web_search call, from a run that carries untrusted content (connector calls only when not fully pinned; see Untrusted content)

The decision record rule_id is task_envelope:<reason>[:<detail>]:<tool>; for outside_task the detail is connector, tool or arg:<name>. Argument values are never put in the rule_id.

When the agent's template sets on_outside_task: "approval", an outside_task call that can be held is held for the agent owner instead of denied (see Outside-task approval). The approved call is recorded as an allow whose rule_id is task_envelope:outside_task_approved:<review_id>. A call held for approval under the rule below is recorded as an allow with rule_id approval:approved:<review_id> once approved, and a refusal has rule_id approval:approval_required:<class>:<tool>.

A call the task envelope refuses (task_envelope_missing, task_envelope_malformed, or outside_task when the template does not escalate) is refused at once and never held for approval, even when the tool is on the agent's approval list: no approval is created and no approval mail is sent.

Step limit (per agent)

max_steps is an optional run setting of an agent: the maximum number of tool rounds of ONE turn. Accepted values are 5, 10 and 20. Absent or null means the gateway default of 25 rounds, which is also what every existing agent keeps. Anything else (including the string "10", 7, 25, 0, 10.5, a boolean, an array or an object) is refused with 400 invalid_max_steps, on create, on PATCH, and on the draft preview. PATCH with "max_steps": null clears it back to the default. It is set on create and edit like max_tokens, and it is not accepted on an external agent (run-only field, 400 external_agent_field_not_allowed).

  • Versioned. A change creates a new agent version like any other run setting, resets an approved agent to review in a tenant that requires review, and is restored with the version.
  • Visibility. Returned to the owner and editors. It is redacted from the sharee and catalog view like other run configuration. A clone made by a sharee does not carry it and runs with the default of 25.
  • What it bounds. The limit applies to ONE turn. When the Nth round has run, the turn ends with the existing max_rounds_reached notice (limit is the agent's value), and, on an interactive run, the user's Continue starts a fresh turn with a fresh budget (an unattended run's note makes no such promise). After the last round the existing no-tools synthesis may still make one final model call to write the answer. Under a per-agent limit the gateway does not compact the conversation and auto-continue, because that would grant a second budget.
  • Delegation. A delegated child agent runs with its own max_steps, not the parent's.
  • Clients. The agent editor and clone UI do not expose the field yet (frontend follow-up). Set it through the API.
The API channel switch (per agent)

api_enabled is a per-agent switch for the API channel: calls authenticated with a personal (user-bound) API token. It defaults to on for every existing and new agent. It is owner/admin policy, not run configuration: it is not versioned, a change creates no agent version and resets no approval. A clone or duplicate carries the source's value (an admin's "off" is not undone by duplicating the agent; the owner asks an admin).

Set it with PUT /admin/v1/gateways/{gw}/agents/{id}/api-access and the body {"enabled": true | false}. The body must be exactly that one key with a boolean value; a missing key, a string such as "true", a number, null, an array or an extra key is 400 invalid_request. Response: 200 {"enabled": <boolean>}. Only an admin or tenant admin of the agent's tenant may change it: an owner who is not an admin gets 403 forbidden; anyone who cannot see the agent (and an admin of another tenant) gets 404. Every change is audited as agent.api_access (actor, before, after).

Agent responses (list, get, create, update, restore, and the sharee / catalog views) carry no api_enabled field: the switch is read only from .../channels. Known limitation: an older personal token that carries BOTH the playground label and the playground scope stays exempt from the switch (it is indistinguishable from a playground session token).

Read it with GET /admin/v1/gateways/{gw}/agents/{id}/channels (audience: the agent's owner, a tenant admin, an admin; anyone else 404):

{
  "bridges": [
    { "platform": "slack", "enabled": true, "is_default": true,
      "connection_id": "...", "workspace_key": "...", "default_agent_name": "Invoice Reader" }
  ],
  "api": { "enabled": true, "can_change": false },
  "can_manage_bridges": false
}

bridges has one entry per chat-bridge connection on the agent's gateway, limited to the active chat platforms (a platform admin sees all). is_default is true when this agent is the connection's default agent. connection_id, workspace_key and default_agent_name are returned only to callers who may manage the chat bridge (can_manage_bridges: true); an owner without that permission sees platform, enabled and is_default only, never another agent's name. api.can_change is true for an admin / tenant admin of the agent's tenant. No credential is read.

What it blocks. With the switch off, a call made with a user-bound personal API token is refused with 403 agent_api_disabled before any model call, run or trace. No request header can change this classification. Not affected: the in-app Try it (the app's own token), schedules, webhooks, workflows, chat-bridge turns, delegated child agents, the MCP proxy and OAuth grants, and tenant service tokens (they carry no user). A non-owner still gets the 404 first (no oracle). The switch is checked before the spending limit, so an API-off agent answers agent_api_disabled even when its limit is reached; with the API on, an API call counts toward and is refused at the spending limit like every other run. A stored value that cannot be read as 1 or 0 is treated as off.

Monthly spending limit (per agent)

spend_cap_micros is an optional monthly spending limit of an agent, in micro-USD (1 000 000 = 1 USD). null (the default, and what every existing agent has) means no limit. It is owner policy, not run configuration: it is not versioned, a change does not create an agent version or reset an approval, and a clone or duplicate never carries it (the copy starts without a limit).

Set it with PUT /admin/v1/gateways/{gw}/agents/{id}/spend-cap and the body {"spend_cap_micros": <whole number from 1 to 1000000000000> | null} (null clears it). The body must have exactly that one key: {}, an extra key, 0, a negative or fractional number, a string, a boolean or a number above the maximum is 400 invalid_spend_cap (or 400 invalid_request for a wrong body shape).

Amount input. Applies to the agent's spending limit (spend_cap_micros, which the console shows in USD). The console's amount fields read what you type exactly; this is the console's input rule, not an API rule: the API takes JSON numbers. The console accepts plain digits with at most one decimal separator (50, 12.5, 12,5). It refuses, with a message under the field as you type and nothing sent: an ambiguous amount (10,000, 10.000), thousands grouping (1,234.50), more than six decimal places or 15 significant digits, anything that is not an amount (letters, currency symbols, exponents such as 1e3, signs) and an amount out of range. See Entering an amount.

The agent's owner, a tenant admin and an admin get 200 with the agent; anyone else gets 404. PATCH with a spend_cap_micros key (null included) is refused with 400 spend_cap_not_patchable. Every change is audited as agent.spend_cap_changed (before and after). A limit cannot be set while it could not be enforced: when the workspace has request logging disabled or a retention shorter than 31 days, the setter answers 409 agent_spend_cap_unenforceable.

What counts. The agent's spend in the current calendar month, read as the sum of the raw provider cost of its logged requests (request_log.cost_usd, not the marked-up or wallet amount). The month starts on the first day at 00:00 UTC, like every budget period. A delegated child agent's spend counts against the child's own limit, not the parent's. The sum is only read for an agent that has a limit set; an agent without one pays no extra query.

What happens.

  • Below 90% the agent runs normally.
  • From 90% the agent still runs and the response carries X-AIG-Agent-Spend-Warning: <whole percent>, on buffered and streamed invokes (a stream sets it on the headers it opens with). It is absent on a response whose headers were already committed earlier (a forced-buffered stream re-emitted after the run).
  • At 100% (spend at or above the limit) the run is refused with 403 agent_spend_cap_reached before any model call. The message names the owner's limit and carries no top-up or wallet wording: it is not a billing refusal.
  • Within a running turn the limit is re-judged between tool rounds. When this turn's own cost brings the month to the limit, the turn ends with the agent_spend_cap_reached stop note (see Inference). The round that is already running finishes first (including up to three length-cap continuations of its answer), so the month can end slightly above the limit.
  • A stored limit that is unusable (not a positive whole number of micro-dollars) is refused exactly like a reached limit: 403 agent_spend_cap_reached (and an error log), so a scheduler skips instead of retrying forever.
  • When the spend cannot be verified (the read fails, or the log source cannot back a limit) the run is refused with 503 agent_spend_unverified. The gateway fails closed: it never treats an unknown spend as zero.

Channels. The check sits in the one authorization sequence every agent run passes, after the pause gates and before the run-as-owner binding, so it covers Try it, schedules and run-now, webhooks, the API, the chat bridge, a delegated child agent (its own limit) and the MCP proxy. The scheduler treats 403 agent_spend_cap_reached as a skip: no failure strike, no failure notice. 503 agent_spend_unverified is also no strike and is retried on the next tick. The one-shot scheduled-task path, the final conversation delivery and the draft preview (no saved agent, so no limit) have no agent row and are not covered by an agent limit.

Per-owner read. GET /admin/v1/tenants/{tid}/agent-budgets?owner_id=<user id> lists the agents owned by one user that have a limit, with this month's spend, for the user's budget card. It needs the Manage tenant settings permission (otherwise 403) and access to the tenant (a tenant the caller cannot reach is 404, answered before the query is read). owner_id is required and must be a stored user id, 1 to 36 bytes of printable non-space ASCII (no spaces, control characters or non-ASCII); absent, empty, repeated or any other shape is 400 invalid_request, never "all owners". The response is {period_start, resets_at, agents, truncated?} (truncated: true when more than 500 rows matched; the first 500 are returned). Each row carries id, gateway_id, name, can_change_cap and spend_cap_usd; with spend figures also spent_usd, percent and level (warning from 90%, stopped at 100%). The server computes percent and level. A row whose stored limit is unusable carries cap_invalid: true; a row whose spend could not be read carries spend_unverified: true and no figures (an unusable limit wins over an unverified spend). A row is returned when the agent is yours (or you are an administrator or workspace administrator), or when it is shared to you and you hold the agents-review permission; the spend figures need ownership or the View per-user cost permission, otherwise those keys are absent. Amounts are raw provider cost in USD for the current calendar month in UTC, the same figure the limit is judged against. period_start and resets_at are unix seconds. can_change_cap is true only when the limit PUT would be accepted for the row: you own the agent (or are an administrator), you hold the agents-author permission and the Agents feature is on for the tenant. The route itself is not gated by agents_enabled. A failed read of any permission, of the feature flag or of the period answers 503 (retry), never a partial list.

Visibility. The limit is returned (as a number, or null when unset) to the agent's owner and to holders of the agents-review permission, in the single-agent response and the list. Other viewers, sharees and the catalog do not see the field at all.

Limits of the figure. The owner's own budget still applies on top of the agent limit. The sum can slightly undercount: requests written with skip_log (for example proxied tool calls) are not in the log, and the log is written asynchronously, so a request still being inserted is not yet counted. The limit is therefore a guard rail, not a to-the-cent meter. Clients: the user budget card lists an owner's limited agents and changes a limit in place; the agent editor itself does not expose the field.

Conversation starters (per agent)

starters is an optional list of conversation starters of an agent: short example prompts a client can offer as chips when a chat with the agent is empty. It is stored on the agent and is distinct from the connector-derived suggestion chips the web UI shows on the agent page (a frontend follow-up will show the stored starters there).

Rule Value
Shape a JSON array of strings; an empty array [] means none (and clears)
Count at most 12 items, otherwise 400 too_many_starters (formerly starters_too_many)
Length at most 120 characters per item (after trimming), otherwise 400 starter_too_long
Trimming leading and trailing ASCII whitespace is removed; the trimmed text is stored
Empty an empty, blank, or invisible-only item (for example only non-breaking spaces) is 400 starter_required (formerly starter_empty)
Plain text an item with a control character (including TAB and line feed, a starter is one line), an invisible, bidirectional-control or default-ignorable character (this includes the zero-width joiner, so a ZWJ emoji sequence is refused), or invalid UTF-8 is 400 invalid_starters (formerly starters_invalid)
Other not an array (null, string, number, object), a non-string item, or a duplicate item after trimming is 400 invalid_starters
Absent a body {} without the starters key is 400 starters_required

Nothing is stored when any item is refused. The message names the item, for example starters[3] must be at most 120 characters.

Set or clear. PUT /admin/v1/gateways/{gw}/agents/{id}/starters with the body {"starters": [...]} replaces the whole list and answers 200 with the agent. The body must be exactly that one key: an absent or non-object body or any other key is 400 invalid_request. The caller must be allowed to edit the agent (its owner, a tenant_admin of its tenant, or a platform admin); anyone else gets the same 404 as for a missing agent, and the body is only validated after that check. An external agent may carry starters as well. A list that cannot be encoded exactly answers 500 internal (agent starters could not be encoded) and nothing is stored or cleared; it is never treated as an empty list. POST …/agents refuses the same way.

Create. POST …/agents accepts the same starters value (absent = none). A null or an invalid value is refused with the codes above, also when the create is replayed after a four-eyes approval. A clone carries the starters only if the client sends them again in the create body (the clone dialog does not yet, a frontend follow-up).

Edit. PATCH …/agents/{id} does not accept starters: a body containing the key is 400 starters_not_patchable and nothing is written, so a client can never change them through the versioned path by accident. Use the PUT above.

  • Not versioned. Changing starters is presentation, not run configuration. It does not bump version, writes no version snapshot, does not reset an approved agent to review in a tenant that requires review, and is not four-eyes gated. It is audited as agent.starters_changed with the list before and after.
  • Last write wins. The PUT has no expected_version: two concurrent writers leave the later list.
  • Visibility. starters is returned on every agent response, including the view of a sharee and the catalog view (always an array, [] when none), because a client needs them to render the chips for a user who can run the agent.
  • Export. The tenant export carries agents[].starters in the JSON manifest (not in agents.csv).
Safety constraints (per agent)

Deprecated (see Tool permission policy): a body that carries constraints is answered with Deprecation: @1794268800 and Sunset: Mon, 01 Mar 2027 00:00:00 GMT.

constraints is an optional list of safety constraints of an agent: {"trigger", "action"} objects that tighten what the agent may do on its own.

Trigger Meaning Allowed actions
write a connector (MCP) tool of class write or destructive; an unclassified tool counts as destructive always_ask, ask_once_per_run, never
egress a built-in egress tool (fetch_url, agentic_fetch, web_search) or a connector write or destructive call always_ask, never
  • Floor, not override. Organisation rules always apply first. A constraint can only tighten them: an agent that is local-only (data residency) cannot carry an egress constraint of always_ask, because the organisation rule is never. Such a value is refused with 400 constraint_looser_than_org_rule, on create, PATCH and restore alike; the floor is checked against today's organisation rules.
  • Validation. At most 8 entries, each with exactly trigger and action (strings), one entry per trigger. A null, a non-array, an unknown field, trigger or action, an action not allowed for its trigger, or a repeated trigger is 400 invalid_constraints (malformed input; a well-formed value that is too loose is constraint_looser_than_org_rule, above). Nothing is stored when any entry is refused. An empty list or an absent field means no constraints.
  • Set. POST …/agents and PATCH …/agents/{id} accept constraints; PATCH with [] or null clears them. A clone carries them.
  • Versioned. Constraints are run configuration: a change bumps version, is stored in the agent version and is restorable, and goes through four-eyes approval where the agent edit does.
  • What happens at the call. never refuses the call (deny, reason agent_constraint). always_ask holds the call for review; ask_once_per_run holds the first write of a run and lets later writes of that run pass once one hold of the run was approved. A hold appears on the Reviews tab with hold_reason agent_constraint_write or agent_constraint_egress; approving lets that one call run, the other safeguards still apply. Both outcomes are recorded in the activity log (Access decisions) with rule_id agent_constraint:<trigger>:<action>:<tool>.
  • Where a hold is possible. Only where somebody can approve: a run attached to a stored run (scheduled, webhook, triggered and run-attached invokes), or a delegated sub-agent call whose parent run can be suspended (the hold suspends the parent run and appears on the parent's reviews). In the playground, on a plain API call with no run, on a delegated call that has no hold path, and on the MCP proxy there is nobody to approve, so always_ask and ask_once_per_run are refused with agent_constraint; never refuses everywhere. The proxy applies the constraints of the agent the token is bound to.
  • Resume. A resumed run uses the agent's current constraints, not the ones in force when the run was held: an edit made while a call waits for review applies on resume.
  • Unreadable value. A stored value that cannot be read is never treated as "no constraints": every gated call of that agent is refused (agent_constraint_malformed). The owner's agent read says so instead of answering a list: it carries constraints: null and constraints_unreadable: true (the field is absent otherwise). constraints: [] always means "no constraints". A version read (GET …/versions/{n}) presents that version's constraints the same way. Saving a new list (PATCH with constraints) replaces the unreadable value.
  • Export. The tenant export and the user self-export carry agents[].constraints in the JSON manifest (not in agents.csv); an unreadable stored value exports as [].
  • Clients. The agent page's Connections tab lists every entry (a select per trigger, remove, add); the Tools and files tab shows the write entry as a switch (off = never; on from never = always_ask; other entries are kept and sent unchanged). Where a bound knowledge area is local-only, the Connections tab disables egress always_ask (the server still decides: constraint_looser_than_org_rule). The editor sends constraints on PATCH only when the list changed, and never sends it when the read carried no constraints or a value it could not read; for constraints_unreadable the user may replace the value, starting from [{"trigger":"write","action":"never"},{"trigger":"egress","action":"never"}] (what the runs enforce meanwhile). The approvals screen shows the two new hold reasons as raw codes (frontend follow-up).
Protection (per agent)

protection says which models an agent may run on. It uses the names of the access tiers in the Agents section:

Value The agent may run on
protected internal models only: a model served by Myra's own infrastructure or by the organisation's own hardware behind the myra provider. Every external model is refused.
masked internal models, and external models only when the agent's gateway masks personal data in the request (an enabled PII masker - pii_protector, custom_pii or presidio with action scrub - that applies to the request, i.e. target request or both). Saving masked on a gateway that does not mask requests is refused (400 protection_needs_masking_gateway). If the gateway's request masker is switched off later, every external model is refused for the agent (it runs as protected); the request is never sent unmasked.
public every model the gateway serves (no extra restriction).
null (default) inherit: the gateway's access tier decides exactly as before; nothing extra is enforced. Existing agents are null.
  • Floor, not override. The gateway's access tier is a floor. Its tier is Protected (every configured provider is internal), else Masked (an enabled PII masker that applies to the request - the same check a masked agent's model calls use), else Public. An agent may tighten its tier, never loosen it: on a Protected gateway only protected is accepted, on a Masked gateway masked or protected, on a Public gateway protected or public. A looser value is refused with 400 protection_looser_than_gateway; masked on a gateway that does not mask requests is refused with 400 protection_needs_masking_gateway (no external model could ever run masked there; choose protected, or enable a PII masker on the request). Both are checked on create, PATCH and restore (a restore is checked against today's tier). If the tier cannot be read the save answers 503 (retry); nothing is stored.
  • Response-only masking. A gateway whose only enabled PII masker applies to the response (target: "response") does not mask what is sent to the model, so for protection its tier is Public: effective_protection of an inheriting agent is public, and masked cannot be saved there. The Agents section's access-tier badge still shows such a gateway as Masked (it counts every enabled masker, whatever its target).
  • Pinned model. An agent pinned to a model (its model, and so its provider) must be allowed to run on it: when the agent's effective protection (the stricter of its value and the gateway's tier) does not allow the pinned provider - for example protected with an external model - the save is refused with 400 protection_blocks_pinned_model on create, on a PATCH that sets protection or changes model / provider, and on restore. An agent without a model (Auto) and an agent whose protection is null are not affected. A PATCH that touches neither protection nor the model (a rename, for example) is not refused for this; such an agent's runs are still refused at run time.
  • Validation. A value other than the three strings or null (another string, a different case such as "Public", a number, a boolean, an array or an object) is 400 invalid_protection. PATCH without the field leaves it unchanged; PATCH with null clears it (inherit).
  • Versioned. Protection is run configuration: a change bumps version, is stored in the agent version and is restorable, goes through four-eyes approval where the agent edit does, and resets an approved agent to review in a tenant that requires review.
  • What the run enforces. Every model call of the run is checked before anything is sent, with the stricter of the agent's value and the gateway's current tier (a gateway that tightened after the save wins): the agent's own model, every fallback and failover target, every model call after a tool result, and internal calls such as the agentic-fetch summary model. A refused model is skipped: a permitted fallback still serves the turn; when no permitted model is left the request ends with 403 agent_protection_blocks_model (no retry, no model-error triage row; after a tool result the turn ends with that code, see Error codes). Each refused model call is recorded in the activity log (Access decisions) with reason agent_protection and rule_id agent_protection:<protection>:<provider>.
  • Every channel. The same check applies to the playground (Try it), API calls, scheduled runs, webhook triggers, workflows, the chat bridge, the draft preview and resumed runs; it reads the agent's current value on every run. A delegated sub-agent runs with the stricter of its own protection and the protection of the agent that delegated to it, so a protected agent's data never reaches an external model through a sub-agent. The MCP proxy runs no model, so protection does not change what it allows.
  • Unreadable value. A stored value that cannot be read is treated as protected, never as inherit; the agent read shows protected for it. If the gateway's tier cannot be read when a run starts, a masked or public agent runs as protected for that run.
  • Read. The owner's agent read (GET, list, create, update and restore responses) carries protection (the value or null), protection_floor (the gateway's access tier as a protection value - protected, masked or public; a save may carry protected or exactly this value, every other value is refused as described under Floor, not override; null for an external agent and when the gateway's tier cannot be read, then the save alone decides) and effective_protection (protected, masked or public: what a run applies, also when protection is null; a masked agent whose gateway no longer masks requests reads protected, because that is what its runs apply). A sharee or catalog viewer gets effective_protection only (no protection, no protection_floor) (the Protection fact is shown to everyone who can see the agent); protection itself is owner configuration. effective_protection is null for an external agent (it never runs on the gateway) and when the gateway's tier cannot be read. A version read (GET …/versions/{n}) carries that version's protection.
  • Export. The tenant export (JSON manifest and agents.csv) and the user self-export carry agents[].protection (null = inherit; an unreadable stored value exports as protected).
  • Clients. The agent page's Connections tab has a Protection select (null = "Same as the access tier"); values the protection_floor does not allow are disabled, and the four save refusals are shown at the field. Changing the value to public asks the user first ("Send to an external provider?": the safer level - masked where protection_floor is masked, else protected - Public, or cancel; a safer level equal to the stored value sends no protection and no PATCH at all unless another field changed); the API itself asks nothing. Duplicate sends the source's protection (a sharee's read has none: the source's effective_protection when it is protected or masked) only when the target gateway allows it as the client can tell from the gateway list (a masking gateway counts as protected, since the list cannot show whether it masks requests), else protected; after a 400 protection_looser_than_gateway / protection_needs_masking_gateway / invalid_protection on create, the retry sends protected. The Overview's Protection fact shows effective_protection.
  • Not to be confused with automatic protection (protection_paused_at), which pauses an agent on suspicious activity.
Task envelope template (per agent)

The agent owner declares in tool_config.task_envelope how a triggered run's envelope is built: which trigger field binds which connector, tool and argument. The template is validated when the agent is created or updated (including draft previews and replayed approvals). It is stored with the agent's versioned tool_config, and is visible to the owner and admins only (shared agents omit it). It is applied to unattended runs, see Per-run derivation.

"task_envelope": {
  "v": 1,
  "required": true,
  "bindings": [
    { "connector": "<connector id>", "tool": "*" },
    { "connector": "<connector id>", "tool": "update_case", "arg": "case_id",
      "source": { "field": "subject", "extract": "digits", "prefix": "Case ", "min_digits": 6, "max_digits": 12 } },
    { "connector": "<connector id 2>", "tool": "send_reply", "arg": "to",
      "source": { "field": "from", "extract": "email_address" } }
  ]
}
Key Rule
v the integer 1
required boolean. true = a run whose envelope cannot be derived has every connector call refused with task_envelope_missing; false = it proceeds without an envelope
bindings array of 0 to 32 entries (an empty array is valid)
on_outside_task optional, "block" (default) or "approval". block refuses an outside_task call. approval holds it for the agent owner where a hold is possible (see Outside-task approval). Any other value, including null, is rejected
bindings[].connector non-empty string up to 128 bytes, and it must be listed in the same body's tool_config.mcp: the template can only narrow what the agent already has consent for
bindings[].tool "*" or a tool name (non-empty, up to 128 bytes). Naming a tool scopes the connector to the named tools
bindings[].arg and bindings[].source given together or both omitted. Both omitted is a scope-only entry (the connector and tool are in scope with no argument constraint)
source.field non-empty string up to 64 bytes: a top-level key of the trigger input. Email triggers carry the string fields from, subject, date and body. A field that is not a string (for example attachments, or a nested webhook or form value) yields no value, so the argument has no allowed value and derivation fails, which is refused when required is true
source.extract one of whole (the field's string value, trimmed; a value containing a control byte other than TAB, line feed or carriage return, such as NUL, ESC, VT, FF or DEL, yields no value), email_address (the address inside a From-style header), digits (see below). No regular expressions are accepted
digits options prefix (string, 0 to 32 bytes, optional, must not end in a digit) immediately followed by a run of ASCII digits whose length is between min_digits and max_digits (integers, 1 <= min_digits <= max_digits <= 32). whole and email_address accept no further keys

A template saved by an earlier version whose prefix ends in a digit is refused when the run starts (it fails validation like any invalid stored template, so every connector call is refused: fail closed). Re-save the agent with a prefix that does not end in a digit.

required: false with bindings: [] derives no envelope (no_bindings), so the run is unrestricted; use required: true when a run must never proceed without an envelope.

A derived envelope is subject to the normal envelope caps (at most 64 values per argument, at most 512 bytes per value), so whole of a long field fails derivation instead of being truncated.

Rejected with 400 and a message starting tool_config.task_envelope:: a value that is not an object; an unknown key at any level; v other than the number 1 (1.0 is the same JSON number; 1.0000000000000002 is not 1 and is rejected); required that is not a boolean; bindings that is not an array or has more than 32 entries; a binding that is not an object; a missing, empty or over-long connector or tool; a connector that is not in tool_config.mcp (connector <id> not consented), or a malformed tool_config.mcp (consent malformed); arg without source or the reverse; an unknown extract; extra keys on whole or email_address; min_digits or max_digits that is not an integer in range, or min_digits greater than max_digits; a prefix that is not a string of at most 32 bytes or that ends in an ASCII digit (it would be ambiguous where the digit run starts); and a duplicate binding for the same connector, tool and arg (or a duplicate scope-only entry). {"tool": "*", "arg": "x"} and {"tool": "t", "arg": "x"} on one connector are two different bindings, not a duplicate.

When a connector leaves the agent's consent, its bindings are removed from the template in the same step (an explicit revoke, or the automatic drop of a connector that was deleted), so the stored template never names a connector the agent no longer has. If the last binding goes, bindings becomes [].

Per-run derivation

When an agent has a template and the run is unattended (X-AIG-Unattended: 1), the gateway builds the run's envelope from the trigger of the workflow run it belongs to. The workflow runner sends that run's id in X-AIG-Workflow-Run-Id on every agent step.

  • The header is only a pointer. The envelope content is read from the stored trigger input of that run, never from the request. The run is looked up by id, tenant and gateway, and only while its status is running; any other run (finished, foreign gateway, unknown id) counts as having no trigger.
  • The value must be 1 to 64 characters of letters, digits, _ or -. A present but malformed value (empty, too long, other characters, or repeated) is refused with 400 invalid_request and nothing runs, whether or not the agent has a template. A bridge token that sends it is refused like any other bridge-driver mixing.
  • Every binding's source.field must give a value from the trigger input. The result becomes the run's envelope, and required carries over. A trigger input that is missing, empty, not an object or not valid JSON gives no value.
  • When the envelope cannot be derived (no trigger, an unusable trigger input, or a binding without a value): required: true leaves the run with every connector call refused as task_envelope_missing; required: false runs without an envelope.
  • A template stored with an invalid shape is treated as required: true with no envelope, so every connector call is refused, and a warning is logged.
  • A run that carries an envelope may delegate to sub-agents. The envelope is committed to in the run's signed principal token (a sha256 of the envelope plus the required flag; the envelope itself is not in the token), and a delegated sub-agent takes its envelope only from its verified parent: the same envelope, never a wider one and never one the sub-agent's own configuration sets. A sub-agent whose parent token is missing or invalid, or whose copied envelope does not match the token's commitment, fails closed: every connector call is refused. A sub-agent call that waited for human approval and resumed gets its parent token re-minted from the claims persisted when the run was held (the tool allowlist, the envelope commitment and the delegation depth; never the token itself, which would have expired during the wait), so it runs with the scope the run had when it was held. The re-minted token is at most as wide as the original: it is not widened by later configuration changes, and it is not narrowed by them either. The sub-agent is re-authorised live on resume (same owner, enabled, not paused), its own tools are re-resolved live and intersected with the persisted allowlist, and connector calls keep the access layer's live revocation check. A hold persisted before this behaviour, claims that fail validation, an envelope that no longer matches the committed hash, or a mint failure leave the sub-agent with no parent token, and it fails closed as before. A bridge resume carries no task envelope, so a held sub-agent call under an envelope gets scope only on scheduled, webhook and workflow resumes.
  • The trace records a task_envelope step with the outcome (stamped, none or invalid_template) and the trigger kind, never the values.
  • If the trigger cannot be read because of a datastore fault, the response is 500 INTERNAL and nothing runs.
Webhook-trigger envelope

A run started by an agent webhook trigger has no workflow run to derive an envelope from. Instead the owner sets a static task envelope on the trigger (task_envelope on create or PATCH, same shape as the envelope in the table above: {"v":1,"connectors":{"<connector id>":{"*" or "<tool>":{"<arg>":["<allowed value>", ...]}}}}). The gateway stores it with the trigger and stamps every run of that trigger with it.

  • The request body never defines the scope. The webhook payload, its headers and any task_envelope or connectors keys inside it are ignored for scoping; only the stored envelope counts.
  • When it applies. A configured trigger envelope always applies to the run, whether or not the agent has a task envelope template and whether or not that template is required. The run fails closed (required: true, no envelope, every connector call refused) when the trigger row is missing or belongs to another agent, when the stored value is corrupt (an empty string counts as corrupt), and when no envelope is configured on the trigger but the agent's template is required.
  • Absent is not the same as invalid. A trigger with no envelope behaves as before: a required template leaves the run with every connector call refused as task_envelope_missing, a non-required template runs unrestricted. A stored value that no longer parses (or a trigger row that cannot be matched to the agent) is treated as required: true with no envelope, so every connector call is refused.
  • Escalation follows the template. A call outside the configured scope is refused as outside_task, or held for approval when the agent's template sets on_outside_task: "approval".
  • It only narrows. The envelope never grants a connector the agent is not connected to; such a connector stays unusable.
  • Resume keeps the envelope. A run held for approval and resumed uses the envelope it was stamped with; editing or deleting the trigger afterwards does not change a run that is already held. A resume of a webhook-fired run never reads the trigger; a run that had no envelope when it was held stays without one.
  • The envelope is validated like a template-derived one (at most 16 KiB, bounded connectors, tools, arguments and values; an array, a JSON-text string or an unknown version is 400 invalid_task_envelope; the 400 carries a closed-list reason and an optional path of names, never values — see Why an envelope is rejected).

Consequences to plan for:

  • Schedule-driven runs and direct service-token calls do not carry X-AIG-Workflow-Run-Id. An agent with required: true therefore has every connector call refused with task_envelope_missing on those paths. Use required: false for agents that also run outside a workflow.
  • A form trigger's input holds the raw uploaded-file references. A whole binding on an upload field binds that reference string, not the file content.
Outside-task approval

With on_outside_task: "approval", a call the envelope refuses as outside_task is held like any other approval-gated tool call: the run is suspended, a review item of kind tool_gate is created for the agent owner, and the call runs only if the owner approves it. The review item has hold_reason: "outside_task" ("approval_required" for a hold under the unattended-write rule below, "untrusted_egress" for a hold under the untrusted-content rule, null for an ordinary approval hold); this is for display and triage only.

  • Where it holds. Only on runs that are attached to a run (X-AIG-Run-Id): unattended runs and chat-bridge turns. That includes workflow Agent steps on runs started by a webhook, form, manual or schedule trigger; the workflow run is suspended while the review is pending and resumes when it is decided. Everywhere else approval behaves as block and the call is refused as outside_task: workflow Agent steps inside a Loop body, delegated child agents, interactive calls that are not chat-bridge turns, and calls without a run (an unattended service-token call without X-AIG-Run-Id is given one). The setting never widens what runs.
  • Email-triggered workflow runs. Runs started by an inbound email carry untrusted content. Such a run keeps its full tool set; the server-derived mark (from the workflow run) is what constrains it. The built-in fetch_url, agentic_fetch and web_search tools are held (see Built-in egress tools), connector writes get the untrusted_egress or approval_required hold (the untrusted_egress hold is skipped only when every argument is pinned by the task envelope or a one_of parameter rule; see Untrusted content), and the outside_task hold applies as for any other trigger. A read connector tool still runs unattended with the arguments the model chooses unless an envelope or parameter rule binds them.
  • What an approval waives. Only the outside_task verdict, for that one held call, once. The connector's tool policy, parameter rules and consent still apply to the approved call and can still deny it.
  • Batches. The hold is by tool name. A call to the same tool in the same model turn that is inside the envelope is held together with it: approve runs both, reject or expiry denies both.
  • Reject or expiry denies the call; it never runs.
  • Template, not stored state. The setting is read from the agent's current template when the run starts and when it resumes. Changing it to block while a hold is pending makes the resumed call refused again.
  • Resume uses the suspended envelope. A held run resumes with the envelope it was suspended under. Narrowing the template while the hold is pending does not narrow the restored envelope; only on_outside_task follows the live template.
Unattended write calls need approval

The holder's mail says why the call waits ("Why: Unattended run wants to write to <connector>."); for untrusted_egress it shows a warning instead (see Untrusted content holds). The tool-approval items carry trigger_kind (see Held tool calls).

An agent that runs unattended (scheduled runs, triggers, service-token calls) does not run a write or destructive connector tool on its own. The call is held for the person whose credential the run uses, the credential holder, through the same approval gate as any other gated tool call: the run is suspended, a review item of kind tool_gate with hold_reason: "approval_required" is created for the holder, and the call runs only if the holder approves it, once. Reject or expiry denies the call; it never runs.

  • Which calls. MCP connector tools/call made by an agent that is not interactive, where the tool's class is write or destructive. A tool with no class is treated as destructive. read tools are never held.
  • Exempt. Tools the agent's grandfathered consent covers keep running unattended. If the snapshot cannot be read, nothing is treated as exempt.
  • Hold or refuse. The call is held only where a hold is possible: an unattended run attached to a run (X-AIG-Run-Id). A chat-bridge turn is run-attached and is held for the asking driver. A run started by an agent webhook trigger is run-attached too and is held for the agent owner (the credential holder). A write call made by a delegated sub-agent (one level deep) is held too: the whole run suspends, with one review item for the parent run that shows the sub-agent's call (subject agent__<slug> > <tools>, at most 128 characters), and the sub-agent resumes on approval. A runless API-token call (a user-bound token of the agent owner, or a service token with or without X-AIG-Unattended) is given a run and held the same way (see unattended calls without a run id). Everywhere else it is refused with reason approval_required: calls made through the MCP proxy, playground and OAuth-grant tokens, workflow-runner steps without a run id, fan-out delegation, delegation deeper than one level, and a sub-agent of a parent that has no run. What happens to a held webhook run depends on the outcome:

    • Approved: the call runs once and the run continues to completion.
    • Rejected: the call is not executed, the denial is injected into the run, the run continues and finishes succeeded.
    • Expired: the call is not executed, the run is marked failed (error: approval expired: no decision within the approval window (counts as rejected), marker approval_expired, never paged as a server error) and the owner is notified. Only chat-bridge runs continue after an expiry.

    A webhook run to a direct agent carries the untrusted-content mark and, when the agent has a required task envelope template, is stamped only from the static envelope configured on the trigger; the webhook body is never read as a trigger. With no envelope configured every connector call is refused with task_envelope_missing (the approval and outside-task holds never apply to such a call, not even under on_outside_task: "approval"; a tool on the agent's own gate list is not held either: a call the task envelope refuses is refused at once and never held for approval. In a held batch, a same-name sibling call the envelope refuses is shown to the reviewer and refused at execution). A call that is held is always one the task envelope would otherwise admit; an outside_task call that is held under on_outside_task: "approval" carries hold_reason: "outside_task", which wins when both apply to the same batch (outside_task over untrusted_egress over approval_required).

  • Unaffected. Interactive use (the playground and chat) follows the interactive column of the tool permission policy instead (never held). Sub-agents, workflow Connector nodes and user API calls without an agent are not covered by this rule; built-in tools only through the agent's own tightening.

  • What an approval waives. Only this rule, for that one call. Tool policy, parameter rules and consent still apply to the approved call.
  • Reclassified while held. The call is re-checked at execution: a tool reclassified from read to write/destructive while held is refused (a write-to-read change simply runs).
Untrusted content holds

The tool-approval list and detail say where the untrusted content of such a hold came from (untrusted_origin) and what started the run (trigger_kind); the credential holder's detail also carries the sender and subject of the email that started it (email_from, email_subject). See Held tool calls for who gets which field. The approval card asks the approver to confirm that they checked the content and the target before Approve is enabled; that confirmation is a client-side step, and the approve route takes no extra parameter.

A run started from content an outsider controls carries a server-derived untrusted-content mark. Marked runs are: every agent run started by a webhook trigger (the payload is third-party content), every workflow run started by a webhook, a form submission or an inbound email, a chat-bridge turn for a foreign caller (see Who approves a foreign-caller turn), and runs that read third-party tool results (below). That includes the run the gateway creates for an unattended call without a run id: it starts unmarked and is marked as soon as it reads such a result. Schedule and manual runs are not marked by their trigger. A trigger that cannot be read, or an unknown trigger kind, is treated as strict. A webhook or form source has level snapshot; an email source, or a webhook trigger created with no_egress: true, is strict. The mark is set by the server from the workflow run, or from the agent run's trigger record, never by a request field, it cannot be cleared by the agent, and a delegated child agent inherits it.

On a marked run, a write or destructive connector tool call that the grandfathered consent covers is no longer exempt: it is held for the credential holder exactly like the unattended-write rule above, with hold_reason: "untrusted_egress", and it is recorded and waived the same way (approval_awaiting, then allow with rule_id approval:approved:<review_id>). A refusal where no hold is possible has reason untrusted_egress. A write or destructive tool that is not grandfathered, which its approval level holds anyway (approval_1 / approval_2, a tool entry, or the agent's tool settings), is held with hold_reason: "untrusted_egress" too (rule approval:untrusted_egress:<class>:<tool>): the run's untrusted input is the reason shown, and the approval level is kept (four-eyes still needs two approvers; the detail's class_approval names it). The same applies to a built-in egress tool that the agent's tool settings hold. On a marked run, "once per run" in the agent's tool settings does not release such a write after the run's first approval: once the run's approval has lifted it, the write is treated like a write the organisation lets run unattended (allow), so the mark holds it again as untrusted_egress (unless every argument is pinned, or a grandfathered agent's exemption applies). The same is true when the only thing holding a write was the agent's own ask_once_per_run safety constraint and the run's first approval lifted it: on a marked run the next write is held as untrusted_egress (before, it ran without a hold). Built-in egress tools follow the same rule. Approving an untrusted_egress hold covers the call's approval level only when that approval held the call when the hold opened (an outside_task hold covers the call's approval level as before): approving a hold made only because of the untrusted input does not cover an approval the organisation or the agent's tool settings added after the hold opened. The call is then refused when it would run (reason untrusted_egress for a connector tool, approval_not_held for a built-in tool), and the run has to ask again. A hold whose tool policy could not be read when it opened needs two people, and their approval also covers the call's approval level. Apart from that, which calls are held does not change. read tools are never held by the mark; a read that its approval level holds keeps approval_required, and so does the unverified-MCP-clients agent.

  • Fully pinned calls run. A call is not held when its arguments are a non-empty object and every argument is pinned: bound to the task by a task envelope binding, or restricted by a one_of parameter rule. prefix, suffix, pattern, none_of, not_contains and range rules do not pin an argument.
  • Unattached runs. Without a run to suspend the call is refused, not held. A runless API-token call gets a run automatically, so this applies to MCP-proxy agent calls, playground and OAuth-grant tokens and workflow-runner steps without a run id.
  • Waiver. An approval waives only this rule, for that one call, once.
  • Workflow runs learn it too. When an attached agent step of a workflow run reads third-party tool results (for example a fetched page), the run is marked as well, even if its trigger was a schedule or manual start: the later Fetch, Connector, Deliver and agent steps of that run are treated like a webhook or form run, see tainted runs.
  • Survives a hold. The mark is stored with a suspended run, so a run that was held and then resumed stays marked even if the resume request carries no workflow information. A stored mark can only add the mark, never remove it.
  • Workflow Connector nodes. A workflow Connector node on an email, webhook or form run (or otherwise untrusted-trigger run) is held for the workflow owner when a model wrote its arguments; arguments fixed by the workflow author run unattended. A Connector node cannot be placed in a loop body (loop_body_side_effect, rejected at publish and at run-claim); a call on a run without an owner is refused on every tainted run (email, webhook and form), never held.
Built-in egress tools

On a marked run the built-in tools that send data out to an address the model chooses are held the same way: fetch_url, agentic_fetch and web_search. The call is held for the credential holder with hold_reason: "untrusted_egress" and a decision record per stage: approval_awaiting carries the review id as rule_id, the approved call is recorded as allow with rule_id approval:approved:<review_id>, and a call refused at execution (no hold possible, or no matching approval) is recorded as a denial with rule_id untrusted_egress; the tool name is in the record's tool. Nothing is fetched or searched until the holder approves, and a rejection or expiry returns the model a short note that the call was held and nothing was sent.

  • What is covered, and why. These three tools carry model-chosen text (a URL or a query) to a third party, which is the exfiltration path an outsider's content can steer. Tools that only read from the platform (knowledge, documents, the agent's own connectors, which have their own rules above) are not in this set.
  • Exact call shown. The approver sees the call that will actually be sent (the URL to be fetched, the query to be searched), with its masked arguments, on the tool-approval detail; see held tool calls.
  • Per page. Approval covers that one call. Reading another page of the same document (a different pages range) or another URL is a new call and needs its own approval.
  • Waiver. An approval waives only this rule, for that one call, once. It is bound to the held call, so a different call in the same turn is still held.
  • Unattached runs. Without a run to suspend the call is refused with reason untrusted_egress, not held (the same callers as above; an unattended service-token call gets a run and is held).
  • Delegated child agents. A child agent inherits the mark. Its fetch_url, agentic_fetch or web_search call is held on the parent run with one review (the parent suspends, and approving resumes the sub-agent so the call runs once). A child that cannot be held there (several sub-agents in one round, depth beyond one, a parent without a run) is refused with reason untrusted_egress; see agent-as-tool delegation.
  • Search on a marked run. The search the gateway runs on the model's behalf before the model answers is skipped, so no query leaves unreviewed; the model can still ask for web_search, which is held. For Google Gemini and Vertex, whose search is built into the model call, the native Google Search grounding is held for approval on an agent run (the review item has hold_reason: "native_grounding" and subject_ref model:<id>; a rejection or expiry ends the run with native_grounding_rejected; the hold is never offered when the gateway is set to an EU search provider or EU residency is enforced, because the gateway then runs its own two-leg search), and is switched off (fail closed) where no run can hold it. Models whose search is inherent to the model itself (they search on every call) are routed to a non-searching sibling, have their search switched off, are held for approval (agent runs; the review item has hold_reason: "inherent_search" and subject_ref model:<id>; a rejection or expiry ends the run with inherent_search_rejected), or are refused with inherent_search_blocked; see models that always search the web.
  • Out of scope. Auto-loading media in the rendered answer is neutralised (see Delivered answers on a tainted run); data leaving through a link the reader clicks, link unfurlers and mail-scanner prefetch are not covered.
Tool results mark the rest of a run

A run that starts clean is marked as soon as one of its tool calls returns third-party content. This applies to unattended agent runs (a run id is attached, or the run is a delegated child) and not to interactive chat or chat-bridge turns. An unattended service-token /invoke call without a run is given a run of its own and is marked the same way (see unattended calls without a run id). A tool result marks the run unless the tool is one of the platform's own stores or fixed-text tools: search_knowledge, read_file, search_connector_tools, write_file, generate_image and remove_background. search_knowledge and read_file are the exception to that exception: they mark the run when a result comes from knowledge that did not originate with a person on your team (see the knowledge bullet below). Everything else marks it: fetch_url, agentic_fetch, web_search, code_interpreter, edit_file, convert_document, edit_office_file, create_video, every connector tool, a delegated child agent's answer, and any error or "held" note. A call that was refused and never ran returns no content and does not mark the run.

  • Applies from the next batch. The calls of one model turn run together under the state the turn started with. The mark takes effect for the next batch, so a page fetched in one turn does not hold the other calls of that same turn, but the follow-up fetch to an address the page names is held (hold_reason: "untrusted_egress").
  • Knowledge from outside sources. search_knowledge and read_file mark the run when any returned document did not come from a person on your team (connector syncs, connected web sources, and content written by an agent or tool), because that text was not written by your team. Memories the model proposed record their origin too, but they are never placed into agent runs, so they cannot mark a run. Files a person uploaded into the project do not mark it. If the origin of a document cannot be determined, it is treated as outside (fail closed). The mark has the level snapshot like any tool-result mark, so the follow-up fetch_url, agentic_fetch or web_search call is held. See synced knowledge in projects.
  • Grandfathered agents. A mark that comes from a tool result has the level snapshot: a grandfathered agent keeps the tools its consent snapshot granted (decision rule grandfathered:untrusted_egress:builtin:<tool>), every other agent is held.
  • Search stays consistent within a request. Whether the gateway-run search or the model's built-in search is used is fixed at the start of a request. A mark set during the request does not switch it; the next request of the run (for example after an approval) uses the gateway search, and an Anthropic search already performed is passed back to the model as plain text.
  • Chat-bridge turns. A chat-bridge turn that carries text no mapped user wrote (or replays such a message that is still inside the replay window; the marking ends at most about two replay windows after the last such message) also has the level snapshot; the asking colleague decides the hold. See Content nobody on the team wrote.
  • Web drawer replies. A web-drawer turn in a conversation whose replay window still holds a flagged chat-bridge message is not restricted, but the assistant reply it stores is marked, so the marking carries on into later chat-bridge turns (see Content nobody on the team wrote).
  • Delegated children. A child agent's tool results mark the parent too, including when the child failed or was interrupted.
  • Earlier searches on a resumed marked run. When a run that is already marked is resumed, the model's built-in search is not offered, so a search the model made earlier is replayed as one text block instead of as search blocks. That text comes from a third-party search provider, so it is wrapped in the untrusted-content frame ([Untrusted web search: ...]), which the model treats as data, not as its own words. At most 10 results and 10 queries are kept; a title is cut at 200 bytes, a URL at 500 and a query at 200 (never in the middle of a character). Line breaks and control characters become a space, and [, ], < and > inside a field become parentheses.
Search on a marked run

A search the model runs with its provider's own built-in search also marks the run, at the same level as a tool result (snapshot). This covers Anthropic's server-side web_search, the OpenRouter web plugin, Gemini grounding, OpenAI web_search_options and the Mistral agents search. The result of such a search is third-party content, and the model can answer it with a fetch_url to an address that content names, so that follow-up is held like any other built-in egress call, including when it is in the same turn as the search (hold_reason: "untrusted_egress").

  • Only when a search ran or may have run. For Anthropic, streaming or not, the gateway reads the response: a web_search tool use or search result block marks the run, and a response where the model chose not to search (neither of those and only block kinds the gateway knows) does not. For Google Gemini and Vertex the gateway reads the grounding metadata: a response that carries grounding queries or sources marks the run, and a complete response that finished normally (STOP) with no grounding metadata does not. Where the gateway cannot tell (a block kind or metadata it does not recognise, a response it could not read to the end, one that stopped for any reason other than a normal finish, or a response that has an empty or malformed grounding record), the run is marked, because a search may have happened. Some routes are always marked, with no evidence check: the OpenRouter web plugin, OpenAI web_search_options, the Mistral agents search and the Anthropic raw /v1/messages streaming relay. A non-streaming /v1/messages response is read like any other Anthropic response: a web_search block, or anything unreadable or unknown, marks the run; a complete text-only answer records no search. For Anthropic the stop reason is not used as evidence, because a search that started always leaves its server tool use block in the response, and a stream that did not finish is already treated as unknown.
  • Interactive turns are not marked. Chat and chat-bridge turns are outside the mark, as for tool results. An unattended service-token /invoke without a run id is not outside it: it is given a run of its own and is marked like any other unattended run (see unattended calls without a run id).
  • Grandfathered agents. An agent whose consent snapshot granted the tool keeps it (grandfathered:untrusted_egress:builtin:<tool>); every other agent is held.
  • Once marked, always marked. The mark never lowers an existing mark: a run that is already strict stays strict.
  • Timing. A search result arrives inside the model's turn, so the tool calls of that same turn already run under the mark and are held. This differs from a tool result, which marks from the next batch.
  • Search stays available. A run that starts marked does not lose search: the model's built-in search is not offered, and the gateway's own web_search tool is offered in its place (Anthropic, OpenRouter, OpenAI and Mistral; Gemini and Vertex have no search on a marked run, see above). Each call to it is held like any other built-in egress call (hold_reason: "untrusted_egress") and runs only after approval, unless the run is covered by a chat-bridge connection that allows web search or outgoing data (see Chat bridge) or by a grandfathered egress waiver. A run that is marked part-way through a request keeps the built-in search for that request (see Search stays consistent within a request).
Grandfathered agents on a marked run

An agent that demonstrably ran unattended before this update keeps, on a marked run whose mark is not strict, the tools its frozen consent snapshot already granted, instead of having them held. It is held back for every other agent.

  • Who qualifies. An agent with at least one successful unattended run (a schedule, webhook or workflow run, not a chat-bridge turn) at the time of the update, and a consent snapshot. Agents created after the update, agents that never ran unattended and agents whose only runs failed get no exemption and are fully protected. Run history is kept for 90 days, so an agent whose last successful unattended run was more than 90 days before the update is not on the list either (it is fully protected). The list is frozen: nothing grows it afterwards.
  • What is kept. The snapshot-consented connector tools, and web_search, fetch_url and agentic_fetch as far as the snapshot enabled web search or agentic fetch. How much of that is kept depends on where the mark came from: a source that had the full tool set before (level snapshot) keeps everything above; a source that only had web search before (level web_search) keeps only the built-in web_search, and its connector tools, fetch_url and agentic_fetch stay held. Anything the snapshot did not grant is held as before.
  • What is never exempt. A mark that comes from an inbound email, a webhook trigger with no_egress: true, an unknown or unreadable trigger, a storage fault and a mark inherited without a recorded level are always strict. Interactive callers are never exempt. A delegated child inherits the parent's level and the parent's grandfather status; it is still bounded by its own consent snapshot (tools not granted there are never exempt).
  • Only the untrusted-content hold is lifted. The exemption keeps a tool that would otherwise run without an approval. An approval the organisation set for that tool by name, or that the agent's own tool permission policy asks for, still holds the call, exactly as on an unmarked run; the hold is then untrusted_egress. A "once per run" approval that the run has already given counts as no approval: the call runs under the exemption, for connector tools and built-in tools alike.
  • Decision records. An exempt call is allowed with rule grandfathered:untrusted_egress:<class>:<tool> for a connector tool, or grandfathered:untrusted_egress:builtin:<tool> for a built-in, so it stays distinguishable in the audit log. A held run that is resumed keeps its level.
  • Residual risk. The snapshot records what was granted, not what was used: an exempt agent can still send data out through any tool it was granted. Revoke the unneeded tools in the agent's tool configuration to close it.
Workflow Fetch nodes

A workflow Fetch node on a marked run is not held; it is checked by the gateway instead. A URL that is a literal, that only references the trigger's own content, or that has a literal scheme://host[:port] with references only in the path or query is fetched (the last one with redirects confined to that origin on every marked run; a redirect to another origin is held for the workflow owner, see Workflows). A URL a model could choose (for example {{agent.output.url}}) is held for the workflow owner (a tool_gate approval with hold_reason: "untrusted_egress", the exact URL shown, linked to the run through workflow_run_id and workflow_name on the approval item) and fetched at most once after approval; a rejection or expiry answers 403 untrusted_egress_refused. Two decision records result: the decision itself writes approval_rejected or approval_expired when the owner rejects or the hold expires, and the run's re-entry writes an untrusted_egress denial when the Fetch is refused. On any tainted run (email, webhook or form), a Fetch on a run without an owner is refused before any download, with an untrusted_egress denial recorded; a Fetch in a loop body is held per iteration like a plain step; see Fetch node. The Deliver to recipient is already checked against the tenant allowlist (recipient_not_allowed).

  • Connector node. A workflow Connector node's write or destructive call is held as untrusted_egress on a marked run unless its input is fixed by the node's template; arguments that cannot be canonicalised are refused on every marked run; see Connector node.

Caller-supplied system/developer turns are dropped (the draft owns its system prompt), and tool_config.agents (sub-agent delegation) is ignored in preview — a dry-run never spawns owner-scoped sub-agent runs.

Authorization: preview requires a user-bound token holding the AGENTS_AUTHOR permission — the same permission the agent create/edit routes require. For the built-in roles that is member, ki_manager, tenant_admin, and admin; a tenant custom role granting AGENTS_AUTHOR is admitted regardless of its base role. An unbound (gateway service) token, and any caller lacking AGENTS_AUTHOR (e.g. viewer / demouser) — none of which may create or own an agent — are refused (403). POST-only (405 otherwise). Because it runs as the caller with the caller's own connectors/areas, preview grants no capability the caller doesn't already have. Preview runs are marked as agent-shaped traffic but carry no agent_id, so they never affect per-agent usage statistics.

Shared agents — a sharee runs as the caller

A sharee who can see an approved shared agent can invoke its slug directly with their own token. The run executes as the caller: the caller's identity, budget (the budget guard is keyed on the caller; the owner is never consulted), connectors and permissions apply, not the owner's. The owner's MCP credentials are not exposed. Clone-then-own remains available (the clone re-resolves the model/provider for the cloner's gateway and binds the cloner's own connectors/knowledge), and it is still the way to get an editable copy. Consequently a single agent's distinct-invoker count can exceed 1.

Gate order for a non-owner caller: visibility + approved check (404 otherwise), then the handover pause (409 agent_handover_pending), then the protection pause and feature gate. A caller who cannot see the agent never learns of its handover state.

Behaviour on an area-bound shared agent:

  • The run can read the agent's knowledge areas via read_file / search_knowledge.
  • The area's project instructions and knowledge are not composed into the system prompt for a caller who is not a member of the area (the composition fails safe).
  • Memory proposals are filed under the owner's area.
  • The approval-expiry mail still goes to the owner only (it names the tools, never the content).

The owner's run detail for a sharee's run is 200 but omits the result, and the trace step bodies are redacted to a whitelist of metadata (tool, model, status, counters); the numbers kept in that step data are returned exactly, with every digit. Runs the owner's own bridge/grant legs or unattended runs produced remain fully visible.


Agent-as-tool — delegation

A supervisor agent can call another saved agent as a tool. Declare the callable sub-agents in the supervisor's tool_config:

{ "tool_config": { "agents": ["research-helper", "summarizer"] } }

Each entry is a sub-agent slug on the same gateway. At invoke time the gateway offers the supervisor's model one agent__<slug> tool per resolvable, same-owner sub-agent (input schema: { "input": "<task>" }). Calling it runs the sub-agent's full configured pipeline (its own model, tools, MCP connectors and knowledge) via an internal in-process subrequest, and returns its final answer to the supervisor as a tool result. The sub-agent runs as the supervisor's owner — the same run-as-owner boundary as a direct invoke.

Accepted / rejected (tool_config.agents): an array of ≤ 8 valid slugs (^[a-z0-9][a-z0-9_-]*$, ≤128 bytes), deduplicated. A non-array value, a malformed slug, a duplicate, or more than 8 entries is rejected with 400 at create/update. A declared slug that no longer resolves, or is owned by a different user, is silently not offered (fail-closed) — it never becomes a callable tool.

Guards (non-negotiable, fail-closed). Every delegation in a run draws from one run-wide budget and is refused (returned to the model as a tool-error, never a crash) when any limit is hit. The numbers below are the platform limits: the default and the hard ceiling. An organisation can lower them (agent_delegation_limits) and an agent can lower them further for runs it starts (tool_config.delegation_limits); nobody can raise them.

Guard Platform limit (default, can be lowered per organisation / agent) Key Refusal
Nesting depth 3 max_depth delegation_depth_exceeded
Cycle (A→B→A) active call-path repeat — delegation_cycle_detected
Total sub-invokes (calls per run) 8 per run max_calls delegation_fanout_exceeded
Token budget 300 000 tokens per run max_tokens delegation_budget_exceeded
Wall-clock (run) 240 s per run max_run_seconds delegation_time_exceeded
Sub-agents per agent_fanout call 5 max_fanout delegation_fanout_exceeded (limit_kind: "batch")
Wall-clock (per child) 180 s per sub-agent (fixed; never longer than the run's remaining time) — delegation_deadline_exceeded

Effective limits. A run's limit per key is the lowest of the platform limit, the organisation's value and the value of the agent the run started with (the root supervisor). It is resolved once, on the run's first delegation, and every sub-agent in the tree shares it: a sub-agent's own delegation_limits never applies inside someone else's run. If the organisation setting cannot be read, or a stored value is corrupt, that level counts as unset and the run uses the platform limits (never looser than before). The refusal records below report the effective limit.

Per-agent delegation limits

tool_config.delegation_limits lowers the limits for runs this agent starts:

{ "tool_config": { "agents": ["research-helper"], "delegation_limits": { "max_calls": 3 } } }

Accepted / rejected (tool_config.delegation_limits): an object with any of the keys max_depth, max_calls, max_tokens, max_run_seconds, max_fanout; each a whole number ≥ 1, or null / absent (= the organisation's value). Absent or null for the whole object = no override.

Input Answer
not an object (array, string, number), an unknown key, a value that is not a whole number (string, float, boolean, object) 400, code: "invalid_delegation_limits"
a value < 1 422, code: "delegation_limit_range", field: "tool_config.delegation_limits.<key>"
a value above the organisation's effective value (its own value, else the platform limit) at save time 422, code: "delegation_limit_above_organisation", field: "tool_config.delegation_limits.<key>"; the message names the limit
the organisation's limits cannot be read 503 (retry)

A value equal to the one already stored on the agent is accepted even if the organisation lowered its limit since (an unrelated save does not fail; the run uses the lower value anyway). Only the agent's owner (or an admin) can change tool_config, as for every other tool setting. A sharee or catalog viewer does not see tool_config.agents or delegation_limits (owner-private, like the connector bindings).

Where a refusal shows up. A refusal is never only a tool error the model sees:

  • Trace. Each refusal writes an agent_delegate_refused step (agent_fanout_refused for a whole agent_fanout batch) with reason, depth, child_slug, path (the active slug chain from the root supervisor to the agent that tried to delegate; the refused child is child_slug, so a cycle reads path + child_slug = A → B → A) and, for the limit codes, limit (the limit that applied), used (the value the guard compared: current depth, calls already made, tokens spent, seconds elapsed; batch: the requested batch size) and limit_kind (depth, calls, batch, tokens, run_seconds, child_seconds). A fan-out batch refused by the calls limit also carries requested. A sub-agent that ran into its per-child wall clock is recorded by the sub-agent itself: its own trace carries the loop_terminated step with delegation_deadline_exceeded. An agent_fanout call with more entries than the run's effective max_fanout (5 by default) writes agent_fanout_refused with delegation_fanout_exceeded, limit_kind: "batch". Every agent_delegate step of a call whose sub-agent ran carries child_run_id (the sub-agent run's trace id), whatever its outcome: answered, capture_failed, an error status, interrupted or held. A call refused before the sub-agent started writes agent_delegate_refused without one. Every agent_delegate step carries duration_ms and limits (depth, calls, tokens, seconds, fanout: the effective limits the run delegates under; child_seconds: the effective wall clock that sub-agent had, the per-child cap or the run's remaining time if that was sooner). Slugs and numbers only, never the delegation input; a model-supplied slug that is not a configured sub-agent stays behind the trace-body gate.
  • Run detail. GET /admin/v1/gateways/{gw}/agents/{id}/runs adds delegation: {calls, refused} to every run that delegated (absent otherwise), counted over the run's whole delegation tree. GET …/runs/{run_id} adds delegation: the chain in tree order (each call is followed by its child run's own entries), read from the run's trace and the traces of every child run it started (same gateway only). A child run's loop_terminated step with delegation_deadline_exceeded becomes a delegation_deadline_exceeded entry naming that call, with limit = its child_seconds and used = how long it ran; trace_id names the trace that recorded each entry. Only a fixed field whitelist is returned: step, depth, child_slug, child_run_id, reason, path, limit, used, requested, limit_kind, limits, tokens, duration_ms, status, ok, held, error_code, error, trace_id. The child_slug of an agent_not_configured refusal (raw model text) is never returned. A string must look like a code (^[A-Za-z0-9_.:-]+$, bounded) and a path holds at most 16 such slugs, or the field is dropped; child_run_id must be a UUID. No step body is ever returned here. A storage fault is a 503, never a partial chain. delegation_names maps each slug the chain names (call and refusal child_slug, every path element) to its agent's display name, only for agents on the run's gateway created by the same user as this agent (exactly the agents a delegation chain can reach); another user's agent keeps its slug, and the field is absent when nothing is named. Read once per run detail, tenant-fenced; a storage fault is a 503. A sub-agent call's own steps are read with GET …/runs/{run_id}/delegation/{child_run_id}/steps.
  • Agent activity. Each refusal writes one access_decision row: decision deny, reason = the code above (or agent_delegation_forbidden, agent_not_found, agent_misconfigured, agent_not_configured, agent_external, agent_handover_pending, agent_protection_paused, egress_blocked), tool agent__<child-slug> (agent_fanout for a batch and for a model-supplied slug that is not a configured sub-agent), actor = the agent that tried to delegate, root agent = the supervisor, request_id = the run. The row's arguments hold path, limit, used, limit_kind and child_slug ("Show details"). A sub-agent stopped at its own wall clock also writes one row (delegation_deadline_exceeded, tool agent__<child-slug>, limit = its effective cap, used = how long it ran), but only when the sub-agent's own trace confirms that stop; with tracing off it writes none. These rows do not count toward the automatic deny-burst protection: the guard is working as designed.
  • SIEM. The same write streams the row to the tenant SIEM as TOOL_ACCESS_DENIED with reason = the code. A failing row write or SIEM emit never changes the refusal.

Held calls in a sub-agent. A sub-agent's write call, and, on a run that carries untrusted content, its built-in outgoing call (fetch_url, agentic_fetch or web_search), is held for approval on the parent run (see Unattended write calls) with these v1 limits: one held call per sub-agent turn; after the approval, further write or outgoing calls in that same turn are refused; executed sibling calls are never run again and later siblings in the batch are not run. Fan-out (several sub-agents in one round), depth beyond one and a parent without a run are still refused. The parked sub-agent call produces no client frame (a parked run is unattended and there is no new stream event type for it), and the held sub-agent's token usage up to the hold is not added to the run when it is parked: it is carried with the parked sub-agent state and added to the run's delegated tokens once, when the sub-agent is resumed after approval. The sub-agent's cost (delegated_charged_usd) is different: it is charged at park time, not at resume.

A call to a model that searches the web on every call (hold_reason: "inherent_search"), or a Gemini/Vertex call whose native grounding would be injected (hold_reason: "native_grounding"), made inside a sub-agent is held the same way. The tool_gate item is on the parent run and its subject_ref is agent__<slug> > model:<id>; the sub-agent has no review of its own. Approval is a single-use waiver bound to that parent review and to the parked sub-agent request: it lets that one call be sent, and a different or already-used review does not. A parked sub-agent state that is malformed or lacks a valid held-model marker is refused and never resumed. After the approved send, a retry inside the sub-agent is refused, not held again. On rejection the sub-agent is not run and the parent continues with a declined tool result, so the parent run can still succeed. On expiry the parent run fails with the approval-expired error; it does not get inherent_search_rejected. A call to an always-searching model is refused with inherent_search_blocked, and nothing is held, in three cases: fan-out (several sub-agents in one round), delegation deeper than one level, and a parent that is not attached to a run. A native_grounding call in those cases is sent without grounding, with no error, and nothing is recorded.

The depth, fan-out, token and run wall-clock guards are checked at the entry gate before each sub-invoke. The per-child wall-clock (180 s, or the remaining run budget if that is sooner) is additionally enforced mid-flight, so a single sub-agent that keeps running cannot overshoot: its provider stream read is cut when the deadline passes, and its own tool loop stops cleanly between rounds with a delegation_deadline_exceeded note. The per-child cap is deliberately tighter than a direct (non-delegated) turn's tool-loop budget so one runaway sub-agent can't consume the whole run and starve its siblings; a legitimate multi-round sub-agent finishes well inside it. (A sub-agent leg already producing output but stalling between chunks is interrupted when its current read returns — the same granularity as the client-disconnect kill; a leg that goes silent right after a late chunk can therefore overshoot the per-child cap by up to one inter-chunk read budget before it is cut.)

Interrupted sub-agent. When a sub-agent's turn is cut off mid-answer, the gateway answers the typed error with x-should-retry: false (its tools may already have run; a 2xx carrying X-AIG-Error is treated the same way as a defensive backstop — see Inference › Interrupted answers). The partial is not passed on as its answer: the supervisor's model receives a tool error saying the sub-agent was interrupted, that its tools may already have run, and that it must not be invoked again for the same task.

A diamond (A→B→C then A→C) is allowed — only a true cycle on the active path is refused. This includes a supervisor that lists its own slug (S→S) and a deep call back to the run's originating supervisor (S→…→S): both are refused as cycles (a self-listed slug is additionally never even offered as a tool). A malicious or looping agent graph therefore always terminates.

Security. The agent__ tool-name prefix is reserved: an MCP connector that exposes a tool named agent__* is rejected, so it can never shadow or hijack a sub-agent tool. Cross-owner delegation is refused unconditionally — a sub-agent's owner must equal the (already-resolved human) owner of the run, with no service-token / unattended-automation exception, so a scheduled supervisor run can never borrow another owner's agent (and its credentials). The model-supplied input is treated as untrusted (byte-capped; the sub-agent runs its own guardrails/PII on it), and the sub-agent's returned text is fenced as untrusted before the supervisor model sees it.

Billing + lineage. Each sub-agent invocation is a separate request billed under its own request id, attributed to the same owner; the parent's agent_delegate trace step records parent_run_id, child_run_id and depth (and, for a refused child, its error_code — e.g. quota_exceeded, which also tells the parent model not to retry that sub-agent), and the child's request_log.meta carries parent_request_id. Nested delegate runs are metered and logged like any other run — a build guard ensures a configuration change can never leave nested runs silently unbilled.

Parallel fan-out (agent_fanout)

Calling sub-agents one at a time costs the sum of their wall-clock times. When a supervisor wants several independent sub-agent tasks done at once (e.g. "run 3 review agents on this diff"), it can call the agent_fanout tool instead — offered automatically alongside the per-slug agent__<slug> tools whenever at least one is offered — with an array of {agent, input} pairs:

{
  "agents": [
    { "agent": "research-helper", "input": "Check the API section for accuracy." },
    { "agent": "summarizer",      "input": "Summarize the intro in 2 sentences." }
  ]
}

Every named sub-agent must already be one of the supervisor's declared, resolvable, same-owner tool_config.agents — agent_fanout does not grant access to anything a plain agent__<slug> call couldn't already reach; it only changes HOW MANY calls run per model turn and WHEN they run. The children run concurrently (within the same request) and their answers are merged into one tool result inside ONE outer untrusted-content frame around the whole batch — each child's answer is individually labeled (not its own separately closed frame — only the outer batch frame is opened/closed, execute_tool closes it once at the end) and defanged (reusing the same marker-forgery defenses agent__<slug> fencing uses — see Security above); every refusal string in the merge (including a raw, unresolved model-supplied agent value) is defanged too, so a crafted agent field can't forge a fake close/open marker pair inside its own refusal text.

Accepted / rejected (agents):

Condition Outcome
Not an array, empty, or more than 5 entries (or the run's lower effective max_fanout) whole-batch refusal, no sub-agent is run
An entry isn't an object, or agent/input is missing/non-string/empty that entry's own refusal; the rest of the batch still runs
input exceeds the byte limit (same cap as agent__<slug>) that entry's own refusal
agent is not one of this supervisor's configured, resolvable sub-agents that entry's own refusal
Depth / tokens / deadline (single early check) or fan-out (N-aware early check) obviously over budget for the WHOLE batch a fast, whole-batch pre-flight refusal before any sub-agent runs
Fan-out budget exhausted specifically by concurrent siblings (invokes race) an individual entry's own refusal from its race-safe late re-check, even though the early batch check passed
One child's sub-request crashes, or returns an error / empty answer that entry's own error string; siblings are unaffected — this is a partial merge, not an all-or-nothing failure

The agents array shares the SAME run-wide guards as sequential delegation (by default depth 3, 8 total sub-invokes per run, 300 000-token budget, 240 s run deadline, 180 s per-child deadline; the run's effective limits apply, and the batch size is capped by the effective max_fanout) — a fan-out batch cannot raise the ceiling, only spend it faster. Every fanned-out child's invocation is counted exactly once against the fan-out guard, and every child's real token usage is counted exactly once against the token budget, regardless of the order the concurrent children finish in.

Trade-offs, named explicitly (not silent):

  • Shared output budget. The merged batch shares ONE 80 KB tool-result cap across up to 5 children (a sequential agent__<slug> call gets the full 80 KB to itself) — a fan-out of several verbose sub-agents divides that budget between them.
  • Token-ceiling overshoot window. The 300 000-token run-wide ceiling is a pre-flight check against already-completed usage, not a hard per-call limiter (true sequentially too) — under concurrency, up to 5 children can each independently pass that check before any of them is reconciled, so the worst-case transient overshoot widens from "one child's response" to "up to 5 children's worth" before the NEXT call sees the corrected total.
  • Client-abort is not retroactive. If the client disconnects while a fan-out batch is already running, the already-spawned children are not killed (the underlying mechanism cannot interrupt an in-flight sub-agent invocation) — they run to completion or their own deadline, bounded by 5 × 180 s in the worst case, same as an in-flight agent__<slug> call today.

Privacy. When agent names a sub-agent that isn't actually one of the supervisor's configured, resolvable sub-agents, the refusal identifies the attempted (model-supplied, unbounded) value the same way every other delegation refusal does — but because that value never resolved to a real, gateway-known identifier (unlike every other refusal reason, where the named sub-agent IS a small, bounded, already-configured slug), the value persisted to the queryable trace record for this ONE refusal reason follows the same opt-in gate every other piece of raw request content does: present only when include_bodies is on AND log_payloads is on AND the request did not send x-aig-collect-log-payload: false AND the turn is not private (ghost); omitted otherwise. The refusal reason itself (agent_not_configured) is always recorded regardless.


Structured output (response_schema)

An agent can require its answer to be a JSON value conforming to a schema, so a downstream consumer (a scheduled webhook, another agent in a chain) can parse it reliably instead of scraping prose. Set response_schema on the agent to a JSON Schema object:

{
  "response_schema": {
    "type": "object",
    "required": ["summary", "sentiment"],
    "properties": {
      "summary":   { "type": "string" },
      "sentiment": { "enum": ["pos", "neg", "neutral"] },
      "items":     { "type": "array", "items": {
        "type": "object", "required": ["id"],
        "properties": { "id": { "type": "integer" } } } }
    }
  }
}

Accepted / rejected (response_schema, each → 400 at create/update). The value must be a JSON object (a top-level array or scalar is rejected — a schema root is an object), must fit the 60 000-byte column (measured on the exact text that is stored, in which large whole numbers are written out in full digits), and must not be excessively nested (at most 24 levels of nested objects — deeper is rejected so egress validation can descend it in full without a silent depth cut-off). An absent / null value means the agent has no structured-output requirement (unchanged behaviour, no overhead).

How it is enforced (provider-strict where possible, always validated on egress)

Enforcement is two-layered, and the egress layer is the hard guarantee:

  1. Native provider-strict (a belt, where the provider supports it). For a single-shot agent (no tools/web-search/MCP/knowledge/delegation) whose model is served by a provider confirmed to enforce it, the schema is sent natively so the provider constrains generation to it. Tool-using agents are excluded — constraining every leg to the schema would starve the model of tool calls. Two native shapes are supported today:
    • OpenAI-style response_format: json_schema — OpenAI gpt-4o / gpt-4o-mini.
    • Gemini generationConfig.responseSchema (Google gemini-2.5-flash / -2.5-pro / -2.0-flash / -1.5-flash / -1.5-pro, and the same models via Vertex). The JSON schema is translated to Gemini's OpenAPI-subset (types uppercased, enum → STRING+format:enum, a ["T","null"] union → nullable). The translation is fail-closed and faithful: any construct it cannot represent exactly — oneOf/anyOf/allOf/$ref/const/patternProperties, additionalProperties:false, a property-less object or item-less array, a multi-type union — is not sent natively; that agent falls back to the prompt directive + egress validation below (never a lossy native schema).
  2. Egress validation (the universal guarantee, every provider). An agent invoke with a response_schema always executes internally buffered — a caller's stream:true only changes the delivery (the validated body is re-emitted as SSE, see Streamed interactive invoke below) — and every provider's answer is normalised to a single message, then the gateway extracts the JSON from that answer (tolerating a ```json fence or a leading citation bracket), validates it against the schema, and replaces the delivered content with the canonical re-serialised JSON. This runs for all providers — including those with no native belt (Anthropic, Gemini, the default Myra/vLLM models) — so structured output is enforced uniformly, not best-effort.

Validation scope. Recursive: the top-level type; object required fields and each declared property (recursively); array items (each element, recursively); enum membership; and integer (a fractional number is rejected). An array is distinguished from an object, so an object where an array is required (or vice-versa) is rejected. Not enforced (validation only checks what is declared): minItems/maxItems/minLength/pattern/format/oneOf/anyOf/$ref, tuple items (an array of per-position schemas), and non-primitive enum members. In particular additionalProperties is not applied — fields the model adds beyond the schema are validated-around, not stripped; a consumer that needs a closed object must not assume unknown keys are absent.

On failure — never silent prose. If the model's answer cannot be extracted, parsed, or validated against the schema, the invoke fails closed with structured_output_failed (HTTP 422) — the caller never receives non-conformant output dressed as success. (The main inference is still billed, since it already ran.)

Numbers in the schema are written exactly as stored. The schema directive sent to the model carries every number exactly as stored: an integer such as 9007199254740991 or a fraction such as 0.30000000000000004 is never rounded to 9007199254741000 or 0.3. A number in the model's answer is read as the nearest 64-bit double and written as the shortest text that reads back as that double; only a number that has no double value is refused, with structured_output_failed (HTTP 422, still billed). The exact rule and examples are in the structured_output_failed row of the error codes. A stored response_schema that cannot be written out at all (for example a non-finite value left over from an older row) fails the invoke with agent_misconfigured and a message naming the schema, before any provider call.

The agent create and update API reads the numbers in response_schema exactly. A number that is stored is the number you sent; a number that cannot be stored exactly is refused by name with 400 number_not_exact or number_invalid and field: "response_schema", and nothing is written. The rows are in Error codes. Send such a value as a string.

Duplicate in the web app. The browser cannot write a whole number beyond 2^53 back as the same number, so Duplicate does not copy a response_schema or tool_config that holds one. The create form says so and sends nothing; create the copy through the API instead.

Typed codes on refusals

Every JSON error on the agent routes (/admin/v1/gateways/{id}/agents…, including sharing, ratings, external agents, knowledge areas and schedules) carries a top-level code next to the unchanged HTTP status and error text. Branch on code; never parse error.

A refusal about one request field also carries field. A missing, null or empty value answers field_required; a present but wrong value answers invalid_field. The conversation starters, plan proposal and review decisions use their own <field>_required / invalid_<field> codes, documented on their sections. The status and error sentence are the same for both.

Group Codes (status)
Generic unauthenticated (401); forbidden, feature_disabled (403); not_found, agent_not_found, group_not_found, user_not_found (404); malformed_body, field_required, invalid_field, invalid_q, invalid_body, bad_param (400)
Sharing org_share_disabled, share_target_gone (a selected group no longer exists; a gone user answers 404 user_not_found), agent_not_owned, agent_owner_missing, agent_owner_inactive
Ratings own_agent_rating (403)
External agents agent_external, agent_not_external, agent_not_approved, invalid_hosting, invalid_task_envelope, invalid_token_hint
Approval window invalid_approval_ttl (400, see Approval window)
Schedules invalid_schedule, schedule_not_found (404), schedule_disabled (409)
Versions and bodies version_not_found (404), unknown_field (400, with field)

Schedule endpoints

An agent's schedules are managed through these routes. All require access to the gateway; the mutating routes additionally require the AGENTS_AUTHOR permission (the same gate as agent create/edit — the built-in member/ki_manager/tenant_admin/ admin roles, or a custom role granting it) and are ownership-checked against the schedule's parent agent. On the routes that take a schedule id, a missing schedule and a schedule whose parent agent the caller cannot manage (not the owner, or the agent is gone) get the same 404 { "error": "schedule not found", "code": "schedule_not_found" } (no existence leak). On the list and create routes, an agent in the URL that is missing or not the caller's answers 404 { "error": "agent not found", "code": "agent_not_found" }.

Method Path Purpose
GET /admin/v1/gateways/{gw}/agents/{agent}/schedules List the agent's schedules as a JSON array ([] when none). Each row's output_action is redacted to { kind } — the webhook URL/token, Mattermost channel, and email recipient are never returned on this gateway-access route.
GET /admin/v1/gateways/{gw}/agents/{agent}/schedules/{id} Fetch one schedule with its output_action returned whole (kind plus the to / url / channel_id), so the owner's edit form can prefill the current delivery target. This is why the read is owner-gated (AGENTS_AUTHOR + parent-agent ownership) unlike the redacted list; a non-owner gets 404 (no recipient/URL leak), a caller lacking AGENTS_AUTHOR (e.g. viewer/demouser) 403.
POST /admin/v1/gateways/{gw}/agents/{agent}/schedules Create a schedule (201; see the input contract below).
PATCH /admin/v1/gateways/{gw}/agents/{agent}/schedules/{id} Update a schedule (partial). Accepts output_action to change the delivery target; send { "kind": "none" } to clear an existing target (a JSON null is treated as "not provided" and leaves it unchanged). A schedule deleted while the update is in flight answers 404 schedule_not_found; an update that lost a race with another save of the same schedule answers 409 schedule_conflict (see Concurrent saves).
DELETE /admin/v1/gateways/{gw}/agents/{agent}/schedules/{id} Delete a schedule (200 { "ok": true }).
POST /admin/v1/gateways/{gw}/agents/{agent}/schedules/{id}/run-now Mark the schedule due so the scheduler claims and runs it on its next tick (within about a minute), executing invoke, delivery, and the run record exactly as a normal run. A disabled schedule is refused with 409 — enable it first. A schedule of an agent that was handed over and not yet confirmed is refused with 409 agent_handover_pending (the scheduler would not claim it); confirm the hand-over first. A schedule of an agent paused by automatic protection is refused with 409 agent_protection_paused. A schedule of an agent that is flagged or disabled by its governance review is refused with 409 agent_review_blocked (the scheduler would not claim it); get the agent approved again first.

The run-now route loads the schedule by id and gateway and checks ownership on the schedule's parent agent (not the path {agent}), so it cannot be used to trigger another agent's schedule.

Schedules — input contract for enabled

POST /admin/v1/gateways/{gw}/agents/{agent}/schedules and PATCH …/schedules/{id} accept an optional enabled field:

  • Accepted shape: a strict JSON boolean (true / false), or JSON null / absent meaning "not provided". Anything else — a string, a number, an object — is rejected 400 enabled must be a boolean before any storage access. (Same strictness as require_approval below and the workflow-schedule route.)
  • On create, enabled absent or null defaults to enabled — a fresh schedule runs. (This differs from the member scheduled-tasks API, where enabled is PATCH-only.)
  • Re-enabling re-arms the next run. Flipping a disabled schedule back to enabled: true recomputes next_run_at exactly like a cadence change: an interval schedule becomes due promptly (within about a minute); a daily/weekly schedule arms to the next occurrence of its configured time. A stale run slot from before the pause is never fired — re-enabling can not trigger an immediate catch-up run.
  • Storage errors are not client errors. The only 400 from the update's storage layer is no fields to update (an empty PATCH). A failed write answers an opaque 500 { "error": "internal error", "request_id": "<id>" } (or the retry 503 when it wrote nothing); raw driver/SQL text never appears in a client-error (4xx) body — every 4xx on these routes is a fixed validator message.
  • 404 means genuinely absent, not "the lookup failed". On PATCH, DELETE, and …/run-now, a 404 schedule_not_found is returned only when the row does not exist (or its parent agent is not the caller's to manage); a transient database fault on the lookup answers 503 { "error": "temporarily unavailable; retry later" }, never a 404. After a POST (create) the row is read back for the response: if that fails, the answer is the sanitised 503 { "error": "temporarily unavailable; retry later" } (or, when the outcome is unknown, the sanitised 500 { "error": "internal error", "request_id": "…" }) — the read-back runs inside the transaction that stores the schedule and its audit entry, so a failed read-back stores nothing and the request may be retried; if the outcome was unknown, list the schedules before creating it again. Only a row that vanished in between answers 201 with a minimal { "id": … } body.
  • Integer cadence fields are canonicalized. interval_sec and, for weekly agent schedules, daily_dow are stored as canonical integers, so a syntactically-integer value never reaches the database in a form that would surface as a 500; a value the shared cadence validator does not accept as an in-range integer is a 400.
  • Cadence fields belong to exactly one kind. A schedule's cadence is described by the field(s) its schedule_kind uses — interval uses interval_sec, daily uses daily_at, weekly uses daily_at and daily_dow — and nothing else. On this route that also means daily_dow is rejected outright: agent schedules are interval or daily only, so no kind here uses it. A cadence field the kind does not use is rejected 400 on create and on PATCH (it used to be accepted and then dropped), and the fields the new kind does not use are cleared when the kind changes, so a schedule never reports a cadence it does not run on. A PATCH may change the kind alone when the stored schedule already carries what the new kind needs; it is rejected 400 when the new kind needs a field the schedule's previous kind never used, rather than silently reusing a leftover value the request never named. The same rule applies when a queued four-eyes schedule-create is applied — a payload carrying a field its kind cannot use fails at apply with that reason recorded, instead of persisting it.
  • output_action is validated at the trust boundary. The optional delivery target is an object whose kind is one of none / email / webhook / mattermost (any other value → 400). For email, to must be a plain ASCII address (single @, dotted domain, no inner whitespace or control characters, at most 254 bytes after surrounding whitespace is trimmed; stored trimmed, all other output_action keys are kept). A malformed, blank or over-long to is 400 { "error": "output_action.to must be a valid email address", "code": "invalid_email", "field": "output_action.to" } (previously code: "invalid_request" without field); a non-string to keeps its existing message. An unchanged stored address is kept: a PATCH or an approved held change that re-sends the schedule's current address is accepted even when it would fail the check today; "unchanged" is judged against the schedule as it is when the change is applied. A PATCH that re-sends an unchanged address that fails today's check (a legacy value) together with a pause or an approval-off patch is written only if enabled, require_approval and output_action are still as read; if another save changed them meanwhile, the change is re-evaluated against the fresh row: when that row no longer stores the address it is judged as new and refused with 400 invalid_email, otherwise the answer is 409 schedule_conflict. For webhook, url must start with the literal https://, stay within the length cap, have a host and carry no user name or password (the same URL shape the run-time delivery check and workflow publish apply — a URL with credentials could never be delivered); for mattermost, channel_id must be exactly a 26-character lower-case-alphanumeric id (a trailing newline is refused). A malformed value is rejected 400 before any storage write, on both POST and PATCH — the client-side form check is a convenience, never the authority. Set { "kind": "none" } on PATCH to clear an existing target; a JSON null is read as "not provided" and leaves the stored target unchanged. The delivery destination's real egress controls (the fail-closed PII gate, SSRF/private-address refusal, and the per-tenant Mattermost-delivery flag — on by default, a platform admin may disable it per tenant) are enforced at delivery time, not here. A Mattermost delivery uses the tenant's own bot token and requires that bot to be a member of the target channel; if it cannot deliver (no per-tenant bot token, an undecryptable token, or the post is refused — e.g. the bot is not in the channel), the result is emailed to the schedule owner instead (never-fail), never silently dropped.

  • A value that cannot be stored as JSON is rejected 400. JSON parsers accept the non-finite number literals nan, Infinity and overflowing exponents such as 1e999, but those values cannot be re-serialised, so they can never be persisted. Such a number anywhere in a request body — e.g. {"output_action": {"kind": "webhook", "url": "https://x/y", "retries": 1e999}} — is refused by the body parser with 400 { "error": "request body contains a number that is not finite (NaN / Infinity / out of range)", "code": "malformed_body" } before any handler or storage write runs (see Error codes). Behind it, every place the admin API stores a caller-supplied JSON object (this output_action, an agent's tool_config / response_schema, gateway config, routing-rule conditions/actions, workflow graph_json, governance-template obligation_refs/target_controls, token scopes) still refuses an unencodable value with an error naming the field (<field> is not JSON-encodable) for a value that reaches it another way — never a partial write.

Scheduled email delivery blocked by PII policy — the user is notified

A scheduled run's outbound delivery always passes a fail-closed PII gate: when the run masked personal data (or the PII signal is missing), the result must not leave the platform — the run records delivery_status: blocked_pii and no content egresses. This holds on a local-only gateway of an enforcing tenant too: an agent-shaped run there is masked under the PII mandate like on any other enforcing gateway (the first-party exemption is for chat turns only). That block stays, and it is never silent: a blocked delivery of any kind (email, webhook, Mattermost) notifies the schedule owner.

  • The scheduler sends the schedule owner a notification email (never the configured recipient, who receives nothing) stating that the run completed and that delivery was blocked by the organization's PII policy. The notification never contains the run output or any personal data — only the agent and schedule name and where to log in. It is localized (English/German) by the owner's user locale.
  • Exactly one notification per blocked run — no retries, no notification loops. If the notification itself fails, the failure is recorded on the run (delivery_error: "…; notification email failed: …") and nothing is retried; a successful notification records "…; owner notified by email".
  • The run detail (Agents → Runs) shows the same honest status: the Internal channels only badge (formerly Blocked (PII)) plus a hint explaining that the block is the tenant's PII policy, not a delivery failure.
  • Webhook and Mattermost deliveries blocked by the PII gate send the same content-free notification to the schedule owner. The gateway resolves the owner server-side (the scheduler passes recipient_owner: 1, never an address); if the owner is deactivated, in another tenant or has no email, nothing is sent and the run records "…; notification email failed: owner not notifiable: …".
  • Before every agent-run delivery (email, webhook, Mattermost) the scheduler also asks the gateway for clearance (POST /internal/scheduler/deliver-clearance {run_id}). The result leaves the platform only if the run's X-AIG-PII-Active header said clean and the gateway's own record of the run answers 200 {"cleared": true}. A server-side PII verdict records blocked_pii (and the notification above); a hold answer (cleared: false with held) records waiting_release and sends the release notice instead (see Delivery releases); any other answer — an error (401 / 503 included), a timeout, an unknown run, a malformed reply — records delivery_status: failed with a deliver clearance … reason and sends nothing (it never halts the scheduler tick). A transient clearance failure is therefore final for that run (delivery is never retried): re-run the schedule to deliver.

Input contract (POST /v1/{tenant}/{gateway}/agents/{slug}/deliver-email, service token only): the optional notice field requests this content-free notification with the value "blocked_pii" (the delivery-release notices waiting_release, release_denied and release_expired are described under Delivery releases) — any other value is rejected 400. notice: "blocked_pii" and text are mutually exclusive (400 if both are present); without notice, a non-empty text remains required. In notice mode the notice always goes to the server-resolved schedule owner (recipient_owner, 0|1|bool, anything else 400, is accepted for compatibility) and any client to / expected_to_hash is ignored, so a recipient pin can neither refuse nor redirect it; an unresolvable owner answers 200 {"delivered": false, "blocked": "…"} and sends no mail. All other deliver-email protections (service-token-only auth, disabled/flagged-agent refusal) apply unchanged in notice mode; the expected_to_hash pin still guards result delivery.

Tenant suspension (MAP-4420). Right before the send, deliver-email reads the tenant's suspension fresh (not from the cached configuration). A suspended tenant gets 403 tenant_suspended, a tenant whose state cannot be read gets 503 tenant_state_unknown; both carry the X-AIG-Error header with the same code, and nothing is sent. The conversation write of a scheduled prompt task (.../agents/scheduled-task/{id}/deliver-conversation) does the same check right before the write.

Processing restriction. deliver-email re-checks the GDPR Art. 18 processing restriction at send time, for both the agent's owner and the user who created the schedule. If either of them is restricted, the route answers 403 owner_processing_restricted and sends no mail — in result mode and in notice mode, whichever recipient was chosen. A missing or unreadable restriction value counts as restricted. A stored-recipient delivery also checks the schedule creator: an absent, deactivated or erased schedule creator (or agent owner) answers 403 agent_owner_inactive and the run is recorded as failed. When the owner and the schedule creator are different people and one is restricted while the other is deactivated, the restriction wins. The scheduler records such a refused delivery as delivery_status: owner_restricted — not a failure, so no strike and no owner notice. It is terminal: the result is not re-sent after the restriction is lifted — re-run the schedule to deliver.

Scheduled run FAILED — the owner is notified

A scheduled run used to deliver only on success: if a run failed (a quota 429, a provider error, a timeout), the configured destination received nothing and the owner had no signal. Now a failed scheduled run whose schedule has a delivery destination (output_action.kind of email / webhook / mattermost) sends a short failure notice through that same channel.

  • The notice is content-free operational metadata — the agent name, an actionable reason, and a UTC timestamp. It never contains the prompt or any model output (a failed run has none). The email subject reads Agent run failed: <agent>; a webhook payload carries event: "run_failed" so an automation can tell an alert from a result.
  • The reason is the gateway's typed error message when it returns one, not a bare status code. A run stopped by a budget cap — for example the shared scheduler-service token reaching its monthly budget_usd — reports which cap tripped and that it resets at the start of the next period, so the owner can act (raise the budget, or wait for the reset) instead of guessing at an opaque http 429. The same reason is stored on agent_run.error and shown in the run history. Any bearer token in the body is redacted, and a response with no usable message degrades to the bare http <status>.
  • At most one notice per schedule per 24 hours (anti-flap) — a schedule failing every minute alerts once, not 1 440 times. This 24 h window is now shared with the owner account-email channel (see below): both the destination notice and the owner email fire at most once per window, off the one watermark. If the schedule uses the delivery-approval gate (require_approval), the failure notice is still sent: that gate reviews run output, and a content-free alert has none. A schedule with the no-egress profile sends no destination notice (but the owner account email — not an external egress — still fires).
  • If the notice's own delivery fails, it is not retried within the period and the failed run stays visible in the run history (Agents → Runs) — no notification loops.
  • A failed run delivers no result, so its run record never says a delivery is still coming: a run with a destination starts with delivery_status: pending, and the moment the run is failed (an error answer, a timeout, a guardrail block, a lease timeout, an expired tool-gate review, a cancelled run) that is set to delivery_status: none in the same write. The run history therefore shows Failed with no delivery badge, never Failed next to Pending. The failure notice above is an alert, not the result: it does not change the run's delivery_status. Only the pending start value moves — a run without a destination keeps null. A succeeded run whose delivery never settled (the scheduler crashed between finishing the run and recording the delivery) still shows pending.
  • For a Mattermost destination whose failure notice cannot be posted to the channel, the owner gets one email for the failure — the owner account email below — and not a second copy of the notice. Only if that account email could not be handed to the mailer does the "email the owner instead" fallback send the notice (subject Agent run failed: <agent>), so a failure is never left without an email for that reason. A schedule whose creator has no account email gets no email either way (the notifications center still shows the failure).
  • For an email destination that is the schedule owner's own address (compared case-insensitively, surrounding spaces ignored; name+tag@ is a different address), the owner gets one email for the failure — the owner account email below — and the destination notice is not sent. If the gateway could not accept the account email (for example a transient fault), the destination notice is sent instead. Once accepted, the account email is sent in the background; if that final send fails, it is not retried and the failure stays visible in the run history and the notifications center. If the owner's account is deactivated, no failure notice is sent to that address through either channel.
  • If the schedule owner's processing is restricted (GDPR Art. 18), no failure notice is sent through either channel: not the owner account email, not the destination notice (it would disclose the failing run to the destination), and not the Mattermost-to-owner-email fallback. The skipped destination notice is audited as delivery.skipped (owner-restricted). Notices resume once the restriction is lifted. The approval-required and approval-expired notices are unchanged. Exception: when the scheduler gets no reply to its owner-notice call (a transport fault), it cannot see the restriction and keeps the destination notice as for any other owner.

Delivered answers on a tainted run

An answer delivered by a tainted workflow run (one started by an email, webhook or form trigger, see email triggers) is stripped of auto-loading external media first. No ! survives: every !, also inside a link, is replaced by ǃ (U+01C3, so ![x](u) arrives as the link ǃ[x](u), #!/ as #ǃ/ and a sentence-ending Done! as Doneǃ), < by ❮ and { by ❴; a percent-encoded %21 / %3c / %7b becomes %C7%83 / %E2%9D%AE / %E2%9D%B4. The text is decoded (;-terminated and numeric references) and Unicode-normalised first (m² becomes m2). A link stays byte-identical apart from the ! / < / { rules above and one more case: a &lt / &amp / &not / &laquo / &iexcl parameter without ;, whose & becomes ⅋, a dangerous punycode host label (xn-- becomes xn⸺⸺, with U+2E3A; under glibc iconv ASCII//TRANSLIT this neutralised form no longer transliterates back to xn--), and « ‹ and similar (❮) or ¡ ¬ (ǃ), the last two as a partial mitigation only. If the safety check cannot settle a text, the fallback costs more: & becomes ⅋ and % becomes ٪ across the whole text, so links with query strings or percent-escapes then stop working. Supported receiver model: up to two standard markdown/HTML render rounds (CommonMark/GFM including markdown-it with linkify, python-markdown including extra, HTML5 parsing, html2text HTML-to-markdown), with HTML character-reference decoding, Unicode normalisation (NFKC), percent-decoding, punycode/IDNA decoding and markdown backslash-escapes in between. Not covered: ASCII-transliterating receivers (iconv ascii//TRANSLIT, unidecode-style), Org-mode [[url]], JavaScript %u0021, overlong UTF-8 %C0%A1, quoted-printable =21, an xn-- prefix split by a default-ignorable character (x, U+00AD, n--; also U+200B, U+034F: standard decoders reject it, so only a non-standard strip-then-decode receiver is exposed), unidecode / anyascii-style libraries (they map the guard's substitutes back to markup; closing it would need an ASCII-only output alphabet or approval hold), markup other than markdown or HTML, link unfurlers that fetch a plain URL, and more than two render rounds. Input and delivered text are each truncated at 1,048,576 characters. Anything changed is counted, and the step notes external_media_neutralised:<n>. Details: Deliver node.

Interrupted runs are failed runs

A scheduled agent run that is cut off mid-answer — the gateway answers the typed error (with x-should-retry: false when tools ran) after the model call failed mid-turn, typically after the agent's server-side tools ran (see Inference › Interrupted answers); a 2xx carrying X-AIG-Error is read the same way as a defensive backstop — is recorded failed. The typed error (a 5xx, normally 502) records its own typed reason (http 502); only the 2xx backstop records "interrupted: the answer was cut off (<code>)". It is not retried when the response carries x-should-retry: false (its tools may already have run) and the partial is not delivered to the schedule's destination. The same applies to scheduled prompt tasks.

Failing scheduled runs are surfaced, not silently disabled

Failure state was already persisted, but the only proactive owner channel was delivery to the schedule's own external destination — skipped for output_action.kind: none, for member prompt-tasks, and for scheduled workflows, and unreliable when the destination itself was the fault. And after enough consecutive failures a schedule was silently auto-disabled, so an owner who never opened the runs page never learned their automation had stopped. Both are fixed.

  • Owner account email, destination-independent. On a failed scheduled run (agent schedule, member prompt-task, or scheduled workflow) the schedule's creator is emailed at their account address — resolved server-side from created_by, never from output_action.to. This fires even when kind: none (no external destination). The email carries the schedule name, the same bounded, bearer-redacted typed reason stored on the run, and a UTC timestamp; the reason is HTML-escaped. Its button opens the automation's runs page: an agent schedule's runs tab (/agents?gateway=<id>&agent=<id>&tab=runs), the scheduled-tasks page for a member prompt task, or the workflow's runs page. It is localized (English/German) by the owner's locale. A schedule whose creator has no account email (an SSO/service identity), is GDPR-erased (created_by NULL), is deactivated (disabled or removed by an administrator), whose processing is restricted (GDPR Art. 18; resumes once the restriction is lifted, see the bullet above), or who belongs to — or whose schedule belongs to — a deleted organisation gets no email — the in-app alert below still covers it.
  • A delivery-failed-on-a-successful-run is a distinct event. When a run succeeds but delivering its output to the destination is an ongoing failure, the owner gets a separate email that says results were produced but delivery failed. This covers a transport failure, a destination that now resolves to a private IP (SSRF-blocked — a misconfig or hijack the owner must fix), and a disabled tenant integration (e.g. Mattermost delivery turned off). This applies identically to a schedule that requires approval: when an approved result's delivery then ends in one of these outcomes, the owner gets the same email. A PII-policy block (blocked_pii, working as designed) and an empty result (nothing to deliver) are not alerted. Two approval-only outcomes where an approved result can never arrive are alerted, through the same email with its own per-kind 24 h window, with their own wording that says why and what to do (run the agent again and have the new result approved — for output_missing only after the setting below is switched back on, since run-now and enabling are refused until then): blocked_changed (the destination was changed after the result was held for approval) and output_missing (the approved result is no longer stored — usually because the gateway's "Log request/response payloads" setting is off or request logging is disabled for the organisation, or the retention sweep deleted it: the audit entry then carries the marker "(payload-expired)" and a distinct reason). The notifications center shows the same explanation. An approved delivery interrupted because the scheduler stopped mid-delivery (a crash or restart) is alerted, through the same email and the same 24 h window, once its delivery lease has expired (usually about 23 minutes after the interruption, at most about 45): the run is marked failed with the reason "delivery interrupted: the scheduler stopped mid-delivery; the result may or may not have been sent" — the gateway never re-sends it automatically, so check the destination before re-running. A delivery still in progress on another gateway node is never reported as interrupted. Because a broken destination fails on every run, this email has its own 24 h window — separate from the run-failure window, so neither masks the other — bounding a schedule that succeeds every minute against a dead destination to one alert per window instead of up to 1 440 — also when several approved deliveries of one schedule fail at once. The window is kept per failure kind (the run's delivery_status: failed — including an interrupted delivery —, blocked_ssrf, blocked_tenant, blocked_changed, output_missing): an approved result that can never arrive and a real delivery failure of the same schedule each send their email; two failures of the same kind within 24 h send one.
  • In-app alert on /me. GET/PATCH /admin/auth/me now returns a failing_runs array — the caller's OWN failing scheduled runs — rendered in the always-on notifications center for every user (unlike budget_alerts, which is admin/tenant_admin only). Each entry is { kind: "agent"|"prompt"|"workflow"|"email"|"content_withheld", schedule_id, name, reason, failed_at?, delivery, delivery_status?, approval_blocked?, email_drop?, run_id?, gateway_id?, trigger_kind?, withheld_cause? } (delivery: true = the delivery-failed-on-success state; delivery_status is present on delivery entries only — one of failed, blocked_ssrf, blocked_tenant, blocked_changed, output_missing — and selects the notification wording for an approved result that can never arrive). An entry with approval_blocked (payload_logging_off | request_logging_disabled) is not a failed run but a warning: the caller's enabled schedule requires approval, but approved results can no longer be delivered (see Refused up front); it has no failed_at and its reason is an English explanation. A kind: "email" entry is an email trigger that skipped an inbound email (schedule_id = the trigger id, name = the workflow's, email_drop = too_large | unreadable | rejected); see Skipped emails. A kind: "content_withheld" entry is a workflow run whose email or form content was withheld by the PII fence (schedule_id = the workflow id, run_id / gateway_id locate the run, trigger_kind = email | form, withheld_cause = the cause literal; delivery: false); it shows the newest such run per workflow until a later run of that workflow succeeds — see Run fields. For an agent schedule a run failure shows while it is the newest run (any newer run clears it, as before); a delivery failure is taken from the successful run whose delivery finished last (by the time the delivery outcome was recorded, not the run's start — so an older approved result whose delivery fails after a newer run was already delivered still shows); a result still waiting for approval or still being delivered does not hide an earlier delivery failure, an expired or denied hold is not a delivery and never hides one, and a run failure takes precedence. failed_at is the time the alert is about (the delivery's finish time for a delivery failure; else the schedule's last run time). The projection is owner-scoped in SQL (created_by = the caller); a tenant admin additionally sees rows whose owner is NULL (an orphaned/erased schedule that would otherwise be invisible) — never another member's rows. The array is always present ([] when none); a projection read error degrades to [] (logged) and never fails /me. The center is non-dismissible — a broken automation cannot be swiped away.
  • No more silent auto-disable. A repeatedly-failing schedule stays enabled. Instead, an interval schedule's next run is pushed later by a bounded exponential backoff (interval_sec × 2^min(cf, 6), capped at 24 h, only ever forward) so a fast-interval schedule cannot bill every minute forever; the backoff resets to the base cadence on the next success. daily/weekly schedules keep their exact chosen cadence (widening them would skip a chosen fire). Once the 5 most recent scheduled runs since the schedule was last armed have all failed, an interval workflow schedule stops starting runs (next_run_at is pushed 24 h ahead on every fire) until it is saved with enabled: true; daily/weekly workflow schedules keep their exact cadence. (An owner can still disable a schedule manually; that is unchanged, and a manually-disabled schedule produces no failing_runs alert.)

Proactive token pre-expiry warning

The single most damaging silent failure is an auth/service token expiring unnoticed: a scheduler service token that lapsed took six scheduled agents down for days with no warning. To make that impossible, a daily sweep warns a token's owner before it expires:

  • When. Once per day the scheduler triggers a server-side sweep of every auth_token whose expires_at falls within the next 7 days and is not yet lapsed (a pre-expiry warning, not a post-mortem). Ephemeral playground tokens (30-minute UI probes) and the tokens the gateway manages itself (device sign-in tokens and MCP OAuth grant tokens) are excluded — they expire or are renewed by design. The 7-day window matches the "expires soon" badge in the gateway's Auth Tokens table, so the two never disagree.
  • Who is warned — resolved server-side (never from a request). A user token warns its owner (the auth_token.user_id account). A service token (user_id NULL — a class which has no user owner) warns the active tenant-admins of the token's gateway's tenant (deleted or admin-disabled accounts are skipped; the same applies to a user token's owner). A token on a gateway of a soft-deleted tenant is not warned at all: no e-mail, no in-app alert, and it is not stamped, so restoring the tenant re-arms the warning. The recipient set is derived entirely server-side from the token id inside the internal sweep route; a client can never redirect the warning to another address, and the admin fan-out is tenant-fenced in SQL — never cross-tenant (invariant 11).
  • Two channels. (1) An account email — for a service token it explicitly warns that scheduled automations will stop when it lapses, and reminds the reader that a token issued with no expiry date never lapses. (2) An in-app alert on /me (see below).
  • At most once per token per window (dedup). Each warned token records the time it was warned (auth_token.last_expiry_warned_at, unix seconds); the sweep re-warns only when that watermark is unset or predates the current warning window (expires_at − 7 days). So repeated sweeps inside one window send nothing after the first, while extending a token's expiry (which opens a fresh window) correctly re-arms exactly one new warning.
  • Suspended tenant. The warning mail is not sent while the token's tenant is suspended; the in-app alert stays and the token is marked warned, so the warning window passes without a mail. If the tenant's state cannot be read, the mail is not sent either, but the token is not marked warned and the next daily sweep tries it again. See Messages while suspended.
  • Recipient-less tokens. A token whose owner was GDPR-erased or admin-disabled, or a service token on a tenant with no admins, sends no email — but the in-app /me alert still surfaces it (invariant 4), and the watermark is still stamped so a daily no-op email is not re-attempted. A token of a soft-deleted tenant is a different case: it is not scanned, so it is neither mailed nor stamped, and it reappears in the sweep once the tenant is restored (if still inside its window).
  • In-app alert on /me. GET/PATCH /admin/auth/me returns an expiring_tokens array — the caller's OWN soon-expiring tokens (a tenant admin additionally sees the tenant's service tokens) — rendered in the same always-on notifications center as failing_runs, for every user. Each entry is { token_id, gateway_id?, label, expires_at?, service } (service: true = a no-owner gateway service token, shown with the "automations will stop" wording). The projection is owner-scoped in SQL (auth_token.user_id = the caller; a tenant admin additionally sees user_id NULL) and tenant-fenced. The array is always present ([] when none); a read error degrades to [] (logged) and never fails /me. Like failing_runs, it is non-dismissible.
  • Safe default at mint time. The token create/edit form defaults to no expiry (leave the field blank), which is the right choice for a service or scheduler token — a token that never lapses cannot die silently. The scheduler creates its own gateway service tokens with no expiry, and creates a new one when its token is missing, expired or revoked.

Delivery approval — human-in-the-loop (HITL) gate

An unattended (scheduled) run whose result is delivered to an external destination (email / webhook / Mattermost) can require explicit human approval before it is sent. This is opt-in per schedule and defaults OFF — existing schedules keep auto-delivering exactly as before.

Opt-in field: require_approval

Create or update a schedule with require_approval: true (a strict JSON boolean — any other type is rejected 400). When set, a succeeded run whose output_action.kind is side-effecting (email / webhook / mattermost) does not auto-deliver: the run executes and produces output, but delivery is held — the run's delivery_status becomes await_approval and a pending approval appears in the inbox below. A schedule with output_action.kind: none is unaffected (nothing is delivered, nothing is held).

If nobody decides within 24 hours the hold expires and is denied — the output is never delivered (fail-closed; an unapproved run never silently egresses).

The held output is not copied: it is referenced by the run and re-fetched at delivery time. This requires payload logging to be enabled on the gateway and the request_log retention to exceed the 24h approval window (both hold by default). If the stored output cannot be re-fetched at delivery, the approved delivery fails closed to output_missing (never a blank or wrong send) and the schedule's owner is notified.

Refused up front when an approved result could never be delivered

A schedule that would hold its results (enabled, require_approval: true, a side-effecting output_action) on a gateway where the approved result can never be re-fetched is refused instead of saved — on create, on an update that touches the hold (enabling the schedule, turning approval on, or setting / changing its destination), and on run-now:

Cause Code HTTP
Request logging is disabled for the organisation approval_undeliverable_request_logging 400 (create / update), 409 (run-now)
The workspace's privacy mode is on approval_undeliverable_tenant_content_logging 400 (create / update), 409 (run-now)
The gateway's Log request/response payloads (log_payloads) setting is off approval_undeliverable_payload_logging 400 (create / update), 409 (run-now)

The body is { "error": "<English explanation>", "code": "<code>" }; the web app shows its own localized message naming the setting. The check is made on the schedule's resulting state, merged exactly as the update is stored (a field that is absent or JSON null keeps its stored value): disabling the schedule, setting require_approval: false, or setting the destination to { "kind": "none" } is always accepted. An update of a schedule that already holds and still holds with the same destination — a rename, a new prompt (input), a new cadence, or the full form re-sent with the destination unchanged — is saved normally, even while the setting is off; the schedule stays flagged (below). "Same destination" compares the destination kind and its routed field exactly (url for a webhook, channel_id for Mattermost, to for email — a different address, even one differing only in letter case, is a change); other keys in output_action are not part of the destination. The web app's edit form sends output_action only when the destination was actually edited, so saving it unchanged never counts as a destination change. An update that does not touch the hold does not read the settings at all. A gateway or organisation that no longer exists is 404; a failure to read the settings is 503 { "error": "temporarily unavailable; retry later" } and nothing is saved; a gateway configuration that is stored but cannot be decoded (or names no organisation) is the sanitised 500 { "error": "internal error", "request_id": "…" } — permanent, so a retry would fail the same way — and nothing is saved. A held four-eyes change re-runs the check when it is approved — only if it touches the hold, judged against the schedule as it is then (a refusal fails the approval; a read failure retries it). The gateway setting is read the way inference reads it (cached per gateway node for the gateway-config cache TTL — one minute by default), so a change can take that long to be seen here.

If the setting is switched off after a schedule was saved, the schedule is flagged instead: GET .../schedules, GET .../schedules/{id} and the 200 body of PATCH .../schedules/{id} add approval_blocked (payload_logging_off | request_logging_disabled) to that schedule, and its owner's notifications center shows a warning (failing_runs entry with approval_blocked, above). The flag is computed on every read — nothing is stored — and disappears once the setting is back on, approval is turned off, the destination is removed or the schedule is disabled. If the settings cannot be read, the two GETs answer 503 { "error": "temporarily unavailable; retry later" } (never a row silently missing its flag); the PATCH answers the sanitised 500 { "error": "internal error", "request_id": "…" } — the update was saved, re-read the schedule instead of saving again. A gateway configuration stored corrupt makes the single GET the sanitised 500; the list then shows the schedule without a flag. If reading a schedule create or update back fails, the change and its audit entry are rolled back with it (retryable 503, or the sanitised 500 when the outcome is unknown — list the schedules before repeating it); if the row vanished in between, the create answers 201 { "id" } and the update 200 { "id" }.

Concurrent saves

The check and the write are atomic: an update that writes enabled, require_approval or output_action is stored only if those three fields still hold exactly the values the check was made on (output_action compared byte for byte as stored). So two saves that are each allowed on their own — one enabling the schedule, the other setting its destination — can no longer combine into a schedule that holds results that could never be delivered. When another save changed one of those fields in between, nothing is written and the update is re-checked against the schedule as it is now:

Re-check result Response
The combined result would be refused the refusal above (400 + approval_undeliverable_*)
The update no longer validates against the current schedule (for example its cadence kind changed) that validation error (400), exactly as a fresh request would get it
The schedule was deleted in between 404 { "error": "schedule not found", "code": "schedule_not_found" }
The gateway or organisation is gone, or its logging settings cannot be read 404 / 503, as in the refusal section above
The update would be allowed now 409 { "error": "<English text>", "code": "schedule_conflict" } — reload the schedule and send the change again
The re-read of the schedule fails 503 { "error": "temporarily unavailable; retry later" } — nothing was written; send the change again

The re-check runs the same validation and refusal as a fresh request against the schedule as it is now; whatever it answers is returned unchanged. New with this check: the 409, the 404 for a schedule deleted in between (before, that save answered 200 although nothing was written) and the 503 when the re-read fails; every other row is exactly what a fresh request gets.

Updates that write none of the three fields (name, prompt, cadence), and updates that by themselves rule out a hold (disabling the schedule, require_approval: false, destination { "kind": "none" }), are never conflicted — a concurrent edit can never block pausing a schedule (a deleted schedule is still 404). The single exception: such a patch that also re-sends the stored e-mail address unchanged, where that address fails today's check, is conditional as described under output_action above (a valid address re-sent unchanged does not make it conditional). A held four-eyes schedule update that loses such a race leaves the approval pending (503); approving it again re-checks it against the schedule as it is then. The web app shows its own localized message for schedule_conflict and for a schedule deleted meanwhile (404 schedule_not_found — matched on the code; any other 404 keeps the generic error), and reloads the schedule list — after an enable/disable toggle, and after an edit (the edit form closes, since its values are no longer current). This closes races between saves only: the gateway setting itself is read through the gateway-config cache (see above), so a save made within that window after the setting is switched off on another node is flagged like any schedule whose setting changed later, rather than refused.

List approvals (tenant governance)

GET /admin/v1/agent-approvals?status=pending

Authz: the EGRESS_APPROVE permission (built-in admin / tenant_admin, or a custom role granting it) — approving an egress is a tenant governance action. A session without a tenant gets 401. Tenant-scoped: you only ever see your own tenant's approvals; a cross-tenant id is never revealed. status (optional) must be one of pending|approved|denied|expired|closed|all — any other value, a repeated status or a valueless status is rejected 400 with code: invalid_status (omitting it, an empty status=, or all returns every status). The response is { "approvals": [...] } ([] when none); a failed read is 503.

Each row carries the agent name/slug, the output_kind (e.g. email) and a short action_summary (e.g. email / 1234 chars), the timestamps, and the run's real delivery_status. It never returns the recipient or the answer.

A decided row also carries decided_by (absent while the hold is undecided: pending or expired). The deciding person is shown by the actor rendering rule (see the Agent approval decider table): Myra staff as Myra staff stf_…, an erased account as erased, a member of your workspace by id. The platform view stays unredacted.

Approve / deny

POST /admin/v1/agent-approvals/{id}/approve
POST /admin/v1/agent-approvals/{id}/deny

Authz: EGRESS_APPROVE, tenant-scoped. Both are POST-after-auth. The decision is a single tenant-scoped compare-and-swap:

  • approve flips a pending hold to approved; the scheduler delivers it on its next tick via the existing egress path (all three gates — empty-output, PII-active, SSRF / tenant-allowlist — re-run, and the destination is re-checked against what was approved; a schedule edited after approval fails closed to blocked_changed, and the schedule's owner is notified). A result whose delivery disposition is approval_1 / approval_2 is then held for a delivery release (waiting_release) like any other scheduled delivery. Approving an expired hold is refused (409) — the TTL can never be bypassed.
  • deny flips it to denied; it is never delivered.

Responses: 200 on success; 404 if the id is not in your tenant, or if the approval's run, schedule or gateway no longer exists (such an approval is kept as a record but can no longer be listed, read or decided; it is never delivered). If that parent disappears while the decision is already in flight, the answer is still 404, never 409, and nothing is written; 404 { "error": "tenant_not_found", "code": "tenant_not_found" } if the organisation itself is being deleted while the decision is written (nothing is recorded); 409 if it was already decided (or, for approve, already expired). A failed read, or a decision that wrote nothing (a transient conflict), is 503 { "error": "temporarily unavailable; retry later" } — approve / deny again; any other database fault is 500 { "error": "internal error", "request_id": "<id>" } (the decision may or may not have landed — reload the list before deciding again). Each decision is recorded in the control-plane audit log (agent_approval.approved / .denied) with the deciding admin (best-effort write: a failed audit insert is logged server-side and never blocks the decision).

Delivery releases

A scheduled agent run whose delivery disposition is approval_1 or approval_2 and whose schedule delivers to an external channel (webhook, mattermost, or email to an address that is not an active user of the same tenant under the tenant's internal-delivery opt-in) is held for release instead of being refused. The gateway opens one release per run and channel (a review_item of kind delivery_release); the run records delivery_status: waiting_release and the owner gets the release notice. Every other run with these levels (no schedule, a workflow run, an internal channel, no owner to release it) keeps the blocked_pii path.

  • Approvers. approval_1: the schedule's creator, or the agent's owner when the schedule has none (the owner). approval_2 (four-eyes): the owner first (pending → awaiting_second), then a different person who holds GOVERNANCE_MANAGE and is neither the owner nor the first decider (awaiting_second → approved).
  • Expiry. A release expires after the agent's approval window (tool_config.approval.ttl_seconds, default 7 days). The expiry sweep sets expired; the run then records release_expired.
  • Content-free. A release stores and returns no value of the run: the channel label, the sources (connector ids and names, built-in source ids), the places (fetched hosts, tool names), entity types with counts, and whether the run also carried untrusted content. The result itself is re-read from the request log when it is delivered, so the gateway must log request/response payloads (as for the delivery approval).

Personal routes

All routes are tenant-scoped to the session (a session without a tenant is 401 {"error": "unauthenticated"}), refused while impersonating (403 impersonation_forbidden), and decided on the server; the client is never the authorisation boundary. {id} must be 1-64 characters of A-Z a-z 0-9 -, else 400 {"error": "bad id"} before anything is read. A permission read that fails is 503; a storage fault is 503 {"error": "temporarily unavailable; retry later"}.

Route Answer
GET /admin/v1/me/delivery-releases 200 {"items": [Release]} — the releases the caller can decide now: pending where the caller is the owner, and (caller holds GOVERNANCE_MANAGE) awaiting_second where the caller is neither the owner nor the first decider. Not expired. Newest first, at most 200. [] when none.
GET /admin/v1/me/delivery-releases/count 200 {"count": n} — the same predicate (the Approvals badge).
GET /admin/v1/me/delivery-releases/{id} 200 Release when the caller is the owner (any status), or a GOVERNANCE_MANAGE holder who is neither the owner nor the first decider while the release is awaiting_second. Anyone else, an unknown id, another tenant's id: 404 {"error": "not found"} (never 403 on the read).
POST /admin/v1/me/delivery-releases/{id}/release Body absent, {} or {"confirm_untrusted": true}. 200 {"status": "awaiting_second"} (the owner's release of an approval_2 release) or 200 {"status": "approved"}.
POST /admin/v1/me/delivery-releases/{id}/reject Body ignored. 200 {"status": "denied"} — by the owner while pending, or by the second approver while awaiting_second.

Decision refusals (release and reject):

Status Body When
400 {"error": "confirm_untrusted must be true when present"} Release: confirm_untrusted is present and not true, false or null (a string, a number). A body that is not a JSON object is 400 malformed_body.
400 {"error": "confirm_required"} Release of a release whose run also carried untrusted content (tainted: true, or a stored detail that cannot be read) without "confirm_untrusted": true.
403 {"error": "own_request"} The release is awaiting_second and the caller is the owner or the first decider: the second step must come from another person.
403 {"error": "forbidden"} The caller holds no GOVERNANCE_MANAGE and is not the release's approver (e.g. a member at the second step). The answer depends only on the caller's permission, never on whether the id exists; a caller who holds GOVERNANCE_MANAGE and is not an approver gets the 404 below.
404 {"error": "not found"} Unknown id, another tenant's id, a pending release of which the caller is not the owner, a decided release the caller never had a part in, or the release's agent, run or gateway is gone.
409 {"error": "already_decided"} The release is no longer undecided (approved, denied, expired, closed) and the caller is its owner, first decider or decider; also a decision that lost a race.
409 {"error": "expired"} The release is still undecided but its deadline has passed.

A won decision writes its audit row in the same transaction (delivery_release.first_released, delivery_release.released or delivery_release.rejected, entity review_item) and emits one SIEM approval_decision event; an expiry emits one with the decision expired. A write fault is 503 (nothing recorded, retry) or 500 (outcome unknown: reload before deciding again). A delivery release never appears in GET /admin/v1/review-items or /admin/v1/me/tool-approvals, and the review decision API answers 404 for its id.

Second-approver notice. A won owner release that answers 200 {"status": "awaiting_second"} schedules, off the request path and at most once per release, one notice to every eligible second approver: an active user of the release's tenant, not the owner, not the first decider, whose effective permissions (the same resolver the decision uses) include GOVERNANCE_MANAGE. Each gets the e-mail template delivery-release in mode second (subject "Agent: a result needs your second approval"), a push (flat string map: kind = "delivery_release", review_id, title, body, path = /approvals/delivery/{id}; the mobile apps open themselves without a deep link for this kind) and, where connected, a Slack / Mattermost direct message with a link to the card. The content is the agent's (or the workflow's) name, the run's time, the source names, the channel label and the deadline; never a value of the result, never the places it was found. Nothing is sent for an approval_1 release, a rejection, the second release or a decision that lost the race (409). A test-fixture address gets nothing; a recipient already told of another release of the same agent that still waits for its second approval within the last 15 minutes is not told again. A failed notice is logged and never changes the decision's answer.

Release (all times unix seconds):

{
  "id": "…", "status": "pending",
  "requested_at": 1794000000, "expires_at": 1794604800,
  "gateway_id": "…", "agent_id": "…", "agent_name": "Press review",
  "run_id": "…", "schedule_id": "…", "trigger_kind": "schedule", "run_started_at": 1793999950,
  "owner_id": "…", "owner_name": "Alice Example", "is_owner": true, "is_first_decider": false,
  "level": "approval_2", "approvals_needed": 2, "approvals_done": 0,
  "first_decided_by_name": null, "first_decided_at": null,
  "channel": { "kind": "webhook", "label": "hooks.example.com", "external": true },
  "sources": [ { "kind": "builtin", "id": "web_pages", "name": null, "places": ["heise.de", "faz.net"] },
               { "kind": "connector", "id": "<connector id>", "name": "YouTrack", "places": ["get_issue"] } ],
  "types": {},
  "tainted": false,
  "schedule_cadence": { "kind": "daily", "interval_sec": null, "daily_at": "07:00", "daily_dow": null }
}
  • status: pending, awaiting_second, approved, denied, expired or closed (released and handed to the delivery). approvals_done is 1 only while awaiting_second.
  • trigger_kind: schedule, webhook, workflow, chat or manual (a release is opened for scheduled runs, so in practice schedule).
  • channel.kind: webhook (label: the URL's host, never its path or query), mattermost (label Mattermost #<channel name> or Mattermost) or email (label: the address). external is always true.
  • sources: in first-seen order, at most 32 sources with at most 16 places each. kind is connector or builtin; the prompt reads as {"kind": "builtin", "id": "prompt"} and an unknown place as id: "unknown". name is the connector's name (null for built-in sources).
  • types: entity types and counts, for example {"PERSON": 4, "EMAIL_ADDRESS": 1}; {} when none were recorded.
  • tainted: the run also carried untrusted content (a workflow trigger payload, or a chat-bridge turn with untrusted content); the release then needs confirm_untrusted: true.
  • schedule_cadence: the cadence of the run's schedule, the way the schedule stores it: kind interval (interval_sec, whole seconds >= 1), daily (daily_at, "HH:MM" UTC) or weekly (daily_at and daily_dow, 0 = Sunday … 6 = Saturday); the fields a kind does not use are null. null when the run has no schedule, its schedule was deleted, or the stored cadence is not one of these shapes (it is never passed through). The console shows "Schedule · daily at 07:00 UTC", and "Scheduled run" when the cadence is null. A client treats a missing key as null, and a present value of any other shape as a malformed release.

Delivery after the release

The scheduler's release sweep delivers an approved release through its ordinary delivery path, at most once:

  1. Re-check. The gateway re-evaluates the run's sources under the current policy (trust class or override, minimum for every source, the agent's tightening). If any now resolves to block, or a connector cannot be read, nothing is sent: the run records blocked_pii and the owner gets the content-free blocked notice.
  2. Claim. The release moves to closed and the run from waiting_release to delivering in one step; only one sweep wins.
  3. Send. A destination changed since the hold gives blocked_changed; a result that is no longer stored gives output_missing; otherwise the result is delivered with the usual SSRF, tenant and recipient checks and the run records the outcome (delivered, failed, …).

A denied or expired release whose run still waits records release_denied / release_expired on the run (one winner) and the owner gets the not-released notice.

Run delivery states. agent_run.delivery_status gains waiting_release (external delivery held), release_denied (rejected, not delivered) and release_expired (nobody released it in time, not delivered). The runs list and the run detail carry the release fields.

Owner notices (POST /v1/{tenant}/{gateway}/agents/{slug}/deliver-email, service token only, always to the server-resolved schedule owner): notice accepts, besides blocked_pii, waiting_release, release_denied and release_expired. These need release_id (1-64 characters of A-Z a-z 0-9 -, else 400 "release_id is required for a release notice"), naming a delivery release of this agent in this tenant (else 400 "release not found for this agent"); release_denied / release_expired also need the release in that status (else 400 "release is not denied" / "… expired"). Only waiting_release accepts text (a string, else 400 "text must be a string"): the owner's own copy, attached as result.txt only when the owner's address passes the internal-delivery check (active same-tenant user and the tenant's opt-in), cut to the delivery limit; otherwise the notice goes out without it. text with any other notice is 400 "notice and text are mutually exclusive"; any other notice value is 400. Success: 200 {"notified": true, "copy_attached": true|false}. The notice names the agent, the run time, the sources, the channel and (waiting / expired) the deadline, never content, and links the release card /approvals/delivery/{id} while the release waits (button Open in Approvals) or, once it was rejected or expired, the agent's runs /agents/{gateway_id}/{agent_id}?view=runs (View the run); it is localised (English / German) by the owner's locale.

Internal scheduler routes (POST /internal/scheduler/…, internal scheduler secret only; every field validated before any read, a malformed value is a named 400, a storage fault 500 {"error": "db"}):

Route Body Answer
/deliver-clearance {run_id, channel?} As above, plus the hold answer 200 {"cleared": false, "held", "disposition", "reasons"} (idempotent per run and channel). channel is an optional hint (mattermost, webhook, email or null, else 400 bad_channel); the gateway derives the channel from the stored schedule and never trusts the hint.
/due-delivery-releases {now, limit} 200 {"releases": [...]} — approved releases whose run still waits, with the schedule's delivery fields and the stored result reference; 400 bad_now / bad_limit.
/claim-delivery-release {release_id, run_id, now, lease_owner, lease_secs} 200 {"won": bool, "recheck": "ok" \| "block"}. Only the release of the named run is claimed (another run's release: won: false). recheck is ok only when the run's sources, read under the current policy, still allow what the release allowed: allow, approval_1, or approval_2 for a release that had two approvals; internal_only, block, a raised approval level or an unreadable stored level is block (not delivered). 400 bad_release_id / bad_run_id / bad_now / bad_lease_owner / bad_lease_secs. A re-check read fault is 500 with nothing claimed.
/due-closed-releases {now, limit} 200 {"releases": [...]} — denied / expired releases whose run still waits.
/settle-closed-release {release_id, run_id, status, error?} status release_denied or release_expired (else 400 bad_status), error at most 500 characters (else 400 bad_error). 200 {"won": bool}; only the winner sends the notice.

Publish-time review governance (KI-Governance)

Complements the runtime HITL delivery gate: this governs the agent's own publish lifecycle. Every agent carries a review_status — draft | in_review | approved | flagged | disabled — surfaced on the agent GET (the decision provenance reviewed_by/reviewed_at is owner-only; redacted for sharees). The agent GET for the owner, tenant_admin and admin also carries, for the status banners: reviewed_by_name (display name of reviewed_by, only while the agent is disabled; absent when the user is gone or the read failed) and review_pending_required (true only while the agent is in_review and the tenant requires review; a failed read of that setting answers 503). The reviewer's flag note is never part of the owner's agent read. spend_month_to_date_usd (raw USD spent this calendar month, same basis as the spend limit) is present only when a limit is set, for the owner, tenant_admin / admin and AGENTS_REVIEW holders; it is absent when the read failed. None of these three fields reach sharees or other readers. Only an approved agent is reachable in the org catalog (and, for a review-required tenant, org-publish is refused for a non-approved agent). This is regression-safe: every existing agent is backfilled approved.

Per-tenant opt-in

PATCH /admin/v1/tenants/{id} accepts agent_review_required (0|1, default 0), and GET /admin/v1/tenants/{id} (and the tenant list) return the current value so a client can read the setting back. When 1: new agents are created draft (must be approved before org-publish), and the org-publish gate requires approved. Default 0 ⇒ new agents born approved, publish works as before. The flag/disable kill-switch and the approved-gated catalog visibility apply to ALL tenants (additive governance — they only take effect when someone explicitly acts).

Transitions

POST /admin/v1/gateways/{gw}/agents/{id}/review/submit        (owner or admin)
POST /admin/v1/gateways/{gw}/agents/{id}/review/approve       (AGENTS_REVIEW governance)
POST /admin/v1/gateways/{gw}/agents/{id}/review/flag          (AGENTS_REVIEW governance)
POST /admin/v1/gateways/{gw}/agents/{id}/review/disable       (AGENTS_REVIEW governance)
POST /admin/v1/gateways/{gw}/agents/{id}/review/reactivate    (AGENTS_REVIEW governance)
  (the four decisions: a non-admin reviewer acts only on agents they can see; any other agent answers the
   same 404 agent_not_found as a missing id, before any write)

Valid transitions (any other → 409 { "error": "invalid_transition" }, no state change, no audit). A successful transition answers 200 { "review_status": "<new status>" }. If the tenant is purged while the decision is being written the answer is 404 { "error": "tenant_not_found" }: the status is not changed, no history row is written and no audit entry is made. The optional note (flag) and the required reason (disable) are described in Review decisions; submit, approve and reactivate take no body fields.

decision from to who
submit draft, flagged in_review owner or admin / tenant_admin (AGENTS_AUTHOR + edit access to the agent)
approve in_review approved governance (gateway access + AGENTS_REVIEW)
flag in_review, approved flagged governance
disable draft, in_review, approved, flagged disabled governance
reactivate disabled draft governance

Governance decisions require BOTH access to the gateway (the tenant fence — a reviewer can only govern their own tenant's agents) AND the AGENTS_REVIEW permission; they stamp reviewed_by/reviewed_at and audit-log agent.review.<decision>. submit is an owner action (no stamp). A flag/disable immediately drops the agent from the org catalog and every non-owner org path; the owner keeps full access. Beyond the built-in ki_manager/tenant_admin/admin roles, a custom tenant role granted AGENTS_REVIEW can also make these governance decisions. The governance routes are not behind the agents_enabled gate (a pending review stays resolvable when Agents is turned off); submit is.

Re-check on update

In a review-required tenant, editing an already-approved agent (a PATCH .../agents/{id} or a version restore that changes run-affecting config) invalidates that approval: the agent is downgraded approved → in_review atomically in the same transaction as the config write, so it immediately leaves the org catalog until a ki_manager re-approves the new config. Only approved downgrades — a flagged/disabled agent stays in its blocked state (an owner cannot un-flag/un-disable by editing), and draft/in_review are already unapproved. Default-OFF tenants are unaffected. The reset is visible in the agent.updated audit's review_status before/after.

Invoke-time enforcement (runtime teeth)

A flagged or disabled agent is not directly invokable — the data-plane /agents/{slug}/invoke fails closed for every caller, including the agent's owner and the scheduler service token, regardless of the tenant's review switch (a governance STOP is absolute, not merely a catalog-visibility change). The rejection mirrors the run-as-owner ACL: it returns AGENT_NOT_FOUND so a blocked slug cannot be probed. draft/in_review/approved stay invokable (an owner may test a not-yet-approved draft; approved is the normal live state).

Run history and audit trail (transparency)

These read-only endpoints reconstruct what an agent did, from storage alone — no live re-run.

List agent runs

GET /admin/v1/gateways/{gateway_id}/agents/{agent_id}/runs

Returns the recent runs of the agent as a JSON array. Required role: the agent's owner, or tenant_admin/admin (a non-owned or unknown agent returns 404 — the same gate as Read one agent run). The array is empty when the agent has never run. Runs the gateway created for an unattended call without a run id are listed too.

Each row carries the run record (id, schedule_id, trigger_id, workflow_run_id, bridge_driver_id, status, http_status, error, request_ref, agent_version, delivery_* — including delivery_disposition (allow | internal_only | approval_1 | approval_2 | block, or null when never recorded) and delivery_reasons (array of <source>:<where> strings, or null), see Delivery disposition —, started_at (the start of the run's first leg, not of the resumed leg), finished_at, created_at; newest first, at most 200) plus request_refs (array of strings: the request reference of every leg of the run in the order the legs started — a run that paused for an approval and resumed has one per leg; request_ref stays the final leg's) and three enriched fields, each read in one batched statement for the whole list (a failed read answers 503, never a list silently missing a value):

Field Type Meaning
cost_usd number or null Raw provider cost in USD (list price, before markup) of the request-log entries of the run, summed per request_ref; null when the run has no logged cost.
caller_name string or null Display name (never the e-mail address) of the chat-bridge driver of the run, same tenant only; null for schedule, webhook and workflow runs, and for a deleted user. Clients label those by type from schedule_id / trigger_id / workflow_run_id.
question string or null Owner only. The text the schedule was configured with (agent_schedule.input) for a schedule run, clamped to 500 characters; null for any other run type. The key is absent for an admin who is not the agent's creator, and for an administrator in a View as user session, even when the viewed user is the agent's creator.

delivery_status is one of the existing values or, for a delivery release, waiting_release, release_denied or release_expired. Each row also carries the run's release fields, read in one batched, tenant-fenced statement (a failed read answers 503); all are null when the run has no release:

Field Type Meaning
release_id string or null The release (/admin/v1/me/delivery-releases/{id}).
release_status string or null pending, awaiting_second, approved, denied, expired or closed.
release_count 1, 2 or null Approvals needed.
release_done 0, 1, 2 or null Approvals given: 1 while awaiting_second, all of them once approved / closed.
release_channel object or null { "kind": "mattermost" \| "webhook" \| "email", "label" }, as in the Release.
release_decided_by_name string or null Display name of the person who rejected it (denied), else null.
release_words integer or null The result's word count (runs of non-whitespace characters), recorded when the owner's "waiting for release" notice was sent; null when not recorded. A number only, never text of the result.
release_owner_copy_to string or null The owner's address shortened to its local part, for example "dana.weber@…", when the owner's own copy of the result went out with that notice (internal delivery allowed it); null otherwise.

Every row (with or without a release) also carries delivery_sources: the sources of the run's personal data, from its recorded delivery reasons, as [{"kind": "connector" | "builtin", "id", "name"}] in first-seen order (name: the connector's name, else null; places are not included). [] when nothing was recorded. A connector name that cannot be read leaves name null; the list is still answered.

Read one agent run

GET /admin/v1/gateways/{gateway_id}/agents/{agent_id}/runs/{run_id}

Returns one run fully reconstructed: { "run": { … }, "steps": [ … ] } (run carries request_refs, the request reference of every leg, delivery_disposition / delivery_reasons and the release fields, as in the list) — the durable run record plus its per-step trace (tool rounds, MCP discovery, and the termination reason) and the run's cost and token totals. The steps are metadata-only and carry no response content (the §12 transparency contract). Returns 404 when the run does not exist for that agent and gateway — and, so one owner cannot probe another's run ids, also 404 when the caller is a plain member who does not own the agent.

result — the run output, owner-only

result_expired: true (owner-only) is returned instead of result when the logged content was deleted by the operator-run payload expiry; the field is absent otherwise.

A single additional field, result, carries the run's model output — the de-tokenized text the agent produced (the real body, exactly as the client received it, with any PII restored). It exists so a scheduled run whose external delivery was blocked by PII policy is no longer empty to the person who owns it.

result is returned to the run's owner only — the user who created the agent (agents run as their owner). This is enforced server-side: the field is joined from the request log and added to the response only when the caller's own user id equals the agent's creator. The distinction matters because the route itself is also reachable by governance roles:

  • Owner (the agent's creator): receives result.
  • Tenant administrator / administrator who is not the creator: can read the run (status, steps, usage) for governance, but the response never includes result.
  • Any other member: 404 (cannot read the run at all).

result is absent (the key is simply omitted, never a masked or empty placeholder) when there is no stored body — an aborted run with no request reference, a gateway with payload logging turned off, or a row whose response was PII-scrubbed. The masked projection (response_raw) is never returned by this endpoint.

Read the steps of one sub-agent call

GET /admin/v1/gateways/{gateway_id}/agents/{agent_id}/runs/{run_id}/delegation/{child_run_id}/steps

Returns { "steps": [ … ] }: the steps of one sub-agent call of that run (the run detail's "Show steps"). A sub-agent call has no agent_run row of its own, so GET …/runs/{child_run_id} is a 404; this is the only way to read its steps.

  • Who may call it: whoever may read GET …/runs/{run_id} (the agent's owner, or a tenant_admin / admin); a member who does not own the agent gets 404. No new permission.
  • Accepted child_run_id: a UUID that is the child_run_id of an agent_delegate call in that run's delegation tree (the run's own trace and the traces of every sub-agent run it started, on the run's gateway), and whose trace is on that gateway. Anything else is rejected with the same 404 {"code":"delegation_call_not_found"}: a value that is not a UUID, a call of another run, a run on another gateway or tenant, an id that only a refusal names. An unknown run_id is 404 run_not_found.
  • Content: the same step-body rules as the run's own steps. On a run started by a sharee (an agent shared with a colleague), and for a reader who is not the agent's creator and sends no X-Read-Reason, every step is stripped to its metadata (step kind, numbers, flags, whitelisted codes) and the response adds "redacted": true. A non-creator who sends X-Read-Reason gets the bodies; the read is audited (request_log.content_read, entity = the sub-agent call's trace) before they are sent. A malformed X-Read-Reason is 400.
  • No stored trace (tracing was off for that call): 200 { "steps": [] }.
  • A read fault (the delegation tree, the sub-agent trace or its steps): 503, never an empty list.

Least-privilege recommendations

GET /admin/v1/gateways/{gateway_id}/agents/{agent_id}/access-recommendations?window_days=30

Read-only. Proposes which of the agent's granted connector rights it has not used within the window, so the owner can narrow its consent. Nothing is revoked or changed by this endpoint: proposals are advice, the owner decides. Required role: the agent's owner, or tenant_admin/admin (a non-owned or unknown agent returns 404, the same gate as List agent runs).

window_days is optional. Absent means 30. Otherwise it must be a plain decimal integer from 7 to 90 with no sign, decimal point, space or leading zero. Anything else (6, 91, 07, 30.0, +30, an empty value, a bare window_days key, a repeated key) is rejected with 400 bad_param, as is any other query parameter.

Response 200:

{
  "agent_id": "…",
  "generated_at_ms": 1792389000000,
  "status": "ok",
  "window_days": 30,
  "window_start_ms": 1789797000000,
  "coverage_since_ms": 1780000000000,
  "recommendations": [
    { "connector_id": "…", "connector_name": "Mail", "tool": null, "reason": "unused", "granted_since_s": 1785000000 }
  ]
}

tool is null when the whole connector is granted (a connector without tool narrowing), otherwise the tool name. connector_name is null when the connector no longer exists. granted_since_s is when the right was last continuously granted, taken from the agent's version history (newest first, contiguous run of versions that grant it). A missing or invalid timestamp is never read as epoch 0 but as "now": an invalid created_at on the agent yields agent_too_new, an invalid updated_at makes the fallback grant time "now", and a version row with an invalid created_at ends the contiguous run (all conservative, fewer proposals).

status is the first that applies:

  • consent_unreadable - the agent's current consent cannot be parsed. No proposals (fail closed).
  • agent_too_new - the agent was created less than window_days ago, so unused cannot be concluded. Only connector_deleted proposals are returned.
  • coverage_insufficient - the tenant has no decision records, or its oldest record is younger than the window (a fresh rollout, or a retention shorter than window_days). Only connector_deleted proposals are returned.
  • ok - unused proposals are included.

reason is connector_deleted (the consent still references a connector that no longer exists in the tenant; deleting a connector does not prune agent consent) or unused (granted for the whole window, no allow decision record for that connector and tool within it). Deny records do not count as use. A right whose current grant is younger than window_days is never proposed as unused, even when status is ok.

The same computation feeds the weekly least-privilege digest e-mail sent to agent owners (platform switch, default off).

Known limitations:

  • An interactive call whose decision record could not be written is invisible here, so that right can be proposed although it was used. Treat proposals as advice.
  • The grant time is read from at most the 200 newest agent versions. If all 200 grant the right, the 200th version's timestamp is used, which can only make the right look younger (conservative: fewer proposals).

The tenant-wide list across all agents, sorted by risk class, is GET /governance/least-privilege.

Read the gateway audit trail

GET /admin/v1/gateways/{gateway_id}/audit

Returns the control-plane audit events for all agents and schedules of the gateway — who created, changed, enabled, disabled, or deleted what, with redacted before/after values. Required: the REQUEST_LOGS_VIEW permission (built-in tenant_admin / admin) and access to the gateway (the trail spans every agent, so it is governance-scoped, not per-owner). The route is not behind the agents_enabled gate. Query parameters limit (default 100; a larger value is clamped to 500) and offset (default 0) page the result; anything but a plain integer (≥ 1 for limit, ≥ 0 for offset) is 400 {"code": "invalid_limit"} / {"code": "invalid_offset"}.

The same trail also lists the gateway's own security-relevant configuration events: guardrail_masker.deactivated, gateway.endpoint_config_changed (a change of where provider credentials are sent — base-URL overrides and Azure / Hugging Face endpoints, origin-only), gateway.provider_key.stored / .deleted (provider + alias, never the key) and gateway.managed_model.granted / .revoked. See Audit log — security events. A failed read of the trail answers 503 (retry), never an empty list.