---
title: "Regenerate agent conversation message"
method: POST
path: "/agents/{agentKey}/conversations/{conversationId}/message/{messageId}/regenerate"
tags: ["Agents"]
---

# Regenerate agent conversation message

`POST /agents/{agentKey}/conversations/{conversationId}/message/{messageId}/regenerate`

Regenerate the AI response for a specific message in an agent
conversation and stream the new answer over Server-Sent Events.

**Constraints:**

- Only the last message in the conversation can be regenerated.
- The target message must be of type `bot_response`.

**Request body:**

`chatMode: quick` is required. Other fields are optional and reuse
the original model/context when omitted. The body supports:
- `filters`
- `chatMode`
- `modelKey`
- `modelName`
- `modelFriendlyName`
- `timezone`
- `currentTime`
- `tools`
- `protocol`
- `agentCapabilities`

**Streaming behavior:**

The response is delivered as an AG-UI `text/event-stream`. Stable
outcomes are `RUN_FINISHED` and `RUN_ERROR`; see
`AgentRegenerateSSEEvent`.

Additional agent/tool lifecycle events may be forwarded by the
backend and should be treated as informational updates.

Validation failures on params/body are returned as normal HTTP `400`
responses before the stream starts. Valid-shape requests that fail
conversation lookup or regenerate rules are reported as
`RUN_ERROR` events after stream initialization.

## Path parameters

- `agentKey` string, required
- `conversationId` string, objectId, required
- `messageId` string, objectId, required

## Request body

- AgentRegenerateRequest — Regeneration payload for a scoped agent conversation. The public gateway requires `chatMode: quick`; all other fields retain the semantics defined by `RegenerateRequest`.
  - `filters` Filters — App connector instance ids and knowledge-base / record-group ids that narrow retrieval for a turn. For **org assistant** chat streams, send explicit `apps` / `kb` lists. For **agent** chat streams, send explicit id lists, or **omit** `filters` (and `tools`) to let the service use the agent’s stored knowledge and tool configuration. Sending `{ "apps": [], "kb": [] }` on an agent stream means **no** knowledge sources for that turn (it is not “full org default”).
    - `apps` string[] — Connector instance ids to scope retrieval for this turn. Each element must be a valid UUID (connector app id, KB app id, record-group id, etc.). Gateway validation matches Zod `appOrKbIdSchema`.
    - `kb` string[] — Knowledge-base app ids to scope retrieval for this turn. Each element must be a valid UUID.
  - `modelKey` string — Identifier of the AI model configuration to use for regeneration. Typically a UUID returned by the model-management endpoints. When omitted, the model used for the original message is reused.
  - `modelName` string — Provider model name (e.g. the underlying LLM identifier).
  - `modelFriendlyName` string — Friendly display name of the selected model.
  - `chatMode` 'quick', required — Chat mode used for regeneration (for example `internal_search`, `web_search`, or the universal `agent` mode).
  - `timezone` string — IANA timezone identifier from the client. Used to provide time-aware context to the AI during regeneration.
  - `currentTime` string, date-time — ISO 8601 / RFC 3339 datetime from the client (UTC `Z` or numeric offset). Used to anchor any relative time references in the query.
  - `tools` string[] — Optional list of tool identifiers (fully-qualified action names such as `jira.create_issue`) the agent may invoke when regenerating. Applicable only in agent chat modes.
  - `protocol` 'agui' — AG-UI is the only supported wire protocol. When present must be `"agui"`. Omitting the field is equivalent — the server always uses the AG-UI vocabulary. Kept in the schema for backward compatibility with callers that already send it.
  - `agentCapabilities` AgentCapabilities — Per-request agent capability toggles. Only meaningful when `chatMode` selects an agent mode; ignored otherwise. Each field falls back to its own `default` below when omitted — a missing flag is not uniformly `true`. Omitting the whole object applies every default.
    - `internalSearch` boolean — Whether the agent may search internal knowledge bases for this turn.
    - `webSearch` boolean — Whether the agent may perform web search for this turn.
    - `deepSearch` boolean — Whether the agent may use deeper, higher-latency retrieval for this turn.

## Response `200`

SSE stream established.

Stable event names:
- `RUN_FINISHED` — `{ type, result }`, where `result` contains the
  updated conversation and metadata
- `RUN_ERROR` — `{ type, message, code? }`, reporting lookup,
  authorization, or regenerate-rule failures

Forwarded lifecycle and child-run events may include `runId`,
`threadId`, and `parentRunId`. Additional backend-defined
agent/tool events may be emitted.
Clients should ignore unknown event names.

## Other responses

- `400` — Validation failed for path parameters or request body. Common causes include invalid ObjectId formats, empty strings for fields that require content, malformed `filters`, invalid `tools` entries, or `currentTime` values that are not ISO 8601 datetimes with offset information.
- `401` — Unauthorized

---

[API](https://skmtc.net/pipeshub-ai/apis/pipeshub-api.md) · [All operations](https://skmtc.net/pipeshub-ai/apis/pipeshub-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/pipeshub-ai/pipeshub-api/revisions/64bfe76b130e/schema)
