---
title: "Revise an agent prompt from a natural-language change, streaming the work"
method: POST
path: "/table-enrichments/saved-agents/prompt/edit/stream/"
tags: ["table-enrichments"]
---

# Revise an agent prompt from a natural-language change, streaming the work

`POST /table-enrichments/saved-agents/prompt/edit/stream/`

## Request

- Base URL: `https://api.getoneprofile.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.getoneprofile.ai/table-enrichments/saved-agents/prompt/edit/stream/`
- Auth: HTTP bearer

The streaming form of the revision: the same full revised prompt and one-sentence summary, sent as Server-Sent Events. The first frame is `turn`, carrying the `edit_id` a Stop is sent to; then a `step` frame for each thing the assistant actually did (`read_feedback` when `saved_agent_id` names an agent whose complaints to read, `rewrite_prompt` for the model call, `finish` with the line counts), each with its measured duration; then one `result` frame with the revision as the plain route returns it.

Failures arrive as an `error` frame, because the stream has already answered 200: reason `limit` or `paused` when the workspace's daily AI Assistant allowance refused the revision, `stopped` when the caller stopped it, and no reason for anything else. Counts against the allowance; a stopped or failed revision gives its turn back.

Closing the connection does not stop the revision; the Stop route does. Requires a signed-in person; the plain route serves API keys.

## Request body

- SavedAgentPromptEditRequestSchema: A natural-language change to make to an existing agent prompt.
  - `current_prompt` AgentPromptTemplateInput, required: A saved agent's prompt: literal text with references between the runs. The same convention every other stored prompt in the product uses (``EnrichmentPromptTemplate`` for columns, template segments for sequences): identity-keyed segments, so renaming what a reference points at never rewrites the prompt. Structurally parallel to the enrichment template rather than importing it: an agent prompt references INPUTS, an enrichment prompt references COLUMNS, and the import hierarchy keeps the two domains apart.
    - `segments` union[]
      - union
        - AgentPromptTextSegment: A literal run of prompt text.
          - `text` string, required
          - `type` 'text'
        - AgentPromptInputRefSegment: A reference to one declared input, resolved per row at run time.
          - `input_id` string, uuid, required
          - `type` 'input_ref'
        - AgentPromptContextRefSegment: A reference to the org's business context, resolved per org.
          - `section` 'all' | 'company' | 'icp' | 'personas' | 'signals' | 'social_proof': One section of the org's AI business context a prompt can reference. ``ALL`` is the whole context document; the rest are its named sections.
          - `type` 'context_ref'
  - `inputs` AgentInputSchema[]
    - `id` string, uuid, required
    - `name` string, required
  - `instruction` string, required
  - `saved_agent_id` string, uuid, nullable: Revise in the light of what people said was wrong with this agent's real results. The complaints are read server-side from stored feedback, so the client cannot put words in their mouths.

## Response `200`

A stream of Server-Sent Events; the final `result` frame's `data` is the revised prompt.

## Other responses

- `401`: Unauthorized
- `403`: Forbidden
- `422`: Invalid request made to the API.
- `500`: Internal server error.
- `502`: Bad gateway error.
- `503`: Service unavailable.

---

[API](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile.md) · [All operations](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile/llms.txt) · [OpenAPI document](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile/revisions/4a6bd71e3f02?raw)
