sync update from LAN repo (source dhk-1 @ 3b1ec5b4)
This commit is contained in:
1 parent
da6521b6cb
commit
264e2200d6
995 files changed
+148105
-13399
No files matched your search
@@ -110,6 +110,17 @@ def _state(material_source="knowledge_base"):
|
||||
}
|
||||
|
||||
|
||||
def _patch_whitelist(monkeypatch, skills):
|
||||
"""把素材收集专家(ai-writing-researcher)的 skills 白名单打成固定值。"""
|
||||
import deerflow.config.agents_config as agents_config_module
|
||||
|
||||
monkeypatch.setattr(
|
||||
agents_config_module,
|
||||
"load_agent_config",
|
||||
lambda _agent_id: SimpleNamespace(skills=list(skills)),
|
||||
)
|
||||
|
||||
|
||||
def test_general_skill_candidates_do_not_resurrect_explicitly_offline_knowledge_search(
|
||||
tmp_path,
|
||||
monkeypatch,
|
||||
@@ -120,6 +131,7 @@ def test_general_skill_candidates_do_not_resurrect_explicitly_offline_knowledge_
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.setenv("DEER_FLOW_EXTENSIONS_CONFIG_PATH", str(extensions_path))
|
||||
_patch_whitelist(monkeypatch, ["knowledge-base-search", "other-search"])
|
||||
|
||||
other = SimpleNamespace(name="other-search", description="other")
|
||||
|
||||
@@ -140,6 +152,7 @@ def test_general_skill_candidates_keep_missing_catalog_fallback(tmp_path, monkey
|
||||
extensions_path = tmp_path / "extensions_config.json"
|
||||
extensions_path.write_text('{"mcpServers": {}, "skills": {}}', encoding="utf-8")
|
||||
monkeypatch.setenv("DEER_FLOW_EXTENSIONS_CONFIG_PATH", str(extensions_path))
|
||||
_patch_whitelist(monkeypatch, [])
|
||||
|
||||
class _Storage:
|
||||
def load_skills(self, *, enabled_only=False):
|
||||
@@ -154,6 +167,67 @@ def test_general_skill_candidates_keep_missing_catalog_fallback(tmp_path, monkey
|
||||
assert [skill.name for skill in R._fallback_candidate_skills(set())] == [R.KNOWLEDGE_SEARCH_SKILL_NAME]
|
||||
|
||||
|
||||
def test_general_skill_candidates_limited_to_researcher_whitelist(tmp_path, monkeypatch) -> None:
|
||||
"""300+ 技能部署:候选池只取白名单里的启用技能,其余一概不进池。"""
|
||||
extensions_path = tmp_path / "extensions_config.json"
|
||||
extensions_path.write_text('{"mcpServers": {}, "skills": {}}', encoding="utf-8")
|
||||
monkeypatch.setenv("DEER_FLOW_EXTENSIONS_CONFIG_PATH", str(extensions_path))
|
||||
_patch_whitelist(monkeypatch, ["custom-a", "knowledge-base-search", "custom-b", "missing-skill"])
|
||||
|
||||
def _skill(name: str):
|
||||
return SimpleNamespace(name=name, description=f"desc-{name}")
|
||||
|
||||
catalog = [_skill(f"bulk-{i}") for i in range(300)] + [
|
||||
_skill("custom-b"),
|
||||
_skill("custom-a"),
|
||||
_skill(R.KNOWLEDGE_SEARCH_SKILL_NAME),
|
||||
]
|
||||
|
||||
class _Storage:
|
||||
def load_skills(self, *, enabled_only=False):
|
||||
return catalog
|
||||
|
||||
import deerflow.skills.storage as storage_module
|
||||
|
||||
monkeypatch.setattr(storage_module, "get_or_new_skill_storage", lambda: _Storage())
|
||||
|
||||
# 白名单顺序保留,但内置知识库检索始终提到最前;目录里不存在的
|
||||
# missing-skill 与 300 个 bulk-* 全部排除。
|
||||
assert [skill.name for skill in R._load_candidate_skills()] == [
|
||||
R.KNOWLEDGE_SEARCH_SKILL_NAME,
|
||||
"custom-a",
|
||||
"custom-b",
|
||||
]
|
||||
|
||||
|
||||
def test_fallback_candidates_stay_inside_researcher_whitelist(tmp_path, monkeypatch) -> None:
|
||||
"""容错兜底也不回到全量技能目录:仍限定在白名单内。"""
|
||||
extensions_path = tmp_path / "extensions_config.json"
|
||||
extensions_path.write_text('{"mcpServers": {}, "skills": {}}', encoding="utf-8")
|
||||
monkeypatch.setenv("DEER_FLOW_EXTENSIONS_CONFIG_PATH", str(extensions_path))
|
||||
_patch_whitelist(monkeypatch, ["knowledge-base-search", "custom-a"])
|
||||
|
||||
def _skill(name: str):
|
||||
return SimpleNamespace(name=name, description=f"desc-{name}")
|
||||
|
||||
class _Storage:
|
||||
def load_skills(self, *, enabled_only=False):
|
||||
return [_skill("custom-a"), _skill("bulk-other"), _skill(R.KNOWLEDGE_SEARCH_SKILL_NAME)]
|
||||
|
||||
import deerflow.skills.storage as storage_module
|
||||
|
||||
monkeypatch.setattr(storage_module, "get_or_new_skill_storage", lambda: _Storage())
|
||||
|
||||
assert [skill.name for skill in R._fallback_candidate_skills(set())] == [
|
||||
R.KNOWLEDGE_SEARCH_SKILL_NAME,
|
||||
"custom-a",
|
||||
]
|
||||
# 已试过的技能不再进入兜底池
|
||||
assert [skill.name for skill in R._fallback_candidate_skills({"custom-a"})] == [
|
||||
R.KNOWLEDGE_SEARCH_SKILL_NAME,
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_knowledge_base_hits_intranet_directly(monkeypatch):
|
||||
_patch(monkeypatch)
|
||||
|
||||
Reference in new issue
Block a user