fix(acp): drop dead message_id kwarg from replay chunks

UserMessageChunk and AgentMessageChunk do not have a message_id field
in the ACP schema. Passing it silently dropped the kwarg (pydantic
does not raise on unknown init kwargs here) and the subsequent test
assertions on .message_id raised AttributeError. Strip the dead
plumbing (uuid import, message_id= kwarg on both chunk types, unused
session_id/index parameters) and remove the matching .message_id
asserts from the test.
This commit is contained in:
teknium1 2026-04-30 02:36:42 -07:00 committed by Teknium
parent d2536a72bf
commit 658947480a
2 changed files with 2 additions and 15 deletions

View File

@ -6,7 +6,6 @@ import asyncio
import contextvars
import logging
import os
import uuid
from collections import defaultdict, deque
from concurrent.futures import ThreadPoolExecutor
from typing import Any, Deque, Optional
@ -403,25 +402,20 @@ class HermesACPAgent(acp.Agent):
@staticmethod
def _history_message_update(
*,
session_id: str,
index: int,
role: str,
text: str,
) -> UserMessageChunk | AgentMessageChunk | None:
"""Build an ACP history replay update for a user/assistant message."""
message_id = str(uuid.uuid5(uuid.NAMESPACE_URL, f"hermes-acp:{session_id}:{index}:{role}"))
block = TextContentBlock(type="text", text=text)
if role == "user":
return UserMessageChunk(
session_update="user_message_chunk",
content=block,
message_id=message_id,
)
if role == "assistant":
return AgentMessageChunk(
session_update="agent_message_chunk",
content=block,
message_id=message_id,
)
return None
@ -437,19 +431,14 @@ class HermesACPAgent(acp.Agent):
if not self._conn or not state.history:
return
for index, message in enumerate(state.history):
for message in state.history:
role = str(message.get("role") or "")
if role not in {"user", "assistant"}:
continue
text = self._history_message_text(message)
if not text:
continue
update = self._history_message_update(
session_id=state.session_id,
index=index,
role=role,
text=text,
)
update = self._history_message_update(role=role, text=text)
if update is None:
continue
try:

View File

@ -254,10 +254,8 @@ class TestSessionOps:
assert len(replay_calls) == 2
assert isinstance(replay_calls[0].kwargs["update"], UserMessageChunk)
assert replay_calls[0].kwargs["update"].content.text == "what controls the / slash commands?"
assert replay_calls[0].kwargs["update"].message_id
assert isinstance(replay_calls[1].kwargs["update"], AgentMessageChunk)
assert replay_calls[1].kwargs["update"].content.text.startswith("HermesACPAgent")
assert replay_calls[1].kwargs["update"].message_id
@pytest.mark.asyncio
async def test_resume_session_replays_persisted_history_to_client(self, agent):