mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-11-27 23:58:47 +00:00
* fix(proactive): simplify round files and restore failed summaries * fix(proactive): validate document-relative Markdown links * feat(proactive_agent): implement v2 daily record workflow with single-file decision - Add ProactiveAgentStepV2 class to support single daily note decision and reminder - Introduce RoundOutputs for v2 round file tracking, and keep RoundArtifacts for v1 summary backup - Refactor AgentOutbox to support both v1 standalone reminder files and v2 daily reminder records - Add proactive_record utilities to parse and validate v2 daily record frontmatter and metadata - Enhance proactive_agent to prepare, read, and manage artifacts for both v1 and v2 flows - Add configuration profile proactive_v2 to enable new workflow with backward compatibility - Update proactive.yaml and reactive proactive_agent_step configuration comment for easy switching - Provide extensive schema validation for v2 reminders ensuring priority and message consistency - Document v2 workflow and usage in English and Chinese runtime docs - Add unit tests for v2 step verifying single file output and proper decision handling * refactor(agent/runtime): replace ReminderRef with string keys and simplify reminder handling - Remove ReminderRef model and switch to using workspace-relative string keys for reminders - Simplify AgentOutbox to read, write, and manage reminders keyed by strings - Change file locking and version checking to protect concurrent edits on daily record files - Replace legacy and v2 reminder file handling with unified ReminderFiles storage - Adjust ChatNotifications to operate with the new key scheme and update pending/read sets - Refactor RoundOutputs to RoundRecord for safer round record tracking and rollback - Remove unused ProactiveRunResult and related references from imports and exports - Update InboxWakeRequest, AgentReminder, and related models for consistent ID and path validation - Adjust proactive agent runtime and local runtime to check reminder versions before commit - Correct language and docs to describe reminders as daily records instead of separate files - Clean up roles of inbox and outbox for reminder ownership, delivery, and acknowledgments * fix(proactive): serialize round commits and align desktop reminders * refactor(proactive): unify task triggers in Proactive Runtime * fix(proactive): bound reminder payloads and simplify receipts * refactor(studio): share workbench and simplify proactive delivery * fix(studio): update and centralize build dependencies * fix(proactive): guard draft repair and verify Studio deployments * chore(docs): update source-map-js * feat(release): support publishing selected artifacts from a tag * chore(studio): remove the public playground * refactor: simplify reminders and release workflows * fix: preserve proactive records and align release provenance * test(proactive): remove brittle prompt and preset assertions * fix(proactive): register reminders after input acknowledgement * feat(notebook): list projects across todos and ideas * feat(studio): connect mobile apps to configurable ReMe services * fix(proactive): reserve registered reminder paths * fix(studio): request Android local network access * fix(proactive): reserve reminder paths referenced by receipts
109 lines
5.8 KiB
Python
109 lines
5.8 KiB
Python
"""Execution phases are presentation facts, never transcript content."""
|
|
|
|
from datetime import datetime
|
|
|
|
import pytest
|
|
|
|
from reme.schema import AgentActivity, StreamChunk
|
|
from reme.steps.proactive.agent._activity import ActivityTracker
|
|
|
|
|
|
def test_task_activity_requires_a_run_identity_and_keeps_it_through_phase_changes():
|
|
"""Task identity and start time survive native phase updates."""
|
|
started = datetime.fromisoformat("2026-11-09T12:00:00+08:00")
|
|
for fields in ({}, {"started_at": started}, {"task_id": "research"}):
|
|
with pytest.raises(ValueError, match="requires task_id and started_at"):
|
|
AgentActivity(session_id="s", turn_id="t", source="task", phase="thinking", **fields)
|
|
activity = AgentActivity(
|
|
session_id="s",
|
|
turn_id="t",
|
|
source="task",
|
|
phase="thinking",
|
|
started_at=started,
|
|
task_id="research",
|
|
)
|
|
updated = ActivityTracker(activity).update(StreamChunk(chunk_type="tool_call", tool_call_name="read_memory"))
|
|
assert updated.phase == "remembering" and updated.started_at == started and updated.task_id == "research"
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"payload, phase",
|
|
[
|
|
({"chunk_type": "think", "chunk": "reason"}, "thinking"),
|
|
({"chunk_type": "content", "chunk": "answer"}, "answering"),
|
|
({"chunk_type": "tool_call", "tool_call_name": "search_memory"}, "remembering"),
|
|
({"chunk_type": "tool_call", "tool_call_name": "web_search"}, "working"),
|
|
({"chunk_type": "tool_result", "status": "running"}, "working"),
|
|
({"chunk_type": "tool_result", "status": "failed"}, "thinking"),
|
|
({"chunk_type": "approval", "status": "waiting"}, "waiting"),
|
|
({"chunk_type": "approval", "status": "running"}, "answering"),
|
|
({"chunk_type": "reply_end", "status": "completed"}, "completed"),
|
|
({"chunk_type": "reply_end", "status": "failed"}, "failed"),
|
|
({"chunk_type": "reply_end", "status": "interrupted"}, "interrupted"),
|
|
({"chunk_type": "done", "done": True}, "answering"),
|
|
({"chunk_type": "error", "metadata": {"will_retry": True}}, "answering"),
|
|
],
|
|
)
|
|
def test_portable_events_update_activity_without_confusing_transport_or_tool_outcomes(payload, phase):
|
|
"""Only execution facts change phase, retaining delivery and turn identity."""
|
|
previous = AgentActivity(session_id="selected", turn_id="turn", source="proactive", phase="answering")
|
|
result = ActivityTracker(previous).update(StreamChunk(**payload))
|
|
assert result.phase == phase
|
|
assert result.session_id == "selected"
|
|
assert result.turn_id == "turn"
|
|
assert result.source == "proactive"
|
|
assert previous.phase == "answering"
|
|
|
|
|
|
def test_identical_text_deltas_have_identical_activity():
|
|
"""Token updates can be deduplicated without restarting presentation."""
|
|
state = AgentActivity(session_id="s", turn_id="t", phase="thinking")
|
|
tracker = ActivityTracker(state)
|
|
first = tracker.update(StreamChunk(chunk_type="content", chunk="one"))
|
|
assert tracker.update(StreamChunk(chunk_type="content", chunk="two")) == first
|
|
|
|
|
|
@pytest.mark.parametrize("first", ["a", "b"])
|
|
def test_parallel_tools_remain_working_until_all_calls_finish(first):
|
|
"""Out-of-order completions retain the remaining tool's actual name and phase."""
|
|
tracker = ActivityTracker(AgentActivity(session_id="s", turn_id="t", phase="thinking"))
|
|
names = {"a": "read_memory", "b": "web_search"}
|
|
for call_id, name in names.items():
|
|
tracker.update(StreamChunk(chunk_type="tool_call", tool_call_id=call_id, tool_call_name=name))
|
|
other = "b" if first == "a" else "a"
|
|
state = tracker.update(StreamChunk(chunk_type="tool_result", tool_call_id=first, status="completed"))
|
|
assert state.tool == names[other]
|
|
assert state.phase == ("remembering" if other == "a" else "working")
|
|
for duplicate in (first, "unknown"):
|
|
assert tracker.update(StreamChunk(chunk_type="tool_result", tool_call_id=duplicate, status="failed")) == state
|
|
assert tracker.update(StreamChunk(chunk_type="tool_result", tool_call_id=first, status="running")) == state
|
|
assert tracker.update(StreamChunk(chunk_type="think", chunk="still processing")) == state
|
|
final = tracker.update(StreamChunk(chunk_type="tool_result", tool_call_id=other, status="failed"))
|
|
assert final.phase == "thinking" and final.tool is None
|
|
|
|
|
|
@pytest.mark.parametrize("outcome", ["completed", "failed", "interrupted"])
|
|
def test_terminal_outcomes_clear_unfinished_tools(outcome):
|
|
"""An interrupted tool cannot leak into a later turn, including reused call IDs."""
|
|
tracker = ActivityTracker(AgentActivity(session_id="s", turn_id="t", phase="thinking"))
|
|
tracker.update(StreamChunk(chunk_type="tool_call", tool_call_id="a", tool_call_name="read_memory"))
|
|
result = tracker.update(StreamChunk(chunk_type="reply_end", status=outcome))
|
|
assert result.phase == outcome and result.tool is None
|
|
assert tracker.update(StreamChunk(chunk_type="think", chunk="late")).phase == outcome
|
|
next_turn = ActivityTracker(AgentActivity(session_id="s", turn_id="next", phase="thinking"))
|
|
assert (
|
|
next_turn.update(StreamChunk(chunk_type="tool_call", tool_call_id="a", tool_call_name="web_search")).phase
|
|
== "working"
|
|
)
|
|
|
|
|
|
def test_unnamed_parallel_tools_still_block_the_thinking_phase():
|
|
"""An optional display name must not affect unfinished-call accounting."""
|
|
tracker = ActivityTracker(AgentActivity(session_id="s", turn_id="t", phase="thinking"))
|
|
for call_id in ("a", "b"):
|
|
tracker.update(StreamChunk(chunk_type="tool_call", tool_call_id=call_id))
|
|
tracker.update(StreamChunk(chunk_type="tool_result", tool_call_id="a", status="completed"))
|
|
assert tracker.update(StreamChunk(chunk_type="think", chunk="reasoning")).phase == "working"
|
|
assert (
|
|
tracker.update(StreamChunk(chunk_type="tool_result", tool_call_id="b", status="completed")).phase == "thinking"
|
|
)
|