Skip to content

Retry a refused request on a fallback model #488

Open

Description

@hakula139

Goal

When the model ends a turn with refusal, ox now rolls the turn back and asks the user to rephrase. Anthropic's streaming-refusal guide notes that resending a refused request to the same model usually results in another refusal and recommends retrying with a fallback model, either server-side or in the client, as its refusals and fallback page describes. oh-my-pi retries a classifier refusal on other models (packages/coding-agent/src/session/turn-recovery.ts). Let the user opt into the same recovery.

Acceptance criteria

  • A config setting names the fallback model to retry a refused turn on. By default, no retry occurs, so behavior stays as it is today.
  • When a fallback is configured, a refused turn is rolled back and sent once more to the fallback model. The chat says which model answered.
  • If the fallback also refuses, the turn ends as it does today when refused, with the turn rolled back.
  • The retry follows the same prompt cache rules as a /model swap, keeping the system prompt byte-identical.
  • Tests cover recovery from a refusal on the fallback, refusals from both models, and no configured fallback.

Notes

This builds on the rollback implemented in #475 through the rewind session entry and Engine::roll_back.

Activity

  1. self-assigned this
    on Oct 21, 2026
  2. added
    enhancement
    area: engine
    on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: engineenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions