diff --git a/tui_gateway/methods_prompt.py b/tui_gateway/methods_prompt.py index d0efe89f9f057..07d4a43f0733d 100644 --- a/tui_gateway/methods_prompt.py +++ b/tui_gateway/methods_prompt.py @@ -118,6 +118,13 @@ def _(rid, params: dict) -> dict: # in turn: a stale "hud" would tell the model the user is still floating # over another app when they are back in Hermes. session["client_surface"] = "hud" if params.get("surface") == "hud" else "" + # Per-turn group-chat note (desktop rooms): context the model needs about + # the room THIS turn — who was invited, who the members are. Same channel + # as reaction notes: model input only, never persisted, so the transcript + # stays clean and the cached prefix survives. Rewritten (not setdefault) + # every submit so a stale note can't outlive the room state it described. + _group_note = params.get("group_note") + session["group_note"] = _group_note.strip() if isinstance(_group_note, str) else "" if truncate_user_ordinal is not None and isinstance(text, str): # A rewind/regenerate replays a turn from what the transcript shows. A # skill turn shows its invocation, so re-expand it here — otherwise diff --git a/tui_gateway/server.py b/tui_gateway/server.py index 14d6dbc2f2fad..807ac220eb1d4 100644 --- a/tui_gateway/server.py +++ b/tui_gateway/server.py @@ -9961,6 +9961,11 @@ def _run_prompt_submit( # Reactions the user added since the last turn. run_message = _prepend_note(run_message, _pending_reaction_notes(session)) + # Desktop group-chat room note (who's in the room / who was just + # invited) — per-turn state, so it cannot live in the (byte-stable) + # system prompt. Consumed on read: one submit, one note. + run_message = _prepend_note(run_message, str(session.pop("group_note", "") or "")) + # Which window the message was typed into. HUD mode is per-turn # state, so it cannot live in the (byte-stable) system prompt. run_message = _prepend_note(run_message, _hud_surface_note(session))