Skip to content

fix(eval): handle failed inference results without invocations (cherry-pick) - #6565

Open
ftnext wants to merge 1 commit into
google:v1from
ftnext:codex/backport-v1-eval-failure
Open

fix(eval): handle failed inference results without invocations (cherry-pick)#6565
ftnext wants to merge 1 commit into
google:v1from
ftnext:codex/backport-v1-eval-failure

Conversation

@ftnext

@ftnext ftnext commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

This PR backports 9a6cf60 from main to v1.

When inference fails before producing invocations, InferenceResult.inferences remains None. The v1 implementation subsequently calls len(inference_result.inferences), replacing the original inference error with:

TypeError: object of type 'NoneType' has no len()

The backported guard returns an EvalCaseResult with final_eval_status=EvalStatus.FAILED and allows the remaining evaluation cases to continue.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Focused tests:

pytest tests/unittests/evaluation/test_local_eval_service.py -k "failed_without_inferences or evaluate_single_inference_result" -q

Result:

4 passed, 15 deselected

Additional checks:

  • ruff check: passed
  • pyink --check: passed

Manual End-to-End (E2E) Tests:

Not run. This is a direct backport of the existing main fix, with focused regression coverage for the failed-inference path.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas. (N/A: no complex logic requiring additional comments was introduced.)
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules. (N/A: no dependent changes.)

Additional context

The original commit was cherry-picked with -x and applied to the current v1 branch without conflicts.

Merge google#5878

## What changed

- Return a failed `EvalCaseResult` when inference failed before producing any invocations.
- Preserve the existing session lookup path when a failed inference still has a session id.
- Add a regression test for `InferenceResult(status=FAILURE, inferences=None)`.
- Clean up two existing lint issues in the touched eval test file so the local changed-file ruff check passes.

This prevents the eval runner from replacing the original inference error with `TypeError: object of type 'NoneType' has no len()`.

Fixes google#5876

## To verify

- `.\.venv\Scripts\python.exe -m py_compile src\google\adk\evaluation\local_eval_service.py tests\unittests\evaluation\test_local_eval_service.py`
- `.\.venv\Scripts\python.exe -m pytest tests\unittests\evaluation\test_local_eval_service.py -k "failed_without_inferences or evaluate_single_inference_result" -q --basetemp .tmp\pytest`
- `.\.venv\Scripts\python.exe -m ruff check src\google\adk\evaluation\local_eval_service.py tests\unittests\evaluation\test_local_eval_service.py`
- `.\.venv\Scripts\python.exe -m pyink --check src\google\adk\evaluation\local_eval_service.py tests\unittests\evaluation\test_local_eval_service.py`
- `git diff --check`

Co-authored-by: George Weale <gweale@google.com>
COPYBARA_INTEGRATE_REVIEW=google#5878 from he-yufeng:fix/eval-failed-inference-none 5ed777d
PiperOrigin-RevId: 933176248

(cherry picked from commit 9a6cf60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eval [Component] This issue is related to evaluation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants