oclaw/tests/test_plan_agent_v2_gateway_cutover_draft.py
oliver 420abac9f1 refactor: root-package imports (svc/runtime/interfaces) and fix PYTHONPATH
- Rename platform/ to svc/ to avoid shadowing stdlib platform.
- Replace from oclaw.* with from svc/runtime/interfaces; update -m CLI paths.
- tests/conftest: prepend repo root to sys.path (no parent-folder package name).
- CI: paths and offline_eval script under repo root.
- Ops scripts: PYTHONPATH must be repo root for python -m runtime.* (fixes gateway/WhatsApp sidecar startup).
- Fix default oclaw.json path in tabular/file attachment limits; stabilize attachment test config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 14:51:17 +08:00

80 lines
2.4 KiB
Python

from __future__ import annotations
from pathlib import Path
from svc.persistence.sqlite_store import SqliteStore
from runtime.plan_agent_v2_gateway_cutover import maybe_handle_expert_turn_v2_draft
from runtime.types import StandardMessage
def _msg(text: str) -> StandardMessage:
return StandardMessage(
session_id="cutover-s1",
tenant_id="t1",
user_id="u1",
role="user",
channel="chat",
text=text,
attachments=[],
metadata={},
)
def test_cutover_draft_off_by_default(tmp_path: Path) -> None:
store = SqliteStore(str(tmp_path / "ops.sqlite"))
out = maybe_handle_expert_turn_v2_draft(
store=store,
msg=_msg("hello"),
lang="zh",
interaction_mode="expert",
requested_specialist="generalist",
base_system_prompt="base",
force_flag=False,
)
assert out.handled is False
assert out.result is None
def test_cutover_draft_plan_reply_when_forced(tmp_path: Path) -> None:
store = SqliteStore(str(tmp_path / "ops.sqlite"))
store.set_setting("AIA_EXPERT_PLAN_FILE_DIR", str(tmp_path / "plans"))
out = maybe_handle_expert_turn_v2_draft(
store=store,
msg=_msg("我要做改造"),
lang="zh",
interaction_mode="expert",
requested_specialist="generalist",
base_system_prompt="base",
force_flag=True,
)
assert out.handled is False
assert out.result is None
assert out.decision_action == "run_agent"
assert "base" in str(out.system_prompt_override or "")
def test_cutover_draft_run_agent_returns_prompt_override(tmp_path: Path) -> None:
store = SqliteStore(str(tmp_path / "ops.sqlite"))
store.set_setting("AIA_EXPERT_PLAN_FILE_DIR", str(tmp_path / "plans"))
_ = maybe_handle_expert_turn_v2_draft(
store=store,
msg=_msg("先给个计划"),
lang="zh",
interaction_mode="expert",
requested_specialist="generalist",
base_system_prompt="base",
force_flag=True,
)
out = maybe_handle_expert_turn_v2_draft(
store=store,
msg=_msg("确认"),
lang="zh",
interaction_mode="expert",
requested_specialist="generalist",
base_system_prompt="base",
force_flag=True,
)
assert out.decision_action == "stay_plan"
assert out.handled is True
assert out.result is not None