sync: 鍚屾灞€鍩熺綉鏈€鏂颁唬鐮?(source master @ b69568e4)
This commit is contained in:
1 parent
4f7f07504a
commit
8bc8b0e082
1651 files changed
+278599
-11416
No files matched your search
@@ -72,8 +72,8 @@ def test_position_intent_agent_is_a_seeded_functional_agent():
|
||||
assert POSITION_INTENT_AGENT_ID in set(required_agent_ids())
|
||||
|
||||
|
||||
def test_action_plan_seed_binds_the_batch_create_skill_and_nine_field_contract():
|
||||
"""New deployments must not fall back to the retired subtask JSON contract."""
|
||||
def test_action_plan_seed_uses_a_model_derived_action_type_and_nine_field_contract():
|
||||
"""Action types are semantic names, while the remaining task fields stay compatible."""
|
||||
action_assets = roundtable_seed._ASSETS_DIR / roundtable_seed.ACTION_PLAN_AGENT_ID
|
||||
soul = (action_assets / "SOUL.md").read_text(encoding="utf-8")
|
||||
config = (action_assets / "config.yaml").read_text(encoding="utf-8")
|
||||
@@ -91,16 +91,20 @@ def test_action_plan_seed_binds_the_batch_create_skill_and_nine_field_contract()
|
||||
"taskId",
|
||||
):
|
||||
assert field in soul
|
||||
assert '"actionType": "行动类型名称"' in soul
|
||||
assert "自行分析归纳" in soul
|
||||
assert "/task/action/add" in soul
|
||||
assert "批量新增" in soul
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_action_plan_prompt_receives_frontend_task_id_and_dictionary_values():
|
||||
"""The action planner must see exact dictValue choices, not frontend labels only."""
|
||||
async def test_action_plan_prompt_derives_action_type_instead_of_using_frontend_values():
|
||||
"""Only non-type fields keep their task-system dictionary values."""
|
||||
dictionaries = position_roundtable_router.ActionPlanDictionaries(
|
||||
publish_channels=[{"label": "微信公众号", "value": "11"}],
|
||||
action_types=[{"label": "宣传", "value": "21"}],
|
||||
# Legacy callers may still include this field. It must be ignored rather
|
||||
# than become an actionType candidate in the planner prompt.
|
||||
action_types=[{"label": "旧类型", "value": "21"}],
|
||||
info_formats=[{"label": "图文", "value": "31"}],
|
||||
responsible_positions=[{"label": "规划岗", "value": "41"}],
|
||||
)
|
||||
@@ -117,15 +121,17 @@ async def test_action_plan_prompt_receives_frontend_task_id_and_dictionary_value
|
||||
|
||||
assert "当前 taskId:1001" in prompt
|
||||
assert "微信公众号 → 11" in prompt
|
||||
assert "宣传 → 21" in prompt
|
||||
assert "图文 → 31" in prompt
|
||||
assert "规划岗 → 41" in prompt
|
||||
assert "actionType 必须由你根据方案总结和岗位交付自行分析归纳" in prompt
|
||||
assert "行动类型(actionType)" not in prompt
|
||||
assert "旧类型" not in prompt
|
||||
assert "id、title、goal" in prompt
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_action_plan_prompt_degrades_when_task_dictionaries_are_unavailable():
|
||||
"""A 404 from the task-system dictionaries must not block local planning."""
|
||||
async def test_action_plan_prompt_keeps_analyzed_type_when_task_dictionaries_are_unavailable():
|
||||
"""Unavailable task enums must not turn the independently inferred type into zero."""
|
||||
prompt = await position_roundtable_router._build_builtin_prompt(
|
||||
kind="action_plan",
|
||||
session={
|
||||
@@ -137,11 +143,74 @@ async def test_action_plan_prompt_degrades_when_task_dictionaries_are_unavailabl
|
||||
action_dictionaries=position_roundtable_router.ActionPlanDictionaries(),
|
||||
)
|
||||
|
||||
assert "字典未获取完整" in prompt
|
||||
assert "当前三类任务系统字典未获取完整" in prompt
|
||||
assert "actionType 仍须由你分析并填写中文类型名称" in prompt
|
||||
assert "不得调用 Skill" in prompt
|
||||
assert "0 占位" in prompt
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_action_plan_prompt_allows_direct_planning_without_a_summary():
|
||||
"""Removing the summary step must leave the planner with a usable direct path."""
|
||||
prompt = await position_roundtable_router._build_builtin_prompt(
|
||||
kind="action_plan",
|
||||
session={
|
||||
"task_snapshot": {"title": "直接规划任务", "description": "基于岗位交付生成行动"},
|
||||
},
|
||||
nodes=[],
|
||||
)
|
||||
|
||||
assert "已生效方案总结(如有)" in prompt
|
||||
assert "本轮未生成方案总结" in prompt
|
||||
assert "直接依据下方有效岗位交付、任务信息和已确认意图进行归纳" in prompt
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_action_plan_prepare_allows_a_missing_summary_snapshot(monkeypatch):
|
||||
"""The action planner may start as soon as all position deliveries are done."""
|
||||
session = {
|
||||
"task_snapshot": {"title": "直接规划任务"},
|
||||
"chain_snapshot": {"intentPositionId": "intent"},
|
||||
}
|
||||
nodes = [
|
||||
{
|
||||
"node_key": "stage-1-seat-1",
|
||||
"status": "done",
|
||||
"position_id": "planning",
|
||||
"revision": 1,
|
||||
"artifact_manifest": [
|
||||
{
|
||||
"name": "岗位交付.md",
|
||||
"path": "mnt/user-data/outputs/岗位交付.md",
|
||||
"content": "岗位交付内容",
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
|
||||
class Store:
|
||||
async def list_nodes(self, session_id, user_id):
|
||||
assert session_id == "session-direct"
|
||||
assert user_id == "user-a"
|
||||
return nodes
|
||||
|
||||
async def fake_require_writable_session(request, session_id):
|
||||
assert session_id == "session-direct"
|
||||
return Store(), "user-a", session
|
||||
|
||||
monkeypatch.setattr(position_roundtable_router, "_require_writable_session", fake_require_writable_session)
|
||||
|
||||
prepared = await position_roundtable_router._prepare_builtin_run(
|
||||
object(),
|
||||
"session-direct",
|
||||
kind="action_plan",
|
||||
)
|
||||
|
||||
assert prepared.agent_id == position_roundtable_router.ACTION_PLAN_AGENT_ID
|
||||
assert prepared.thread_id is None
|
||||
assert "本轮未生成方案总结" in prepared.prompt
|
||||
|
||||
|
||||
def test_action_plan_prepare_keeps_a_local_mock_task_id_without_numeric_coercion():
|
||||
"""A local demo id must not stop the action-plan conversation at prepare time."""
|
||||
body = position_roundtable_router.PrepareBuiltinRunRequest(task_id="abc123")
|
||||
@@ -149,8 +218,8 @@ def test_action_plan_prepare_keeps_a_local_mock_task_id_without_numeric_coercion
|
||||
assert body.task_id == "abc123"
|
||||
|
||||
|
||||
def test_action_batch_skill_accepts_only_the_nine_field_array(tmp_path):
|
||||
"""The batch Skill must reject old task-subdivision fields before any HTTP call."""
|
||||
def test_action_batch_skill_accepts_a_text_action_type_in_the_nine_field_array(tmp_path):
|
||||
"""The batch Skill preserves the model-derived action type name unchanged."""
|
||||
archive_path = roundtable_seed._ASSETS_DIR.parents[3] / "skill-packages" / "position-roundtable-action-create.skill"
|
||||
with zipfile.ZipFile(archive_path) as archive:
|
||||
archive.extractall(tmp_path / "skill-package")
|
||||
@@ -163,7 +232,7 @@ def test_action_batch_skill_accepts_only_the_nine_field_array(tmp_path):
|
||||
valid = [{
|
||||
"actionName": "发布内容",
|
||||
"actionDescription": "向目标渠道发布审核通过的信息。",
|
||||
"actionType": "1",
|
||||
"actionType": "内容发布",
|
||||
"publishChannel": "2",
|
||||
"infoFormat": "3",
|
||||
"responsiblePosition": "4",
|
||||
@@ -175,7 +244,6 @@ def test_action_batch_skill_accepts_only_the_nine_field_array(tmp_path):
|
||||
source.write_text(json.dumps(valid, ensure_ascii=False), encoding="utf-8")
|
||||
assert module.read_actions(source, 1001) == [{
|
||||
**valid[0],
|
||||
"actionType": 1,
|
||||
"publishChannel": 2,
|
||||
"infoFormat": 3,
|
||||
"responsiblePosition": 4,
|
||||
@@ -286,8 +354,8 @@ def test_position_intent_seed_repairs_its_contract_without_touching_other_agents
|
||||
assert generic_soul.read_text(encoding="utf-8") == "deployed generic tune"
|
||||
|
||||
|
||||
def test_existing_action_planner_only_merges_the_owned_skill(tmp_path, monkeypatch):
|
||||
"""A code upgrade may add the Skill without overwriting a user-tuned SOUL."""
|
||||
def test_existing_action_planner_refreshes_the_action_type_contract(tmp_path, monkeypatch):
|
||||
"""A deployed planner must stop requiring the retired action-type dictionary."""
|
||||
agents_dir = tmp_path / "agents"
|
||||
monkeypatch.setattr(
|
||||
roundtable_seed,
|
||||
@@ -306,7 +374,10 @@ def test_existing_action_planner_only_merges_the_owned_skill(tmp_path, monkeypat
|
||||
config = (action_dir / "config.yaml").read_text(encoding="utf-8")
|
||||
assert "existing-skill" in config
|
||||
assert "position-roundtable-action-create" in config
|
||||
assert (action_dir / "SOUL.md").read_text(encoding="utf-8") == "deployed action-plan tune"
|
||||
expected_soul = (
|
||||
roundtable_seed._ASSETS_DIR / roundtable_seed.ACTION_PLAN_AGENT_ID / "SOUL.md"
|
||||
).read_text(encoding="utf-8")
|
||||
assert (action_dir / "SOUL.md").read_text(encoding="utf-8") == expected_soul
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in new issue
Block a user