Skip to content

fix(retain): a zero retry budget must still perform the initial fact-extraction request #2731

Description

@Jordan-Jarvis

Problem

OpenAICompatibleLLM.call(max_retries=N) correctly interprets N as retries after the initial request and loops over range(N + 1).

_extract_facts_from_chunk, however, resolves the same retain_llm_max_retries / llm_max_retries value and uses it as an attempt count:

for attempt in range(llm_max_retries):

When an operator deliberately configures retain_llm_max_retries=0 because an upstream gateway owns transport retries, Hindsight performs zero fact-extraction requests and raises Fact extraction failed after 0 attempts.

The same setting is also passed to llm_config.call(max_retries=llm_max_retries), so its meaning differs between the two nested layers.

Expected behavior

A retry budget of zero must mean one initial request and no retry. Hindsight should preserve a single retry owner without skipping the operation.

Proposed focused fix

Use at least one outer attempt while preserving the configured transport retry value passed to the provider, and add regression coverage for retain_llm_max_retries=0.

A broader follow-up may want to separate content-quality attempts from transport retries explicitly, but the zero-budget behavior is a correctness bug on its own and blocks trusted gateway deployments.

I can submit the focused patch and test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions