> ## Documentation Index
> Fetch the complete documentation index at: https://docs.revring.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Suggest a Fix for a Run

> Ask for one prompt change that would make every failed test in a run pass.

Requesting a fix per attempt produces separate prompts that do not know about each other, and applying one can undo another. This endpoint analyzes all of the run's failed attempts together and returns a single corrected prompt with a per-attempt breakdown, so failures that share a root cause get one coherent edit.

The wait, polling, and reuse behavior is identical to the per-attempt Suggest a Fix: the request waits up to 105 seconds, `wait=0` returns `status: running` immediately for polling with Get Suggested Fix for a Run, asking again joins a preparation already in progress, and a suggestion prepared within the last 10 minutes is returned instantly.

The run must be finished and must contain at least one failed attempt. On runs with more than 12 failures, the most recent 12 are analyzed and the rest are listed in `result.skippedAttemptIds`.



## OpenAPI

````yaml POST /test-suites/{id}/runs/{runId}/suggest-fix
openapi: 3.1.0
info:
  title: RevRing Voice AI API
  description: >-
    RevRing Voice AI platform API for managing AI voice agents, phone calls, SIP
    trunks, and analytics. Build intelligent voice applications that can handle
    inbound and outbound phone calls with AI-powered conversational agents.
  version: 1.0.0
  contact:
    name: RevRing Support
    url: https://revring.ai
servers:
  - url: https://api.revring.ai/v1
    description: Production API
security:
  - apiKeyAuth: []
tags:
  - name: Messaging Connections
    description: Connect messaging providers so agents can send text messages
  - name: Messages
    description: Send text messages and read your message log
  - name: Conversations
    description: List and clear managed conversation threads
  - name: SIP Trunks
    description: Manage SIP trunks for connecting agents to the phone network
  - name: Agents
    description: Manage AI voice agents and their configuration
  - name: Agent Folders
    description: Organize agents into folders for dashboard navigation
  - name: Calls
    description: Manage and query phone calls
  - name: Analytics
    description: Get analytics and metrics about your calls
  - name: Knowledge Bases
    description: >-
      Manage knowledge bases and sources for agent retrieval-augmented
      generation
  - name: Test Suites
    description: Manage test suites, test cases, and test runs for agent evaluation
  - name: Voices
    description: Browse the voices available to your organization for agent speech
paths:
  /test-suites/{id}/runs/{runId}/suggest-fix:
    parameters:
      - name: id
        in: path
        required: true
        description: Test suite ID
        schema:
          type: string
          format: uuid
      - name: runId
        in: path
        required: true
        description: Test run ID
        schema:
          type: string
          format: uuid
    post:
      tags:
        - Test Suites
      summary: Suggest a Fix for a Run
      description: >-
        Ask for one prompt change that would make every failed test in a run
        pass.


        Requesting a fix per attempt produces separate prompts that do not know
        about each other, and applying one can undo another. This endpoint
        analyzes all of the run's failed attempts together and returns a single
        corrected prompt with a per-attempt breakdown, so failures that share a
        root cause get one coherent edit.


        The wait, polling, and reuse behavior is identical to the per-attempt
        Suggest a Fix: the request waits up to 105 seconds, `wait=0` returns
        `status: running` immediately for polling with Get Suggested Fix for a
        Run, asking again joins a preparation already in progress, and a
        suggestion prepared within the last 10 minutes is returned instantly.


        The run must be finished and must contain at least one failed attempt.
        On runs with more than 12 failures, the most recent 12 are analyzed and
        the rest are listed in `result.skippedAttemptIds`.
      operationId: suggestRunFix
      parameters:
        - name: wait
          in: query
          required: false
          description: >-
            Set to `0` to return immediately instead of waiting for the
            suggestion.
          schema:
            type: string
            enum:
              - '0'
      responses:
        '200':
          description: >-
            The suggestion, when it was ready in time. The suggestion fields are
            also present at the top level of `data`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/RunSuggestedFix'
        '202':
          description: >-
            The suggestion is being prepared. Poll Get Suggested Fix for a Run
            until `status` is `ready`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/RunSuggestedFix'
        '400':
          description: >-
            The run has not finished yet, or it has no failed attempts to
            analyze
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
components:
  schemas:
    RunSuggestedFix:
      type: object
      description: A proposed prompt change covering every failed attempt in a test run.
      properties:
        status:
          type: string
          enum:
            - idle
            - running
            - ready
            - failed
          description: >-
            `idle` = none requested for this run. `running` = being prepared.
            `ready` = `result` holds the suggestion. `failed` = could not be
            prepared, request another.
        result:
          type: object
          nullable: true
          description: The suggestion. Present when `status` is `ready`, otherwise null.
          properties:
            analysis:
              type: string
              description: >-
                Overall diagnosis across the run's failures, leading with a
                shared root cause when there is one
            changesSummary:
              type: array
              items:
                type: string
              description: Plain-language summary of what was changed
            suggestedPrompt:
              type: string
              description: The complete corrected prompt, ready to save to the agent
            currentPrompt:
              type: string
              description: >-
                The agent prompt the suggestion was written against, for
                comparison
            rubricIssues:
              type: array
              items:
                type: string
              description: Problems found in the test's pass criteria, if any
            perAttempt:
              type: array
              description: >-
                One entry per failed attempt analyzed, in the order the attempts
                ran
              items:
                type: object
                properties:
                  attemptId:
                    type: string
                    description: The failed attempt
                  testCaseName:
                    type: string
                    description: Name of the test that failed
                  analysis:
                    type: string
                    description: >-
                      Why this test failed and which part of the edit addresses
                      it
            skippedAttemptIds:
              type: array
              items:
                type: string
              description: >-
                Present only on very large runs: the oldest failed attempts
                beyond the most recent 12, which were not analyzed
        stale:
          type: boolean
          description: >-
            Present when `status` is `ready`. `true` means the agent's prompt
            has changed since this suggestion was written, so saving
            `suggestedPrompt` would overwrite those newer edits; request a fresh
            suggestion instead.
  responses:
    UnauthorizedError:
      description: Authentication required or API key invalid
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: unauthorized
    NotFoundError:
      description: Resource not found
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: not_found
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key for authentication. Generate API keys from the RevRing
        dashboard.

````