Skip to content

harness: empty-completion retry + duplicate-send guard for the turn loop#147

Open
Alexsun1one wants to merge 1 commit into
exoharness:mainfrom
Alexsun1one:turnloop-reliability-guards
Open

harness: empty-completion retry + duplicate-send guard for the turn loop#147
Alexsun1one wants to merge 1 commit into
exoharness:mainfrom
Alexsun1one:turnloop-reliability-guards

Conversation

@Alexsun1one

Copy link
Copy Markdown
Contributor

Problem

Two intermittent failures in the responses turn loop, both with weak models behind chat adapters:

  1. Empty completion — a round with no text and no tool call was treated as a real end of turn, so an adapter-woken user could get no reply.
  2. Duplicate send — a weak model loops on send_adapter_message and delivers the same reply as several near-identical variants. The loop only ends when the model calls no tool, and with no round cap it never stops.

Change

runResponsesTurnLoop gains two bounded guards:

  • Empty-completion retry — a round producing nothing is retried up to 2x without consuming the tool-round-trip budget.
  • Duplicate-send guard — once a reply has gone out, a further send_adapter_message with no real tool call in between is skipped; a round that is nothing but duplicate sends ends the turn. Any real tool call resets the state, so a genuine "acknowledge -> do work -> report result" sequence still sends twice.

Tests

shouldRetryEmptyCompletion is a pure function with unit tests. A loop integration test drives a fake runtime and asserts (a) a repeat send with no work between is skipped and the turn ends, and (b) a send after real work is allowed. 128 tests pass. runResponsesTurnLoop is exported for the test.

Harness-side turn hardening — validated in a live Lark adapter deployment where the duplicate-send guard demonstrably stopped a weak model from blasting the same reply multiple times.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant