From a0fe84ca94134f8a70a3f07e912ef2a477a7a2bc Mon Sep 17 00:00:00 2001 From: ciregenz Date: Tue, 28 Jul 2026 17:52:47 -0700 Subject: [PATCH] [eric] events: de-prefix tested seams (suggest_mcps, steps_signature) --- backend/apps/agents/schedule_mcp_server.py | 8 ++++---- backend/tests/test_event_universal.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/apps/agents/schedule_mcp_server.py b/backend/apps/agents/schedule_mcp_server.py index 1effeea1..01d214e6 100644 --- a/backend/apps/agents/schedule_mcp_server.py +++ b/backend/apps/agents/schedule_mcp_server.py @@ -678,7 +678,7 @@ MCP_HINTS = { } -def p_suggest_mcps(check: str, known: set) -> list: +def suggest_mcps(check: str, known: set) -> list: """Infer connected tools from the check sentence so the user never names them; only suggests tools that actually exist.""" text = check.lower() out = [] @@ -705,7 +705,7 @@ def p_known_tools() -> set: return known -def p_steps_signature(steps: list) -> str: +def steps_signature(steps: list) -> str: # MUST byte-match the FE stepsSignature (JSON.stringify of [id, text] pairs); pinned by test_watch_for_event_tool. return json.dumps([[s["id"], s["text"]] for s in steps], separators=(",", ":"), ensure_ascii=False) @@ -766,7 +766,7 @@ def p_build_trigger(args: dict) -> tuple: return None, "kind=agent needs check (one sentence describing the condition)." mcps = [str(m) for m in (args.get("mcps") or [])] if not mcps: - mcps = p_suggest_mcps(args["check"], p_known_tools()) + mcps = suggest_mcps(args["check"], p_known_tools()) mcp_err = p_validate_mcps(mcps) if mcp_err: return None, mcp_err @@ -831,7 +831,7 @@ def handle_watch_for_event(args: dict) -> dict: "event_triggers": [trigger], "source_session_id": PARENT_SESSION_ID or None, "dashboard_id": DASHBOARD_ID or None, - "tested_signature": p_steps_signature(steps_payload), + "tested_signature": steps_signature(steps_payload), } r = _call("POST", "/create", body) if "_error" in r: diff --git a/backend/tests/test_event_universal.py b/backend/tests/test_event_universal.py index 2b1c2318..1af85a85 100644 --- a/backend/tests/test_event_universal.py +++ b/backend/tests/test_event_universal.py @@ -215,8 +215,8 @@ def test_mcp_auto_suggest_and_signature_vector(monkeypatch): import backend.apps.agents.schedule_mcp_server as srv known = {"google-workspace", "notion"} - assert srv.p_suggest_mcps("a new email from my landlord arrived", known) == ["google-workspace"] - assert srv.p_suggest_mcps("my notion database gained a row", known) == ["notion"] - assert srv.p_suggest_mcps("the moon is full", known) == [] + assert srv.suggest_mcps("a new email from my landlord arrived", known) == ["google-workspace"] + assert srv.suggest_mcps("my notion database gained a row", known) == ["notion"] + assert srv.suggest_mcps("the moon is full", known) == [] # Byte-match the FE stepsSignature: JSON.stringify([["s1","a\"b"]]). - assert srv.p_steps_signature([{"id": "s1", "text": 'a"b'}]) == '[["s1","a\\"b"]]' + assert srv.steps_signature([{"id": "s1", "text": 'a"b'}]) == '[["s1","a\\"b"]]'