Move session-related responsibilities into a new application-layer AgentSessionService (and AgentSessionFeedbackResult dataclass), provide a bootstrap factory (get_agent_session_service), and update agent API routes to call the service instead of accessing ConversationStore directly. Routes now translate ValueError into 404 responses and use service methods for get/list/history/delete/feedback. Also update package exports and docs/READMEs to declare the backend architecture authority, enforce api -> application -> domain ports -> infrastructure boundaries, and call out legacy services/workflows as migration-only. These changes centralize session logic in the application layer and tighten architecture guidance for future backend work.
4.3 KiB
4.3 KiB
AGENTS.md
Scope
- Backend code lives under
backend/app/; frontend is the Vite app infrontend/.
Entrypoints
- Backend entrypoint is
backend/app/main.py, which re-exportsappfromapp.api.main. - FastAPI mounts the real API under
/api/v1; health endpoints areGET /healthandGET /. - Frontend API calls use relative
/apiURLs fromfrontend/src/api/index.ts. - Current Vite dev proxy in
frontend/vite.config.tsforwards/apitohttp://6.86.80.8:8000, not the local backend.
Preferred Commands
- Prefer the repo scripts over ad hoc startup commands:
./dev.sh ...on Unix,dev.bat ...on Windows. - First-time local setup:
./dev.sh setupordev.bat setup. - Backend foreground dev server:
./dev.sh start api --foregroundordev.bat start api --foreground. - Equivalent direct backend run from repo root:
PYTHONPATH=backend uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload. - Python tooling must use the repo-root
.venvenvironment; do not use the globalpython. - Prefer
uv-managed execution from the repo root, for exampleuv run --python .venv\\Scripts\\python.exe python ...or otheruv run ...forms that resolve within the project environment. - Frontend dev:
npm --prefix frontend run dev. - Frontend verification:
npm --prefix frontend run lintandnpm --prefix frontend run build. - Use
npm, notpnpm; the checked-in scripts runnpm installeven thoughfrontend/pnpm-lock.yamlalso exists.
Env And Infra
- Backend settings must resolve env files from the repo root only. The supported files are root
.envand optional root.env.development; files underbackend/must not be treated as authoritative env sources. - The dev scripts read
API_HOST,API_PORT,FRONTEND_PORT, andFRONTEND_MODEfrom root.envfirst, then root.env.developmentas an override; all other backend config comes from the repo-root env files via Pydantic settings. - Docker infra is
docker/docker-compose.yml; it brings upmilvus,minio,redis, andpostgres. - Default ports from config/scripts: backend
8000, frontend5173, Milvus19530, MinIO9000/9001, Redis6379, PostgreSQL5432. .env.examplepoints embedding/LLM base URLs at a shared remote gatewayhttp://6.86.80.4:30080/v1; do not assume model inference is local.
Verification
- Root
pyproject.tomlis the active Python manifest and pytest config;testpaths = ["tests"]. - Tests under
tests/insertbackend/intosys.paththemselves, so targeted runs can be launched from the repo root. tests/test_milvus.pyandtests/verify_mvp.pyrequire Milvus and model/runtime dependencies; they are not cheap smoke tests.tests/verify_mvp.pyalso expects theBGEM3Embedderstack to be available and explicitly mentionsFlagEmbedding.- For backend-only changes, prefer focused import/startup checks unless you know the external services and model dependencies are available.
Backend Architecture Authority
docs/architecture/backend-project-architecture.mdis the authoritative backend architecture document for ongoing backend development.- New backend business logic must follow
api -> application -> domain ports -> infrastructure. - Treat
backend/app/shared/bootstrap.pyas the current composition root for backend dependency wiring. - Do not add new business orchestration to
backend/app/services/*orbackend/app/workflows/*unless the task is explicitly a migration step. - API routes must not directly access
ConversationStore; session access should go through application services. - Legacy files may be patched for compatibility or bug fixes, but should not gain new long-term responsibilities.
Backend Commenting Standard
- All comments and docstrings in
backend/**/*.pymust be written in English. - Every Python file under
backendmust include a module-level explanation and at least one meaningful#code comment. - Every function and method must include a docstring.
- Files without functions, including
__init__.py, schemas, enums, dataclasses, and export-only modules, must still include a module docstring, class docstrings when applicable, and at least one meaningful#code comment. - Comments must explain intent, assumptions, invariants, or non-obvious logic; do not add empty, placeholder, or restatement-only comments.