# Ecom DMB Agent(Python / FastAPI / LangGraph) 设计见 [DESIGN.md](./DESIGN.md)。 ## 本地运行 ```bash cd apps/agent python -m venv .venv source .venv/bin/activate pip install -r requirements.txt cp .env.example .env # JWT_SECRET / Mongo / Redis(与 Server 同库) / SERVER_BASE_URL / MCP uvicorn api.main:app --reload --host 0.0.0.0 --port 8200 ``` 健康检查:`GET http://localhost:8200/health` API 前缀:`/api/agent/...`(会话/聊天/记忆;与前端代理 `/api/agent` 对齐) **模型 API 配置不在本服务**:浏览器走 Java `GET/PUT /api/company/agent-llm-settings`(MySQL 加密落库);Agent 经 Redis `agent:llm:rt:{companyId}` 或内部接口拉明文注入。 ## 环境变量要点 | 变量 | 说明 | |------|------| | `JWT_SECRET` | 与 Java `jwt.secret` 一致 | | `MONGO_URI` / `MONGO_DB` | Agent 独立库(sessions / messages / memory) | | `REDIS_URL` | **与 Server 同 DB**,读 LLM 运行时缓存 | | `SERVER_BASE_URL` | Java 根地址,内部拉 `/api/internal/agent/llm-runtime` | | `MCP_BASE_URL` / `MCP_BEARER_TOKEN` | 调 Server `/mcp`,并带 `X-Agent-Company-Id` / `X-Agent-User-Id` | | `LLM_FALLBACK_*` | 仅本地:公司未配置时的 OpenAI Compatible fallback | ## 分层 `api` → `application` → `domain` ← `infrastructure`;编排在 `agent/`(工具装载 / 图预留)