fix(bioflow): QA 生信流加活跃任务续接分支,续接输入(提供文件/参数等)不再掉普通 QA (#011)
This commit is contained in:
@@ -609,8 +609,16 @@ def _try_bioflow_agent_impl(
|
||||
if isinstance(card_result, dict) and str(card_result.get("card") or "").strip() in CARD_TYPES:
|
||||
return _route_card_result(card_result, llm_client, capabilities, bioflow, progress_callback)
|
||||
|
||||
# NL 路径:门 2 + 门 3
|
||||
manifests = _candidate_capabilities(question, capabilities)
|
||||
# NL 路径:活跃任务续接优先(有活跃任务时跳过意图预筛,直接按任务 chain 续接)
|
||||
active_job_id = (bioflow or {}).get("active_job_id")
|
||||
if active_job_id:
|
||||
manifests = _registered_capabilities(capabilities)
|
||||
cap_name = _chain_to_capability((bioflow or {}).get("chain") or "")
|
||||
if cap_name:
|
||||
manifests = [m for m in manifests if m.name == cap_name]
|
||||
else:
|
||||
# 无活跃任务:门 2 + 门 3 意图预筛(新任务入口)
|
||||
manifests = _candidate_capabilities(question, capabilities)
|
||||
if not manifests:
|
||||
return None
|
||||
|
||||
|
||||
@@ -109,6 +109,33 @@ class TestGateLogic:
|
||||
)
|
||||
assert result is None
|
||||
|
||||
def test_active_job_continuation_skips_intent_prescreen(self, tmp_path):
|
||||
"""#011:有活跃任务时,续接输入(不含触发词)也应进入生信流,不掉普通 QA。"""
|
||||
registry = _make_registry(tmp_path)
|
||||
fake_tools = [
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "fetch_source_file",
|
||||
"description": "获取源文件",
|
||||
"parameters": {"type": "object", "properties": {}},
|
||||
},
|
||||
}
|
||||
]
|
||||
with mock.patch.object(ba, "get_registry", return_value=registry):
|
||||
with mock.patch.object(ba, "_build_tools", return_value=(fake_tools, {"fetch_source_file": mock.ANY})):
|
||||
with mock.patch.dict("os.environ", {ba.ENV_FUSE: "1"}):
|
||||
result = ba.try_bioflow_agent(
|
||||
"基因组文件在 https://example.com/rice.fa",
|
||||
llm_client=FakeLLMClient(),
|
||||
capabilities=None,
|
||||
bioflow={"active_job_id": "job-1", "chain": "gene_family"},
|
||||
)
|
||||
assert result is not None
|
||||
assert result["success"] is True
|
||||
assert result["bioflow"]["handled"] is True
|
||||
assert result["bioflow"]["capabilities"] == ["bioflow-gene-family"]
|
||||
|
||||
def test_not_registered_returns_none(self, tmp_path):
|
||||
empty = CapabilityRegistry(tmp_path / "empty.yaml")
|
||||
empty.load()
|
||||
|
||||
Reference in New Issue
Block a user