Skip to content
← Back to activity

Immutable solution version

during run evaluation of a test case inferences could be NoneType which has no len attribute and error is

Version 2

Complete solution

Shows how to fix during run evaluation of a test case inferences could be NoneType which has no len attribute and error is. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

When it applies

Not specified by the original author.

Instructions

TL;DR

Upgrade ADK past the release containing that fix. Reported in Google Agent Development Kit: during run evaluation of a test case inferences could be NoneType which has no len attribute and error is not caught.

Steps

  1. ADK eval crashes with len() on NoneType when a test case's inference failed: in localevalservice.py the code calls len(inferenceresult.inferences) without a None check. When inference fails (session service errors, network failures), InferenceResult has status=FAILURE and errormessage set but inferences stays None. The fix (PR #3805): in evaluate(), filter out failed inferences first, i.e. if inferenceresult.status == InferenceStatus.FAILURE or inferenceresult.inferences is None, log a warning and return EvalStatus.NOT_EVALUATED instead of evaluating. Upgrade ADK past the release containing that fix.

When to use

You are seeing this: ADK eval crashes with len() on NoneType when a test case's inference failed: in localevalservice.py the code calls len(inference_result.inferences) without a None check. Use this skill when you run into "during run evaluation of a test case inferences could be NoneType which has no len attribute and error is".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

In gh:google/adk-python#2729 (https://github.com/google/adk-python/issues/2729), the reporter ran into this: Reported in Google Agent Development Kit: during run evaluation of a test case inferences could be NoneType which has no len attribute and error is not caught. The verified resolution: ADK eval crashes with len() on NoneType when a test case's inference failed: in localevalservice.py the code calls len(inferenceresult.inferences) without a None check. When inference fails (session service errors, network failures), InferenceResult has status=FAILURE and errormessage set but inferences stays None. The fix (PR #3805): in evaluate(), filter out failed inferences first, i.e. if inferenceresult.status == InferenceStatus.FAILURE or inferenceresult.inferences is None, log a warning and return EvalStatus.NOT_EVALUATED instead of evaluating. Upgrade ADK past the release containing that fix.

By @issueatlas · Version 2 · Exact version

Maintainer review

Checking maintainer review for this exact version…

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_BJrTXqUDDZ-IT_CKodHO4w" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">during run evaluation of a test case inferences could be NoneType which has no len attribute and error is <span>— Vectle</span></a>

during run evaluation of a test case inferences could be NoneType which has no len attribute and error is | Vectle