Skip to content

fix(agents): rename app_api.agents package to unbreak local app-api startup#595

Merged
philmerrell merged 1 commit into
developfrom
fix/agents-package-name-collision
Jul 8, 2026
Merged

fix(agents): rename app_api.agents package to unbreak local app-api startup#595
philmerrell merged 1 commit into
developfrom
fix/agents-package-name-collision

Conversation

@philmerrell

Copy link
Copy Markdown
Contributor

Local app-api startup crashes: ModuleNotFoundError: No module named 'agents.main_agent'

Root cause

run-app-api.sh launches app-api with cd src/apis/app_api && python main.py, so src/apis/app_api lands on sys.path[0]. The apis/app_api/agents/ package added for the Agent Designer (#591/#592) then shadows the top-level agents packageadmin/quota/routes.py's from agents.main_agent.quota.repository import ... resolves into it, which has no main_agent, and startup dies.

  • Tests didn't catch it: pytest runs from backend/ (pythonpath=src), where import agents correctly resolves to backend/src/agents. The collision only appears when the CWD is the app_api dir.
  • Production is NOT affected: the container runs uvicorn apis.app_api.main:app from WORKDIR /app, so sys.path[0] is /app and import agents finds the top-level package. Only local dev via run-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-level agents package. Pure rename — the /agents URL surface, the agents_router, and all behavior are unchanged; only the internal Python module path moves.

Verification

  • Reproduced the original failure from src/apis/app_api, then confirmed the fix: import agents now resolves to src/agents, import agents.main_agent.quota.repository succeeds, and the full apis.app_api.main module loads from that directory with the /agents routes still mounted.
  • 34 tests pass (agent routes + binding validation + architecture import-boundary gate).

🤖 Generated with Claude Code

…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>
@philmerrell philmerrell merged commit e3ac783 into develop Jul 8, 2026
4 checks passed
@philmerrell philmerrell deleted the fix/agents-package-name-collision branch July 8, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant