Skip to content

test(anthropic): expect no output tokens on a /v1/messages attempt dropped before content - #53885

Merged
mateo-berri merged 1 commit into
mainfrom
litellm_flakeheal_20261123_test_every_dropped_attempt_logs_its_own_fai
Nov 23, 2026
Merged

mateo-berri merged 1 commit into
mainfrom
litellm_flakeheal_20261123_test_every_dropped_attempt_logs_its_own_fai

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

Three Anthropic /v1/messages retry tests went red on main after #53394 changed how a stream that is cut right after it opens is logged. Such an attempt used to log the 1 output token Anthropic sends as a placeholder when a stream opens, and it now logs 0 because no text arrived. The tests now expect 0 for a dropped connection and still expect 1 when the provider sends an error frame, which did not change

Details

Link to Devin session: https://app.devin.ai/sessions/cb4bbb904f32462a9692dfeddcebc9e9
Open in Devin Desktop: https://app.devin.ai/desktop/session/cb4bbb904f32462a9692dfeddcebc9e9?variant=devin
Requested by: @mateo-berri

TLDR

Problem this solves:

How it solves it:

  • Expect 0 output tokens on a dropped attempt in the three tests, input tokens unchanged
  • test_superseded_attempt_and_its_retry_each_log_their_own_usage takes the expected value per case: 0 for transport-drop, 1 for recoverable-error-frame
  • No product code changes

Relevant issues

Failing job: https://github.com/BerriAI/litellm/actions/runs/45214198063/job/137830801373

AssertionError: (('failure', 5, 0), ('failure', 5, 0))
AssertionError: (('failure', 5, 0), ('success', 5, 3))
AssertionError: [{'completion_tokens': 0, 'prompt_tokens': 33, 'status': 'failure'}]

git bisect over the range between the last green and the first red scheduled run, on the whole file, ends at b099ac8 (#53394): its parent 1fdee58 gives 39 cases 0 failed, b099ac8 gives 39 cases 3 failed

Screenshots / Proof of Fix

E2E exception at b9329df: test-only change, run on the integration rig locally with INTEGRATION_WORKERS=2 python tests/integration/run.py providers <target> and the environment run_integration.sh sets

  1. origin/main, whole file: 39 cases 3 failed, the three tests above with the CI errors
  2. This branch, the three tests: 4 cases 0 failed, five runs in a row
  3. This branch, whole file: 39 cases 0 failed
  4. Mutation: with the anthropic_message_start mark removed from litellm/llms/anthropic/chat/handler.py, all four cases fail with the old value (('failure', 5, 1), 'completion_tokens': 1). Reverted

Open point for a reviewer: a provider error frame right after message_start still logs the placeholder 1, while a dropped connection at the same point logs 0. This PR asserts both as they are today and does not change either

This file first runs in CI on main after merge, since integration groups do not run on pull requests

Type

✅ Test

…opped before content

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri
mateo-berri enabled auto-merge (squash) November 23, 2026 19:15
@veria-ai

veria-ai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@mateo-berri
mateo-berri merged commit 191bd23 into main Nov 23, 2026
40 checks passed
@mateo-berri
mateo-berri deleted the litellm_flakeheal_20261123_test_every_dropped_attempt_logs_its_own_fai branch November 23, 2026 19:24
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