fix(llm): honor per-device 'available' flag in device validation#2081
Open
github-actions[bot] wants to merge 1 commit into
Open
fix(llm): honor per-device 'available' flag in device validation#2081github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
LemonadeManager._validate_device_requirement treated any device key present in get_system_info()'s devices dict as detected, so a device listed with available: false (e.g. an NPU present but disabled/unpowered) wrongly satisfied a REQUIRED_HARDWARE floor. Detection now keys off the per-device 'available' boolean, matching get_system_info()'s documented contract. A missing flag is still treated as available for backwards compatibility with payloads that omit it. Closes #2079
3 tasks
itomek
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this fix, a
REQUIRED_HARDWAREcheck could pass on hardware that isn't actually usable:LemonadeManagertreated the mere presence of a device key inget_system_info()'sdevicesdict as "detected." A device reported withavailable: false— e.g. an NPU that's present but disabled or unpowered — was misread as detected, so an agent requiring that device would proceed against hardware it can't use. Now detection keys off the per-deviceavailableboolean (the documentedget_system_info()contract), so present-but-unavailable devices fail the requirement with the existing actionable device error.A missing
availableflag is still treated as available, preserving behavior for sysinfo payloads that omit it. The device-error message contract is unchanged, so the blast radius across agents that setREQUIRED_HARDWAREstays behavior-compatible except for the disabled-device case this fixes.Closes #2079
Test plan
python -m pytest tests/unit/test_multi_device_wiring.py -xpassespython util/lint.py --allpassesTestPerDeviceAvailableFlagcases cover:available: truepasses,available: falsefails with thegaia init --profile npuremedy, key-absent fails, missing-flag treated as available🔍 Technical details
Root cause:
_validate_device_requirementbuilt itsdetectedset fromset(devices.keys())(src/gaia/llm/lemonade_manager.py), ignoring each entry'savailableboolean.Changes:
_device_is_available(info)helper — truthyavailablefor a dict entry,any(...)over a list entry (amd_dgpucan be a list), and a missing flag treated as available for backwards compatibility.detectedvia{name for name, info in devices.items() if _device_is_available(info)}; the list-of-dicts branch skips entries that aren't available before extracting the device type.TestPerDeviceAvailableFlagintests/unit/test_multi_device_wiring.pycovering the three acceptance cases plus the missing-flag backwards-compat case.Verified:
tests/unit/test_multi_device_wiring.pydevice classes,test_npu_device_support.py, andtest_hardware_selection.pyall pass (44 device tests);python util/lint.py --black --isort --flake8 --pylintclean. The import-validation lint step and one unrelatedfastapi-dependent test in this file fail only because optional extras aren't installed in this environment — neither is touched by this change.