fix(channels): preserve Feishu clarification thread continuity#3285
Conversation
e733743 to
588832b
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes Feishu channel thread continuity when users reply to clarification cards, ensuring replies are routed back to the existing DeerFlow thread instead of starting a disconnected conversation.
Changes:
- Adds Feishu topic resolution using stored root/parent/thread message-id mappings.
- Records bot card message IDs back to the channel store for future reply lookup.
- Adds regression coverage for clarification card replies and running-card mapping persistence.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
backend/app/channels/feishu.py |
Resolves Feishu topic IDs from stored mappings and remembers card/source metadata mappings during replies. |
backend/tests/test_feishu_parser.py |
Adds regression coverage for card replies using a stored parent message mapping. |
backend/tests/test_channels.py |
Extends Feishu running-card tests to verify source/card/root mappings are stored. |
| store.set_thread_id( | ||
| self.name, | ||
| msg.chat_id, | ||
| msg.thread_id, | ||
| topic_id=topic_id, | ||
| user_id=user_id, | ||
| ) |
588832b to
86e3fe4
Compare
|
已补充修复:除了回复澄清卡片,现在也支持用户在群里直接发送澄清答复(例如选择编号或补充说明)时接回原 DeerFlow thread。 验证:
|
|
@zzp1221 , here are some comments for the code.
The _pending_clarifications dict lives in process memory. If the Feishu channel restarts (deploy, crash, etc.) between the clarification card and the user's reply, the mapping is lost and the bug reappears.
If the same user triggers two clarification cards in the same chat within the TTL, the second overwrites the first. The first clarification reply would then be treated as a new conversation. Consider whether _pending_clarifications should store a list or use a more specific key.
This walks backward and stops at the first "human" message. If the agent calls ask_clarification followed by other tool calls (or nested agent turns with additional human messages), the heuristic could miss or incorrectly detect a clarification. Consider whether there's a more reliable signal from the graph execution. |
|
@WillemJiang For the in-memory pending state, this is intentional because it only covers the short-lived plain-message clarification reply path. Explicit Feishu replies are still handled by persisted message-id mappings. I’ve also called this out in the PR description. Changes made:
|
Fixes #3274
Summary
Test
cd backend && uvx ruff check . --fixcd backend && uvx ruff format .cd backend && uvx ruff check .cd backend && uvx ruff format --check .git diff --checkcd backend && uv run pytest tests/test_feishu_parser.py tests/test_channels.py::TestFeishuChannel -qcd frontend && pnpm testcd frontend && pnpm test:e2eNote
The plain-message pending clarification state is intentionally in-memory and best-effort for the short 30-minute window. Explicit Feishu replies are still covered by persisted message-id mappings, so they continue to work across restarts.
Full backend suite was also run locally on Windows:
3611 passed, 31 skipped, 37 failed. The failures look unrelated to this Feishu change and are mostly Windows/local-env issues such as symlink privileges and path separator expectations.