fix: add origin_message_id support for spawn and message deduplication
This commit is contained in:
@@ -25,6 +25,7 @@ class SpawnTool(Tool):
|
||||
self._origin_channel: ContextVar[str] = ContextVar("spawn_origin_channel", default="cli")
|
||||
self._origin_chat_id: ContextVar[str] = ContextVar("spawn_origin_chat_id", default="direct")
|
||||
self._session_key: ContextVar[str] = ContextVar("spawn_session_key", default="cli:direct")
|
||||
self._origin_message_id: str | None = None
|
||||
|
||||
def set_context(self, channel: str, chat_id: str, effective_key: str | None = None) -> None:
|
||||
"""Set the origin context for subagent announcements."""
|
||||
@@ -32,6 +33,10 @@ class SpawnTool(Tool):
|
||||
self._origin_chat_id.set(chat_id)
|
||||
self._session_key.set(effective_key or f"{channel}:{chat_id}")
|
||||
|
||||
def set_origin_message_id(self, message_id: str | None) -> None:
|
||||
"""Set the source message id for downstream deduplication."""
|
||||
self._origin_message_id = message_id
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "spawn"
|
||||
@@ -54,4 +59,5 @@ class SpawnTool(Tool):
|
||||
origin_channel=self._origin_channel.get(),
|
||||
origin_chat_id=self._origin_chat_id.get(),
|
||||
session_key=self._session_key.get(),
|
||||
origin_message_id=self._origin_message_id,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user