@inline-chat/hermes-agent-adapter 1.0.0-alpha.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -270,6 +270,7 @@ INLINE_TOOL_SCHEMA = {
270
270
  + "\n\n"
271
271
  "When chat_id is omitted, the tool uses the current Inline reply thread if present, otherwise the current chat. "
272
272
  "Return normal assistant replies as text. Use send_message only for a button card or a different destination. "
273
+ "To hand work to another bot, mention it in your normal reply; its answer comes back to you as a turn that doesn't need a response, and asking it again takes a new mention. "
273
274
  "Agent-owned button presses return as ordinary turns, and the normal response replaces the source card while clearing omitted buttons. "
274
275
  "Use create_thread on the current triggering message when someone asks to continue in a thread; your answer then goes into it, so don't also post it in the chat, and it starts with a short summary of the conversation so far. "
275
276
  "Use set_reply_threads when someone asks you to always or never answer in threads here. "
@@ -621,11 +622,20 @@ def _set_reply_threads(args: Dict[str, Any]) -> Dict[str, Any]:
621
622
  turn = _current_turn()
622
623
  if not turn.get("senderId"):
623
624
  raise InlineToolError("Only the person who asked can change reply threads, and this turn has no sender", "forbidden")
625
+ parent_chat_id = turn.get("parentChatId") or ""
626
+ chat_type = turn.get("chatType") or "group"
627
+ if parent_chat_id:
628
+ # The change lands on the parent, so the parent's own type decides who may make it:
629
+ # someone added to a thread under a DM is in a group here but not in that DM.
630
+ parent = _sidecar_call("/chat", {"target": {"chatId": parent_chat_id}}).get("result")
631
+ if not isinstance(parent, dict) or not parent:
632
+ raise InlineToolError("parent chat access could not be confirmed", "forbidden")
633
+ chat_type = owner.chat_type_from_info(parent)
624
634
  try:
625
635
  return owner.set_reply_threads_from_tool(
626
636
  chat_id=turn["chatId"],
627
- chat_type=turn.get("chatType") or "group",
628
- parent_chat_id=turn.get("parentChatId") or "",
637
+ chat_type=chat_type,
638
+ parent_chat_id=parent_chat_id,
629
639
  actor_id=turn["senderId"],
630
640
  actor_is_bot=bool(turn.get("senderIsBot")),
631
641
  mode=mode,