feat(gateway): per-turn group_note on prompt.submit

Model-input-only room context (membership, who was just invited) rides the
same _prepend_note channel as reaction notes: never persisted, consumed on
read, so the transcript stays clean and the cached prefix survives. Without
it the host agent's invite turn predates its own room and the model
confidently explains the feature doesn't exist.
This commit is contained in:
Brooklyn Nicholson 2026-08-13 13:18:37 -05:00
parent ab4d79c75c
commit 7583a41d9b
2 changed files with 12 additions and 0 deletions

View File

@ -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

View File

@ -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))