Skip to content

LocalEvalService._evaluate_single_inference_result crashes when inferences is None #6071

Closed

Description

@tottenjordan

Description

LocalEvalService._evaluate_single_inference_result() accesses inference_result.inferences without a None check. When an inference fails (timeout, API error, etc.), inferences can be None, causing an unhandled crash.

Reproduction

When running GEPA optimization with MCP tool agents, if an MCP session drops during inference, the inference result may have inferences=None. The method then crashes at:

# local_eval_service.py, line ~41-42
if eval_case.conversation_scenario is None and len(
    inference_result.inferences  # <-- crashes if None

Impact

A single failed inference case crashes the entire GEPA optimization run instead of gracefully skipping the case with a NOT_EVALUATED status.

Suggested Fix

Add a None guard before accessing inference_result.inferences:

if inference_result.inferences is None:
    return inference_result, EvalCaseResult(
        eval_id=inference_result.eval_case_id,
        eval_set_id=inference_result.eval_set_id,
        final_eval_status=EvalStatus.NOT_EVALUATED,
        overall_eval_metric_results=[],
        eval_metric_result_per_invocation=[],
        session_id="skipped",
    )

Environment

  • google-adk 2.2.0
  • Python 3.11/3.12

Activity

  1. added
    eval[Component] This issue is related to evaluation
    on Jun 10, 2026
  2. added theissue type on Jun 10, 2026
  3. sanketpatil06 commented on Jun 11, 2026

    @sanketpatil06

    Hi @tottenjordan, thanks for reporting this.
    The PR (#5878) that addresses this issue is already open and under review. Could you please test it and let us know if it resolves the issue on your end? Thanks.

  4. added
    request clarification[Status] The maintainer need clarification or more information from the author
    on Jun 11, 2026
  5. tottenjordan commented on Jun 11, 2026

    @tottenjordan
    Author

    Tested PR #5878 against our production codebase (107 tests, all pass). The fix works correctly.

    Repro: When InferenceResult.inferences is None (e.g., agent auth failure, timeout, or null response), _evaluate_single_inference_result calls len(inference_result.inferences) which throws TypeError: object of type 'NoneType' has no len().

    With PR #5878: The null check returns a proper EvalCaseResult with final_eval_status=FAILED and empty metric results. No crash, evaluation continues for remaining cases.

    Compatibility: The fix is backwards-compatible with our existing workaround (a higher-level null guard in our optimizer). Once this PR merges, we can remove our workaround.

  6. removed
    request clarification[Status] The maintainer need clarification or more information from the author
    on Jun 11, 2026
  7. added a commit that references this issue on Jun 15, 2026
    99376c1
  8. added a commit that references this issue on Jun 24, 2026
    21eb92a
  9. added
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on Jul 22, 2026
  10. ftnext commented on Aug 2, 2026

    @ftnext
    Contributor

    This appears to have been fixed by #5878, so I think this issue can be closed.

  11. self-assigned this
    on Aug 6, 2026
  12. GWeale commented on Aug 6, 2026

    @GWeale
    Collaborator

    thanks for flagging this, fixed in v2.3.0, local_eval_service now returns a FAILED result when inferences is None instead of crashing, so you can drop the workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

eval[Component] This issue is related to evaluationneeds review[Status] The PR/issue is awaiting review from the maintainer

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions