fix(image_gen): soft-accept configured provider in check_fn (#16027) - #16377
Closed
Tranquil-Flow wants to merge 2 commits into
Closed
Tranquil-Flow wants to merge 2 commits into
Tranquil-Flow wants to merge 2 commits into
Conversation
Tranquil-Flow
force-pushed
the
fix/16027-image-generate-discovery-race
branch
from
May 25, 2026 09:13
b2f9d59 to
b4e6426
Compare
…arch#16027) `check_image_generation_requirements` returned False when: 1. FAL_KEY was not set, AND 2. Plugin discovery hadn't yet registered the provider named in `image_gen.provider`. The cached `check_fn` result determines tool availability for the session's lifetime, so a discovery race at gateway/session init left `image_generate` permanently excluded — even though `_handle_image_generate` (which retries discovery with `force=True`) and the underlying provider both work fine when invoked directly. The user sees the tool simply missing, with no diagnostic. Add a soft-accept gate between the FAL branch and the plugin probe: if `image_gen.provider` is explicitly set in config.yaml (and is not "fal", which is the in-tree backend), trust that the user wants this tool and surface it. Provider availability is re-checked at call time in `_dispatch_to_plugin_provider`, which retries discovery and returns a clear "provider_not_registered" error if the named plugin still isn't there. Mirrors the soft-accept pattern used for browser-cdp (NousResearch#15952) and openai-codex models (NousResearch#16172). Adds tests/tools/test_image_generation_check_fn.py covering: * configured provider + empty registry → True (the original repro) * configured provider registered but is_available()=False → True * no config + no FAL + empty registry → False (regression guard) * provider="fal" + FAL_KEY unset → False (don't soft-accept fal) The 2 new-behavior tests fail without the fix; the 2 regression guards pass either way.
Tranquil-Flow
force-pushed
the
fix/16027-image-generate-discovery-race
branch
from
May 25, 2026 11:05
b4e6426 to
fabe634
Compare
Collaborator
|
Thanks for the focused regression coverage. This automated hermes-sweeper review found that the linked #16027 behavior is already implemented on current
Closing as superseded by the implementation already on main. |
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.
What does this PR do?
check_image_generation_requirementsreturned False when:FAL_KEYwas not set, ANDimage_gen.provider.The cached
check_fnresult determines tool availability for the session's lifetime, so a discovery race at gateway/session init leftimage_generatepermanently excluded from the session — even though_handle_image_generate(which retries discovery withforce=True, courtesy of #14502) and the underlying provider both work fine when invoked directly. The user sees the tool simply missing, with no diagnostic.This PR is the missing companion to #14502: that PR fixed the symptom at call time; this one fixes it at check time. Without both, the tool isn't in the session's tool list to be retried at call time.
Adds a soft-accept gate between the FAL branch and the plugin probe in
check_image_generation_requirements: ifimage_gen.provideris explicitly set inconfig.yaml(and is notfal, which is the in-tree backend), trust that the user wants this tool and surface it. Provider availability is re-checked at call time in_dispatch_to_plugin_provider, which retries discovery and returns a clearprovider_not_registerederror if the named plugin still isn't there.Mirrors the soft-accept pattern used for browser-cdp (#15952) and openai-codex models (#16172).
Related Issue
Fixes #16027
Type of Change
Changes Made
tools/image_generation_tool.py: insert a soft-accept gate incheck_image_generation_requirements()between the FAL branch and the plugin probe. If_read_configured_image_provider()returns a non-falvalue, return True without requiring registry population.tests/tools/test_image_generation_check_fn.py(new): 4 tests covering the new behavior plus regression guards.How to Test
scripts/run_tests.sh tests/tools/test_image_generation_check_fn.py tests/tools/test_image_generation_env.py tests/tools/test_image_generation.py tests/tools/test_image_generation_plugin_dispatch.py— 65 pass.tools/image_generation_tool.pychange → 2 of 4 new tests fail (the new-behavior tests; the 2 regression guards still pass).image_gen.provider: openai-codexwith valid Codex OAuth, restart gateway, send a message —image_generateis now in the session's tool list (previously missing in some sessions due to the race).Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs