From 21c79582bf9c8f06f384e664b7b62cef93232bbb Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 13 Oct 2026 10:59:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(bioflow):=20QA=20=E7=94=9F=E4=BF=A1?= =?UTF-8?q?=E6=B5=81=E5=8A=A0=E6=B4=BB=E8=B7=83=E4=BB=BB=E5=8A=A1=E7=BB=AD?= =?UTF-8?q?=E6=8E=A5=E5=88=86=E6=94=AF=EF=BC=8C=E7=BB=AD=E6=8E=A5=E8=BE=93?= =?UTF-8?q?=E5=85=A5(=E6=8F=90=E4=BE=9B=E6=96=87=E4=BB=B6/=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=AD=89)=E4=B8=8D=E5=86=8D=E6=8E=89=E6=99=AE?= =?UTF-8?q?=E9=80=9A=20QA=20(#011)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/qa/src/rag/qa_v1_1_73/bioflow_agent.py | 12 +++++++-- .../src/rag/qa_v1_1_73/test_bioflow_agent.py | 27 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/agent/qa/src/rag/qa_v1_1_73/bioflow_agent.py b/agent/qa/src/rag/qa_v1_1_73/bioflow_agent.py index dd04e3a..365e312 100644 --- a/agent/qa/src/rag/qa_v1_1_73/bioflow_agent.py +++ b/agent/qa/src/rag/qa_v1_1_73/bioflow_agent.py @@ -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 diff --git a/agent/qa/src/rag/qa_v1_1_73/test_bioflow_agent.py b/agent/qa/src/rag/qa_v1_1_73/test_bioflow_agent.py index d8d0977..aa39b28 100644 --- a/agent/qa/src/rag/qa_v1_1_73/test_bioflow_agent.py +++ b/agent/qa/src/rag/qa_v1_1_73/test_bioflow_agent.py @@ -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()