fix(agents): rename app_api.agents package to unbreak local app-api startup#595
Merged
Merged
Conversation
…el agents run-app-api.sh launches app-api with `cd src/apis/app_api && python main.py`, putting that directory on sys.path[0]. The new apis/app_api/agents/ package (Agent Designer surface, #591/#592) then shadowed the top-level `agents` package, so `admin/quota/routes.py`'s `from agents.main_agent...` resolved into it and crashed startup with `ModuleNotFoundError: No module named 'agents.main_agent'`. Tests never caught it — pytest runs from backend/ where `agents` resolves correctly. Production is unaffected (the container runs `uvicorn apis.app_api.main:app` from WORKDIR /app, so sys.path[0] is /app). Rename the package apis/app_api/agents → apis/app_api/agent_designer (and its test dir) so its name can't collide with the top-level `agents` package. Pure rename: the /agents URL surface, router, and behavior are unchanged. Verified: `import agents.main_agent.quota.repository` and the full app-api module now load from src/apis/app_api; 34 agent/boundary tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Local app-api startup crashes:
ModuleNotFoundError: No module named 'agents.main_agent'Root cause
run-app-api.shlaunches app-api withcd src/apis/app_api && python main.py, sosrc/apis/app_apilands onsys.path[0]. Theapis/app_api/agents/package added for the Agent Designer (#591/#592) then shadows the top-levelagentspackage —admin/quota/routes.py'sfrom agents.main_agent.quota.repository import ...resolves into it, which has nomain_agent, and startup dies.backend/(pythonpath=src), whereimport agentscorrectly resolves tobackend/src/agents. The collision only appears when the CWD is the app_api dir.uvicorn apis.app_api.main:appfromWORKDIR /app, sosys.path[0]is/appandimport agentsfinds the top-level package. Only local dev viarun-app-api.sh(the CLAUDE.md-documented command) broke.Fix
Rename
apis/app_api/agents/→apis/app_api/agent_designer/(and the mirror test dir) so the package name can't collide with the top-levelagentspackage. Pure rename — the/agentsURL surface, theagents_router, and all behavior are unchanged; only the internal Python module path moves.Verification
src/apis/app_api, then confirmed the fix:import agentsnow resolves tosrc/agents,import agents.main_agent.quota.repositorysucceeds, and the fullapis.app_api.mainmodule loads from that directory with the/agentsroutes still mounted.🤖 Generated with Claude Code