fix: report root_agent type mismatch instead of 'No root_agent found' - #6635
Open
loponly wants to merge 4 commits into
Open
fix: report root_agent type mismatch instead of 'No root_agent found'#6635loponly wants to merge 4 commits into
loponly wants to merge 4 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
When a module defines root_agent with a non-agent type, AgentLoader now raises a targeted ValueError naming the module and the actual type (with a hint to use the name 'app' when the object is an App), instead of the misleading generic not-found error. Fixes google#6606.
loponly
force-pushed
the
fix/agent-loader-root-agent-type-error
branch
from
August 7, 2026 15:11
e32eff7 to
9a19844
Compare
Author
|
@googlebot I signed it! |
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.
Fixes #6606
Problem
When a module defines
root_agentwith a non-agent type,AgentLoaderlogs the type mismatch at WARNING but then raises the generic
ValueError: No root_agent found, whose directory-structure guidancesends users in the wrong direction when their layout is correct.
Fix
_load_from_module_or_packageand_load_from_submodulerecord eachtype mismatch;
_perform_loadraises a targetedValueErrornaming themodule and the actual type at its final failure point. When the object
is an
App, the error suggests exporting it under the nameapp.Fallthrough behavior is preserved: a mismatch in one pattern does not
block a later pattern from loading successfully, and the generic
not-found message is unchanged for the genuinely-missing case.
Testing Plan
tests/unittests/cli/utils/test_agent_loader.py:test_wrong_type_root_agent_raises_targeted_errortest_app_exported_as_root_agent_suggests_app_nametest_wrong_type_root_agent_in_agent_module_raises_targeted_errortest_valid_agent_module_wins_over_mistyped_package_root_agentpytest tests/unittests/cli -n auto: 774 passed, 5 skipped, 4 xfailed, 376 warnings in 84.37s (0:01:24)tox(full multi-version matrix): py310 OK, py312 OK, py313 OK, py314 OK.py311 has one failure in
tests/unittests/sessions/migration/test_migration.py::test_migrate_from_sqlalchemy_pickle_preserves_nested_safe_actions_picklethat is unrelated to this change and reproduces identically on
main:the migration unpickler's
_ALLOWED_PICKLE_GLOBALSblocksbuiltins.getattronly in the py311 environment (the one where thecrewaiextras install per the pyproject markers). This diff touchesonly
cli/utils/agent_loader.pyand its test file. Filed separately.🤖 Generated with Claude Code