Skip to content

OllamaModelBackend.generate_from_raw silently swallows batch exceptions #597

Closed

Description

@planetf1

OllamaModelBackend.generate_from_raw silently swallows batch exceptions

Description

generate_from_raw uses asyncio.gather(..., return_exceptions=True) to run concurrent requests, but silently converts any exception into ModelOutputThunk(value=""), storing the error only in result._generate_log.extra["error"] — invisible to callers.

ollama.py:465-474

Impact

Callers have no way to detect failures. Tests asserting result.value is not None pass silently even when requests are failing, since empty string is not None.

Related

Activity

  1. planetf1 commented on Mar 6, 2026

    @planetf1
    ContributorAuthor

    Proposed fix

    Remove return_exceptions=True from asyncio.gather and delete the per-response exception handling block. Exceptions will then propagate naturally, consistent with how all other backends behave in generate_from_raw.

    This is the simplest fix and aligns with the direction taken in #580 (fail fast, don't swallow exceptions).

    Future consideration

    Longer term, it may be worth considering explicit per-request error handling across all backends — e.g. a public error field on ModelOutputThunk — to support partial batch results. That's a broader API design question out of scope for this fix.

  2. planetf1 commented on Mar 6, 2026

    @planetf1
    ContributorAuthor

    Note: #599 tracks a related but distinct failure mode — Ollama returning genuinely empty responses under load (not exceptions). Both produce value="" but via different paths: this issue is the exception-swallowing code path; #599 is Ollama silently returning nothing. Worth keeping separate as the fixes are independent.

  3. added
    bug
    on Apr 8, 2026
  4. self-assigned this
    on Apr 8, 2026
  5. added
    area/backends
    on May 20, 2026
  6. removed their assignment
    on May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/backendsbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions