---
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:**

All request-body fields are optional. When omitted, the server reuses
the original model/context. The body supports:
- `filters`
- `chatMode`
- `modelKey`
- `modelName`
- `modelFriendlyName`
- `timezone`
- `currentTime`
- `tools`

**Streaming behavior:**

The response is delivered as `text/event-stream`. Stable events are
`connected`, `complete`, and `error`. 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 SSE `error`
events after stream initialization.

## Path parameters

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

## Request body

- RegenerateRequest — Request body for regenerating an AI response. All fields are optional; when omitted the model selection and execution context from the original message are reused. Supported fields: - `filters` — optional `{ apps?, kb? }` filter object - `chatMode` — optional non-empty chat mode string - `modelKey`, `modelName`, `modelFriendlyName` — optional non-empty model override fields - `timezone` — optional non-empty client timezone string - `currentTime` — optional ISO 8601 / RFC 3339 datetime string with UTC `Z` or a numeric offset - `tools` — optional array of non-empty tool identifiers
  - `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 UUID (connector instance id, record-group id, etc.) or the org knowledge-base collection sentinel `knowledgeBase_<orgId>` (pattern `knowledgeBase_[a-zA-Z0-9_-]+`). Gateway validation matches Zod `appOrKbIdSchema`.
    - `kb` string[] — Knowledge-base / record-group ids to scope retrieval for this turn. Each element uses the same accepted formats as `apps`: a UUID or `knowledgeBase_<orgId>` (pattern `knowledgeBase_[a-zA-Z0-9_-]+`).
  - `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` string — Chat mode used for regeneration (for example `internal_search`, `web_search`, or an agent mode such as `agent:auto`).
  - `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.

## Response `200`

SSE stream established.

Stable event names:
- `connected` — confirms the stream is open
- `complete` — returns the updated conversation plus metadata
- `error` — reports lookup failures, authorization failures on
  the conversation, or regenerate-rule failures after the stream
  has started

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/abd27cfefc73/schema)
