Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions tests/extensions/test_lark_goal_topic_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess
import threading
from collections.abc import Mapping
from datetime import UTC, datetime, timedelta
from pathlib import Path
from typing import Any

Expand All @@ -24,6 +25,20 @@
from loopx.extensions.lark.goal_topic_connections import connect_lark_goal_topic


def _fixture_time(minutes_ago: int) -> str:
"""One hour of topic history, placed relative to the run.

Manager context is bounded by MANAGER_CONTEXT_MAX_AGE, so a literal date in
these fixtures turns the calendar into a test dependency. Whole-minute
resolution keeps repeated calls equal, as the fixed timestamps were.
"""

moment = (datetime.now(UTC) - timedelta(minutes=minutes_ago)).replace(
second=0, microsecond=0
)
return moment.isoformat().replace("+00:00", "Z")


def test_goal_topic_runtime_exposes_the_inbox_bridge() -> None:
module = importlib.import_module("loopx.extensions.lark.goal_topic_runtime")

Expand Down Expand Up @@ -342,7 +357,7 @@ def answer(route: Any, text: str) -> str:
"message_id": "om_context_only",
"chat_id": "oc_public_fixture",
"root_id": "om_unrelated_thread",
"create_time": "2026-09-13T05:59:00Z",
"create_time": _fixture_time(61),
"content": "先把这个背景放在这里",
"mentions": [],
"sender_type": "user",
Expand All @@ -363,7 +378,7 @@ def answer(route: Any, text: str) -> str:
"message_id": "om_context_only",
"chat_id": "oc_public_fixture",
"root_id": "om_unrelated_thread",
"create_time": "2026-09-13T05:59:00Z",
"create_time": _fixture_time(61),
"content": "先把这个背景放在这里",
"mentions": [],
"sender_type": "user",
Expand All @@ -387,7 +402,7 @@ def answer(route: Any, text: str) -> str:
"message_id": "om_authorized",
"chat_id": "oc_public_fixture",
"root_id": "om_unrelated_thread",
"create_time": "2026-09-13T06:00:00Z",
"create_time": _fixture_time(60),
"content": "@linkmacbot 结合上文给结论",
"mentions": [{"id": "cli_public_fixture"}],
"sender_type": "user",
Expand All @@ -404,7 +419,7 @@ def answer(route: Any, text: str) -> str:
assert route["context_materials"] == [
{
"message_id": "om_context_only",
"create_time": "2026-09-13T05:59:00Z",
"create_time": _fixture_time(61),
"content": "先把这个背景放在这里",
}
]
Expand Down Expand Up @@ -450,7 +465,7 @@ def decision(**options: Any) -> dict[str, Any]:
"message_id": "om_invalid_authority",
"chat_id": "oc_public_fixture",
"root_id": "om_topic_alpha",
"create_time": "2026-09-13T06:00:00Z",
"create_time": _fixture_time(60),
"content": "continue",
"mentions": [],
"sender_type": "user",
Expand Down Expand Up @@ -516,7 +531,7 @@ def provider_runner(
{
"message_id": "om_old_authorized",
"root_id": "om_topic_alpha",
"create_time": "2026-09-13T05:59:00Z",
"create_time": _fixture_time(61),
"content": "@linkmacbot 历史请求只作背景",
"mentions": [{"id": "cli_public_fixture"}],
"sender_type": "user",
Expand Down Expand Up @@ -545,7 +560,7 @@ def answer(route: Mapping[str, Any], _text: str) -> str:
"message_id": "om_current_authorized",
"chat_id": "oc_public_fixture",
"root_id": "om_topic_alpha",
"create_time": "2026-09-13T06:00:00Z",
"create_time": _fixture_time(60),
"content": "@linkmacbot 结合刚才内容回答",
"mentions": [{"id": "cli_public_fixture"}],
"sender_type": "user",
Expand Down
Loading