---
phase: 06-
plan: 06
subsystem: backend-middleware
tags: [uploads, mentions, context, gap-closure]
requires:
  - phase: 06-05
    provides: UAT gap diagnosis and closure plan
provides:
  - 过滤 ref_kind=mention，避免被识别为本次上传
  - UploadsMiddleware 新增 mention 过滤回归测试
affects: [06-UAT, uploads-middleware, thread-context]
tech-stack:
  added: []
  patterns: [metadata-discriminator, middleware-guard-rail]
key-files:
  created:
    - .planning/phases/06-/06-06-SUMMARY.md
  modified:
    - backend/packages/harness/deerflow/agents/middlewares/uploads_middleware.py
    - backend/tests/test_uploads_middleware_core_logic.py
key-decisions:
  - "后端以 ref_kind=mention 作为强判定，明确将 mention 引用排除出 new_files。"
  - "保留原有 filename/path/sync 行为，只做最小补丁以降低回归风险。"
requirements-completed: [ATREF-04]
duration: 12min
completed: 2026-04-15
---

# Phase 06 Plan 06: Mention/Upload Misclassification Fix Summary

修复了“提及文件被误判为本次上传文件”的核心问题：`additional_kwargs.files` 中 `ref_kind=mention` 条目现在不会进入 UploadsMiddleware 的 `new_files`。

## Accomplishments

- 在 `UploadsMiddleware._files_from_kwargs` 增加判定：`ref_kind == "mention"` 直接跳过。
- 新增两条回归测试：
  - 纯 mention 条目应被完全过滤；
  - mixed list 中真实 upload 保留、mention 过滤。

## Files Created/Modified

- `.planning/phases/06-/06-06-SUMMARY.md`
- `backend/packages/harness/deerflow/agents/middlewares/uploads_middleware.py`
- `backend/tests/test_uploads_middleware_core_logic.py`

## Verification

- 尝试执行：`cd backend && pytest -q tests/test_uploads_middleware_core_logic.py -k "mention or files_from_kwargs"`
- 环境结果：`pytest` 不可用（`python3 -m pytest` 报 `No module named pytest`）

## Self-Check: PASSED (code) / PARTIAL (runtime)

- FOUND: mention 过滤逻辑已在 middleware 生效
- FOUND: 单测覆盖已补齐
- BLOCKED: 当前环境缺少 pytest，未能本地运行后端测试
