fix(api): avoid dify-agent path lookup during Docker build#36187
Open
BeautyyuYanli wants to merge 1 commit into
Open
fix(api): avoid dify-agent path lookup during Docker build#36187BeautyyuYanli wants to merge 1 commit into
BeautyyuYanli wants to merge 1 commit into
Conversation
|
Related Knowledge 1 document with suggested updates is ready for review. dify Dify Agent Server 模块分析 (Commit 55f95dbc)View Suggested Changes@@ -55,7 +55,7 @@
`dify-agent` 包并不替换上述现有组件,而是在其旁边建立了一个**独立的微服务边界**:
-- **集成方式**:`api/pyproject.toml` 已将 `dify-agent` 注册为本地路径依赖 [[10]](https://github.com/langgenius/dify/blob/7210f856c9c07ae03d7c2e5def96c949efee6397/api/pyproject.toml),表明主 API 服务可以作为客户端调用 Agent 服务器
+- **集成方式**:虽然代码结构上 `api/` 可作为客户端调用 Agent 服务器,但 `dify-agent` 目前仅包含在 `api/pyproject.toml` 的 dev 依赖组中 [[10]](https://github.com/langgenius/dify/blob/7210f856c9c07ae03d7c2e5def96c949efee6397/api/pyproject.toml)。API 的生产运行时不使用 dify-agent,生产 Docker 镜像使用 `uv sync --frozen --no-dev` 构建,不包含该包
- **与 Plugin Daemon 的关系**:新模块直接与 Plugin Daemon(端口 5002)通信,复用了同一个 LLM 提供者运行时基础设施
- **与 Redis 的关系**:Redis 仅作为持久化存储使用(非作业队列),保存 run 记录和 Redis Stream 事件,两端均可独立扩展
@@ -64,7 +64,7 @@
│ Dify API (api/) │
│ ┌──────────────┐ ┌──────────────────────────┐ │
│ │ 旧版 Runner │ │ dify-agent Client │ │
-│ │ (CoT / FC) │ │ (HTTP → Agent Server) │ │
+│ │ (CoT / FC) │ │ (开发环境专用) │ │
│ └──────┬───────┘ └──────────┬───────────────┘ │
└─────────┼─────────────────────┼─────────────────────┘
│ │
@@ -78,6 +78,8 @@
│ Redis │
└──────────┘
```
+
+> **注意**:`dify-agent` 目前仅在开发环境中作为 API 的依赖,生产 Docker 构建(`uv sync --frozen --no-dev`)不包含该包。
这一设计标志着 Dify 从**单体同步执行模型**向**异步微服务化 Agent 执行**的架构演进。
@@ -1032,7 +1034,7 @@
新模块与旧版 `BaseAgentRunner` / `CotAgentRunner` / `FunctionCallAgentRunner` 体系**并存而非替代**:
- 旧版 runner 仍承担现有会话式 Agent 的同步执行
-- `dify-agent` 服务器提供了面向微服务架构的新执行路径,主 `api/` 服务通过本地包依赖 [[10]](https://github.com/langgenius/dify/blob/7210f856c9c07ae03d7c2e5def96c949efee6397/api/pyproject.toml) 将其作为客户端调用
+- `dify-agent` 服务器提供了面向微服务架构的新执行路径。虽然代码结构上支持 `api/` 服务作为客户端调用,但 `dify-agent` 目前仅在开发环境中作为依赖,不包含在生产 Docker 镜像中
- 两者共用同一个 Plugin Daemon 基础设施(端口 5002),无需重复部署
### 架构演进的意义How did I do? Any feedback? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #36187 +/- ##
=======================================
Coverage 85.94% 85.94%
=======================================
Files 4454 4454
Lines 210903 210903
Branches 39426 39426
=======================================
+ Hits 181254 181257 +3
+ Misses 26446 26445 -1
+ Partials 3203 3201 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
asukaminato0721
approved these changes
May 14, 2026
Contributor
Author
|
cc @laipz8200 |
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.
Important
Fixes #<issue number>.Summary
dify-agentfrom API production dependencies to the dev dependency group because it is not currently used by the API runtime.uv sync --frozen --no-devfor the API Docker dependency layer so the image build trusts the checked-in lockfile while excluding dev-only path sources outside theapi/build context.Screenshots
N/A. This is a Docker build/dependency fix.
Checklist
make lint && make type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint godsVerification
uv lock --project api --checkdocker build --target packages -t dify-api-packages:test ./apiThis PR is drafted by
gpt-5.5(high)and I'm responsible for all the changes. I have reviewed the code and varified the behavior, while breaks may still exist. Reach me to fix in this case.From gpt-5.5(high)