mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-24 05:41:40 +00:00
fix(acp): replay native todo plans
This commit is contained in:
parent
4444d5fe4f
commit
bd3a5873e1
4 changed files with 99 additions and 9 deletions
|
|
@ -12,6 +12,7 @@ from acp.agent.router import build_agent_router
|
|||
from acp.schema import (
|
||||
AgentCapabilities,
|
||||
AgentMessageChunk,
|
||||
AgentPlanUpdate,
|
||||
AuthenticateResponse,
|
||||
AvailableCommandsUpdate,
|
||||
Implementation,
|
||||
|
|
@ -391,6 +392,57 @@ class TestSessionOps:
|
|||
assert "Search results" in tool_updates[1].content[0].content.text
|
||||
assert "cli.py:42" in tool_updates[1].content[0].content.text
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_load_session_replays_native_plan_for_persisted_todo_tool(self, agent):
|
||||
"""Persisted todo tool results should rebuild Zed's native plan panel."""
|
||||
mock_conn = MagicMock(spec=acp.Client)
|
||||
mock_conn.session_update = AsyncMock()
|
||||
agent._conn = mock_conn
|
||||
|
||||
new_resp = await agent.new_session(cwd="/tmp")
|
||||
state = agent.session_manager.get_session(new_resp.session_id)
|
||||
state.history = [
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": "",
|
||||
"tool_calls": [
|
||||
{
|
||||
"id": "call_todo_1",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "todo",
|
||||
"arguments": '{"todos":[{"id":"ship","content":"Ship it","status":"in_progress"}]}',
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "call_todo_1",
|
||||
"content": '{"todos":[{"id":"ship","content":"Ship it","status":"in_progress"}]}',
|
||||
},
|
||||
]
|
||||
|
||||
mock_conn.session_update.reset_mock()
|
||||
resp = await agent.load_session(cwd="/tmp", session_id=new_resp.session_id)
|
||||
await asyncio.sleep(0)
|
||||
await asyncio.sleep(0)
|
||||
|
||||
assert isinstance(resp, LoadSessionResponse)
|
||||
relevant_updates = [
|
||||
update for update in (call.kwargs["update"] for call in mock_conn.session_update.await_args_list)
|
||||
if getattr(update, "session_update", None) in {"tool_call", "tool_call_update", "plan"}
|
||||
]
|
||||
assert [getattr(update, "session_update", None) for update in relevant_updates] == [
|
||||
"tool_call",
|
||||
"tool_call_update",
|
||||
"plan",
|
||||
]
|
||||
plan = relevant_updates[2]
|
||||
assert isinstance(plan, AgentPlanUpdate)
|
||||
assert [entry.content for entry in plan.entries] == ["Ship it"]
|
||||
assert [entry.status for entry in plan.entries] == ["in_progress"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_resume_session_replays_persisted_history_to_client(self, agent):
|
||||
mock_conn = MagicMock(spec=acp.Client)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue