fix: 协助卡停轮与提交防 409,隐藏配置向导会话,并限制岗位会商产物重复写入
澄清中间件改为 ToolMessage + after_model 停轮,前端提交前取消残留 run;系统/向导 thread_type 从对话列表排除;岗位总结席位加 write_file 上限。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
51afebb394
commit
b81d200eca
31 files changed
+1459
-592
No files matched your search
+27
-3
@@ -15,9 +15,33 @@ three-state semantics (see :mod:`deerflow.runtime.user_context`):
|
||||
from __future__ import annotations
|
||||
|
||||
import abc
|
||||
from typing import Any
|
||||
|
||||
from deerflow.runtime.user_context import AUTO, _AutoSentinel
|
||||
|
||||
# Configuration wizards / machine workers that must not appear in the default
|
||||
# conversation list. Prefer ``metadata.system=true`` on create; this set also
|
||||
# covers older rows that only set ``thread_type``.
|
||||
EXCLUDED_SYSTEM_THREAD_TYPES = frozenset(
|
||||
{
|
||||
"scheduler",
|
||||
"roundtable",
|
||||
"notebook",
|
||||
"deep_research",
|
||||
"writing_setup",
|
||||
"report_structure_setup",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def is_excluded_system_thread(metadata: dict[str, Any] | None) -> bool:
|
||||
"""Return True when a thread should be hidden from user conversation lists."""
|
||||
md = metadata or {}
|
||||
if md.get("system"):
|
||||
return True
|
||||
thread_type = md.get("thread_type")
|
||||
return isinstance(thread_type, str) and thread_type in EXCLUDED_SYSTEM_THREAD_TYPES
|
||||
|
||||
|
||||
class ThreadMetaStore(abc.ABC):
|
||||
@abc.abstractmethod
|
||||
@@ -56,9 +80,9 @@ class ThreadMetaStore(abc.ABC):
|
||||
) -> list[dict]:
|
||||
"""Search threads ordered by ``updated_at`` desc.
|
||||
|
||||
``exclude_system=True`` drops threads whose ``metadata.system`` is
|
||||
truthy (scheduler runs, roundtable workers, …) so user-facing
|
||||
conversation lists are not crowded out by machine-created threads.
|
||||
``exclude_system=True`` drops machine / wizard threads (``metadata.system``
|
||||
or known ``thread_type`` values such as scheduler / report_structure_setup)
|
||||
so user-facing conversation lists are not crowded out.
|
||||
``query`` is a case-insensitive substring match on the thread title
|
||||
(``display_name``). ``limit``/``offset`` apply to the *filtered*
|
||||
result set.
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ from typing import Any
|
||||
|
||||
from langgraph.store.base import BaseStore
|
||||
|
||||
from deerflow.persistence.thread_meta.base import ThreadMetaStore
|
||||
from deerflow.persistence.thread_meta.base import ThreadMetaStore, is_excluded_system_thread
|
||||
from deerflow.runtime.user_context import AUTO, _AutoSentinel, resolve_user_id
|
||||
from deerflow.utils.time import coerce_iso, now_iso
|
||||
|
||||
@@ -107,7 +107,7 @@ class MemoryThreadMetaStore(ThreadMetaStore):
|
||||
# until the requested window is full so ``limit``/``offset`` refer to
|
||||
# filtered rows.
|
||||
def _matches(record: dict) -> bool:
|
||||
if exclude_system and (record.get("metadata") or {}).get("system"):
|
||||
if exclude_system and is_excluded_system_thread(record.get("metadata")):
|
||||
return False
|
||||
if normalized_query and normalized_query not in (record.get("display_name") or "").lower():
|
||||
return False
|
||||
@@ -169,7 +169,7 @@ class MemoryThreadMetaStore(ThreadMetaStore):
|
||||
break
|
||||
for item in items:
|
||||
record = self._item_to_dict(item)
|
||||
if exclude_system and (record.get("metadata") or {}).get("system"):
|
||||
if exclude_system and is_excluded_system_thread(record.get("metadata")):
|
||||
continue
|
||||
if normalized_query and normalized_query not in (record.get("display_name") or "").lower():
|
||||
continue
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@ from typing import Any
|
||||
from sqlalchemy import func, select, update
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
|
||||
|
||||
from deerflow.persistence.thread_meta.base import ThreadMetaStore
|
||||
from deerflow.persistence.thread_meta.base import ThreadMetaStore, is_excluded_system_thread
|
||||
from deerflow.persistence.thread_meta.model import ThreadMetaRow
|
||||
from deerflow.runtime.user_context import AUTO, _AutoSentinel, resolve_user_id
|
||||
|
||||
@@ -166,7 +166,7 @@ class ThreadMetaRepository(ThreadMetaStore):
|
||||
md = row.get("metadata") or {}
|
||||
if metadata and not all(md.get(k) == v for k, v in metadata.items()):
|
||||
return False
|
||||
if exclude_system and md.get("system"):
|
||||
if exclude_system and is_excluded_system_thread(md):
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -233,7 +233,7 @@ class ThreadMetaRepository(ThreadMetaStore):
|
||||
md = metadata_json or {}
|
||||
if metadata and not all(md.get(k) == v for k, v in metadata.items()):
|
||||
continue
|
||||
if exclude_system and md.get("system"):
|
||||
if exclude_system and is_excluded_system_thread(md):
|
||||
continue
|
||||
total += 1
|
||||
if len(rows) < batch_size:
|
||||
|
||||
Reference in new issue
Block a user