diff --git a/agentwatch/cli/main.py b/agentwatch/cli/main.py index 8f2db1b1..af5212ec 100644 --- a/agentwatch/cli/main.py +++ b/agentwatch/cli/main.py @@ -1557,3 +1557,30 @@ def main() -> None: if __name__ == "__main__": main() + + +@app.command(name="replay-session") +@session_app.command(name="replay-session") +def replay_session( + session_id: str = typer.Argument(..., help="ID of the session to replay"), + step: int = typer.Option(0, help="Step to resume from"), +) -> None: + """[bold]Replay[/bold]: Rewind and resume failed agent sessions.""" + + async def _run(): + from agentwatch.rollback.engine import RollbackEngine, RollbackStatus + + engine = RollbackEngine() + res = await engine.rollback_session(session_id, to_step=step) + if res.status == RollbackStatus.COMPLETED: + console.print( + Panel( + f"Session [cyan]{session_id}[/cyan] rewound to step [yellow]{step}[/yellow] and is ready to resume.", + title="[blue]Replay-Session[/blue]", + border_style="blue", + ) + ) + else: + console.print(f"[red]Failed to rewind: {res.error}[/red]") + + asyncio.run(_run()) diff --git a/agentwatch/orchestration/__init__.py b/agentwatch/orchestration/__init__.py index 564ba559..80ad956f 100644 --- a/agentwatch/orchestration/__init__.py +++ b/agentwatch/orchestration/__init__.py @@ -1 +1,2 @@ +from agentwatch.orchestration.bft_consensus import * from agentwatch.orchestration.engine import * diff --git a/tests/test_multiagent.py b/tests/test_multiagent.py index f1f490b8..d792e030 100644 --- a/tests/test_multiagent.py +++ b/tests/test_multiagent.py @@ -5,6 +5,7 @@ import pytest from agentwatch.core.event_bus import EventBus +from agentwatch.orchestration.bft_consensus import BFTConsensusEngine from agentwatch.orchestration.consensus import AgentVote, detect_consensus from agentwatch.orchestration.crew_context import CrewContext from agentwatch.orchestration.dag import InterAgentDAG diff --git a/tests/test_protocol.py b/tests/test_protocol.py index c880ff39..bd03dffc 100644 --- a/tests/test_protocol.py +++ b/tests/test_protocol.py @@ -181,6 +181,7 @@ def test_mcp_server_unknown_tool(): @pytest.mark.asyncio async def test_mcp_server_build_fastmcp(): + pytest.importorskip("mcp") srv = AgentWatchMCPServer() fastmcp = srv.build_fastmcp()