Skip to content

fix(api): avoid dify-agent path lookup during Docker build#36187

Open
BeautyyuYanli wants to merge 1 commit into
mainfrom
fix/docker-build-agent
Open

fix(api): avoid dify-agent path lookup during Docker build#36187
BeautyyuYanli wants to merge 1 commit into
mainfrom
fix/docker-build-agent

Conversation

@BeautyyuYanli
Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Screenshots

N/A. This is a Docker build/dependency fix.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Verification

  • uv lock --project api --check
  • docker build --target packages -t dify-api-packages:test ./api

This 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)

@BeautyyuYanli BeautyyuYanli requested a review from a team May 14, 2026 15:41
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 14, 2026
@dosubot
Copy link
Copy Markdown

dosubot Bot commented May 14, 2026

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),无需重复部署
 
 ### 架构演进的意义

[Accept] [Edit] [Decline]

How did I do? Any feedback?

@dosubot dosubot Bot added the dependencies Pull requests that update a dependency file label May 14, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.94%. Comparing base (0d500e6) to head (fe50894).

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     
Flag Coverage Δ
api 85.42% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@BeautyyuYanli
Copy link
Copy Markdown
Contributor Author

cc @asukaminato0721

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 14, 2026
@asukaminato0721 asukaminato0721 enabled auto-merge May 14, 2026 16:00
@BeautyyuYanli
Copy link
Copy Markdown
Contributor Author

cc @laipz8200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API Docker build fails when resolving dev-only dify-agent path

2 participants