Skip to content

Do not run the model twice when Conversation API completion retries #1686

Description

@dcramer

Problem

The Conversation API worker acknowledges input during a Run. The model can finish before Junior finishes saving the reply, Conversation state, checkpoint, and Turn event. If one of those later writes fails, a queue retry can run the model again and repeat work.

This behavior existed before #1682. That refactor must not hide it, but it must not add a new recovery design either.

Required behavior

  • After the model finishes, a retry must finish saving the result. It must not start another model Run.
  • Preserve the result: success, intentional no reply, or the original model failure code and event ID.
  • Store one visible reply. If recovery starts before the failure reply is stored, store the standard event-ID failure reply once.
  • Run plugin work after a recovered success or intentional no reply. Do not run it after a failure.
  • Leave the Conversation ready for a later Turn.

Design limits

Tests

Extend the main Conversation API integration scenario. Use the real queue, worker, and agent. Fake only model output.

Assert one model Run, one visible result, the correct final Turn event, plugin work after recovered success, and a normal following Turn. Add a component test only if a separate stored-result rule cannot be tested through that integration path.

Review findings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions