Load nested agent entrypoints with a dotted module name (CAN-289) - #81
Draft
nickhuo wants to merge 1 commit into
Draft
Load nested agent entrypoints with a dotted module name (CAN-289)#81nickhuo wants to merge 1 commit into
nickhuo wants to merge 1 commit into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
_load_agent derived the module name for spec_from_file_location by stripping .py from the entrypoint path, leaving directory separators intact (e.g. "agents/aml_agent"). Without dots, Python can't establish __package__, so any relative import inside a nested entrypoint (e.g. `from .prompts import PROMPT`) fails with "attempted relative import with no known parent package" at agent load, surfacing as "No agent loaded" at serve time. Convert path separators to dots so __package__ resolves correctly and sibling relative imports work. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
nickhuo
force-pushed
the
nickhuo/can-289-entrypoint-relative-imports
branch
from
September 9, 2026 22:38
fa08b0f to
18879b7
Compare
iidsample
approved these changes
Sep 10, 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.
Summary
_load_agentderived the module name passed toimportlib.util.spec_from_file_locationby only stripping.pyfrom the entrypoint path (self.agent_file.replace(".py", "")), leaving directory separators intact for nested entrypoints (e.g.agents/aml_agent.py->"agents/aml_agent").__package__, so any package-relative import inside a nested entrypoint (e.g.from .prompts import PROMPTinagents/aml_agent.py, a sibling ofagents/prompts.py) fails withattempted relative import with no known parent packageat agent load — surfacing only as "No agent loaded" at serve time, not at validate or build."agents.aml_agent"), so__package__resolves correctly. The file path passed tospec_from_file_locationis unchanged — only the module-name string changes.