The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat: hold a held session's reply until transform_llm_output rewrites it
Teknium83b412803265
diff --git a/agent/chat_completion_helpers.py b/agent/chat_completion_helpers.pyindex 4e2327d6926..5ef48920097 100644--- a/agent/chat_completion_helpers.py+++ b/agent/chat_completion_helpers.py@@ -2844,7 +2844,7 @@ class _StreamingCall(StreamingWaitMonitor):reasoning tags inside it must still reach the display: route throughthe delta callback for tag extraction (the CLI drops non-reasoning textonce the stream box is closed)."""- if self.agent.stream_delta_callback:+ if self.agent.stream_delta_callback and not getattr(self.agent, "_hold_stream", False):self._quiet(lambda: (self.agent.stream_delta_callback(text), self.agent._record_streamed_assistant_text(text)))def _new_diag(self) -> dict:diff --git a/agent/conversation_loop.py b/agent/conversation_loop.pyindex a16c43669c6..72ea3119e64 100644--- a/agent/conversation_loop.py+++ b/agent/conversation_loop.py@@ -36,6 +36,7 @@ from agent.surface_switch import ()from agent.turn_context import PreflightCompressionTimedOut, build_turn_contextfrom hermes_cli.observability.shared_metrics_efficiency import record_cache_break, record_prompt_rebuild+from hermes_cli.plugins_dispatch import stream_heldfrom agent.turn_retry_state import TurnRetryStatefrom agent.turn_scripted_prelude import Prelude, play_prelude# Phase helpers of the turn loop, bound at import so a source-tree swap cannot load a@@ -1701,6 +1702,8 @@ def _run_conversation_turn(# pool refresh tallies cap same-entry refreshes on a persistent 401 (#26080); usage# for on_turn_complete() stays None on turns that never reach a response.agent._delivered_interim_texts = set()+ # A loaded ``hold_stream`` transform in this profile: the user sees only its rewritten final.+ agent._hold_stream = stream_held()agent._incremental_persistence_failed = Falseagent._last_persistence_error_cause = Noneagent._compression_adoption_failed = Falsediff --git a/agent/stream_delivery.py b/agent/stream_delivery.pyindex 7580230b30b..bf6f1016489 100644--- a/agent/stream_delivery.py+++ b/agent/stream_delivery.py@@ -31,7 +31,10 @@ class StreamDeliveryMixin:return Falsedef _deliver_to_stream_callbacks(self, text: str) -> bool:- """Send ``text`` to the display + TTS delta callbacks; True if at least one accepted it."""+ """Send ``text`` to the display + TTS delta callbacks; True if at least one accepted it.+ Nothing leaves while a ``hold_stream`` plugin holds this turn's reply (``_hold_stream``)."""+ if getattr(self, "_hold_stream", False):+ return Falseresults = [self._call_quietly(cb, text) for cb in (self.stream_delta_callback, self._stream_callback)]return any(results)@@ -174,8 +177,9 @@ class StreamDeliveryMixin:self._delivered_interim_texts.add(normalized)def _deliver_interim(self, visible: str, *, already_streamed: bool, record: list[str]) -> None:- """Hand ``visible`` to ``interim_assistant_callback`` and mark ``record`` delivered; swallows callback errors."""- cb = getattr(self, "interim_assistant_callback", None)+ """Hand ``visible`` to ``interim_assistant_callback`` and mark ``record`` delivered; swallows callback errors.+ Commentary is model text ``transform_llm_output`` never sees, so a held turn drops it."""+ cb = None if getattr(self, "_hold_stream", False) else getattr(self, "interim_assistant_callback", None)if cb is None:returntry:diff --git a/gateway/run_turn_runner.py b/gateway/run_turn_runner.pyindex 255d7534d67..cac075308ab 100644--- a/gateway/run_turn_runner.py+++ b/gateway/run_turn_runner.py@@ -28,6 +28,7 @@ from gateway.platforms.base import BasePlatformAdapterfrom gateway.platforms.base_exec_approval import ea_default_reason_textfrom gateway.turn_context import TurnContextfrom hermes_cli.config import cfg_get+from hermes_cli.plugins_dispatch import stream_heldfrom utils import is_truthy_valueif TYPE_CHECKING: # string annotations only; never imported at runtime (cycle)@@ -230,12 +231,16 @@ class TurnRunner(GatewayTurnProgressMixin, GatewaySessionAgentMixin):scfg = StreamingConfig()# display.platforms.<plat>.streaming may disable streaming per platform; None = follow global.plat_streaming = ctx.resolve_display_setting(ctx.user_config, platform_key, "streaming")- want_stream_deltas = not ctx.scheduled_heartbeat and scfg.enabled_for(plat_streaming)+ # A loaded ``hold_stream`` transform rewrites this session's reply before the user may see it:+ # no drafts, edits, native stream or commentary bubbles; the rewrite goes out as one plain+ # final while the typing indicator runs (the agent also withholds every delta).+ held = stream_held()+ want_stream_deltas = not held and not ctx.scheduled_heartbeat and scfg.enabled_for(plat_streaming)# A finite (`-z`, `chat -q`) viewer prints only the terminal reply, like the classic quiet# CLI that never wired commentary. Commentary it cannot see must not be recorded as a# delivery, or a final that arrives as commentary (codex app-server) suppresses the reply.want_interim_messages = (bool(ctx.interim_assistant_messages_enabled) and not ctx.scheduled_heartbeat- and not _finite_viewer_turn())+ and not held and not _finite_viewer_turn())if want_stream_deltas or want_interim_messages:try:from gateway.stream_consumer import GatewayStreamConsumerdiff --git a/tests/agent/test_hold_stream_agent.py b/tests/agent/test_hold_stream_agent.pynew file mode 100644index 00000000000..04c46fef540--- /dev/null+++ b/tests/agent/test_hold_stream_agent.py@@ -0,0 +1,60 @@+"""A ``hold_stream`` plugin holds the agent's user-facing text until its rewrite lands.++Every surface (messaging, TUI/Desktop/CLI viewers, API server, ACP, managed workers) receives the+reply through the agent's display callbacks, so the agent is the one place the hold must apply: no+text delta and no interim commentary leaves it while a loaded ``transform_llm_output`` plugin in+the session's profile declared ``hold_stream=True``. The final reply is the rewrite. A plugin that+did not declare it keeps the normal stream (control).+"""++import json+import os+from pathlib import Path++import pytest++from tests.fakes.fake_llm_provider import FakeLLMServer, Raw, Text, _chunk+from tests.fakes.redactor_plugin import COMMENTARY, RAW, REWRITE, raw_leaks, redactor_home, redactor_turn+++def _text_after_tool_call():+ """A tool-call response whose text arrives after the call began streaming: the agent routes+ that text through its suppressed-content path rather than the ordinary delta path."""+ call = {"index": 0, "id": "call_late_text", "type": "function",+ "function": {"name": "todo_list", "arguments": "{}"}}+ finish = {**_chunk({}, "tool_calls"), "usage": {"prompt_tokens": 100, "completion_tokens": 10, "total_tokens": 110}}+ frames = [_chunk({"role": "assistant", "content": ""}), _chunk({"tool_calls": [call]}),+ _chunk({"content": COMMENTARY}), finish]+ body = "".join(f"data: {json.dumps(frame)}\n\n" for frame in frames) + "data: [DONE]\n\n"+ return [Raw(body=body, content_type="text/event-stream"), Text(RAW, chunk_chars=6)]+++TURNS = {"commentary_then_tool": redactor_turn, "text_after_tool_call": _text_after_tool_call}++[email protected]("turn", TURNS)[email protected]("hold", [True, False], ids=["hold_stream", "plain_transform"])+def test_held_turns_show_only_the_rewritten_final(hold, turn):+ from hermes_cli import plugins+ from run_agent import AIAgent++ home = Path(os.environ["HERMES_HOME"])+ with FakeLLMServer(TURNS[turn]()) as srv:+ redactor_home(home, srv.base_url, hold=hold)+ plugins._reset_plugin_managers_for_tests()+ try:+ agent = AIAgent(base_url=srv.base_url, api_key="sk-fake-e2e", provider="custom", model="fake-model",+ quiet_mode=True, skip_context_files=True, skip_memory=True, enabled_toolsets=["todo"])+ shown: list = []+ agent.stream_delta_callback = shown.append+ agent.interim_assistant_callback = lambda text, **_: shown.append(text)+ result = agent.run_conversation("show me the config")+ finally:+ plugins._reset_plugin_managers_for_tests()++ assert result["final_response"] == REWRITE+ assert len(srv.main_requests()) == 2 # the tool round ran, then the answer+ if hold:+ assert [text for text in shown if text] == []+ else: # the plain transform rewrites the final only; the stream and commentary showed raw text+ assert COMMENTARY in shown and raw_leaks(shown)diff --git a/tests/fakes/redactor_plugin.py b/tests/fakes/redactor_plugin.pynew file mode 100644index 00000000000..6d67a10e93a--- /dev/null+++ b/tests/fakes/redactor_plugin.py@@ -0,0 +1,56 @@+"""A redaction plugin for ``transform_llm_output`` stream-hold tests.++``redactor_home(home, base_url, hold=...)`` writes a loopback-routed ``HERMES_HOME`` with a user+plugin that rewrites every ``SECRET-<digits>`` in the final reply to ``[REDACTED]``, registered+with ``hold_stream=True`` when ``hold`` is set. ``redactor_turn()`` is the scripted model turn: a+tool call carrying commentary (model text between tool calls) and then the streamed answer.+"""++from __future__ import annotations++from pathlib import Path++from tests.fakes.fake_llm_provider import Text, ToolCall, write_hermes_home++RAW = "Here is the config. Your api key is SECRET-123 and the backup key is SECRET-456. Keep them safe."+REWRITE = "Here is the config. Your api key is [REDACTED] and the backup key is [REDACTED]. Keep them safe."+COMMENTARY = "Checking where SECRET-777 is stored first."++_PLUGIN = """import re+++def _redact(response_text, **_):+ return re.sub(r"SECRET-\\d+", "[REDACTED]", response_text)+++def register(ctx):+ ctx.register_hook("transform_llm_output", _redact{hold})+"""++_CONFIG = (+ "updates:\n check: false\n"+ "models_dev:\n url: http://127.0.0.1:9/api.json\n"+ # The background memory/skill review would fork a second agent against the same stub.+ "skills:\n creation_nudge_interval: 0\nmemory:\n nudge_interval: 0\n"+ # ``todo_list`` sits in the request's tools instead of behind tool_search.+ 'tools:\n tool_search:\n enabled: "off"\n'+ "platform_toolsets:\n api_server: [todo]\n"+ "plugins:\n enabled:\n - redactor\n"+)+++def redactor_home(home: Path, base_url: str, *, hold: bool) -> Path:+ plugin = home / "plugins" / "redactor"+ plugin.mkdir(parents=True, exist_ok=True)+ (plugin / "plugin.yaml").write_text("name: redactor\nversion: 0.1.0\n", encoding="utf-8")+ (plugin / "__init__.py").write_text(_PLUGIN.format(hold=", hold_stream=True" if hold else ""), encoding="utf-8")+ return write_hermes_home(home, base_url, extra_config=_CONFIG)+++def redactor_turn(*, delay_per_chunk: float = 0.0) -> list:+ return [ToolCall("todo_list", {}, text=COMMENTARY), Text(RAW, chunk_chars=6, delay_per_chunk=delay_per_chunk)]+++def raw_leaks(texts) -> list[str]:+ """Every user-visible text that carried an unredacted secret."""+ return [t for t in texts if isinstance(t, str) and "SECRET-" in t]diff --git a/tests/gateway/test_hold_stream_api_server.py b/tests/gateway/test_hold_stream_api_server.pynew file mode 100644index 00000000000..8457542e7b4--- /dev/null+++ b/tests/gateway/test_hold_stream_api_server.py@@ -0,0 +1,56 @@+"""API server: a ``hold_stream`` redactor's session streams no raw text to OpenAI-compatible clients.++Real ``APIServerAdapter`` routes (aiohttp test server) building a real ``AIAgent`` against a+loopback model. With the redactor declared ``hold_stream=True``, a streaming+``/v1/chat/completions`` and ``/v1/responses`` request receive the rewritten final as their only+text: the SSE stream stays open (role chunk / ``response.created``) while the reply is held,+then carries the rewrite. (A plain transform streams the raw deltas first and appends the+rewrite: ``test_api_server_transform_llm_output.py``.)+"""++import json+import os+from pathlib import Path++import pytest+from aiohttp import web+from aiohttp.test_utils import TestClient, TestServer++from gateway.config import PlatformConfig+from gateway.platforms.api_server import APIServerAdapter+from tests.fakes.fake_llm_provider import FakeLLMServer+from tests.fakes.redactor_plugin import REWRITE, raw_leaks, redactor_home, redactor_turn+++def _sse(body):+ return [json.loads(line[6:]) for line in body.splitlines() if line.startswith("data: ") and line != "data: [DONE]"]+++async def test_held_api_streams_carry_only_the_rewrite():+ from hermes_cli import plugins++ home = Path(os.environ["HERMES_HOME"])+ with FakeLLMServer(redactor_turn() + redactor_turn()) as srv:+ redactor_home(home, srv.base_url, hold=True)+ plugins._reset_plugin_managers_for_tests()+ adapter = APIServerAdapter(PlatformConfig(enabled=True, extra={}))+ app = web.Application()+ app.router.add_post("/v1/chat/completions", adapter._handle_chat_completions)+ app.router.add_post("/v1/responses", adapter._handle_responses)+ try:+ async with TestClient(TestServer(app)) as client:+ chat = await client.post("/v1/chat/completions", json={+ "model": "fake-model", "stream": True, "messages": [{"role": "user", "content": "config?"}]})+ chunks = [c["choices"][0]["delta"].get("content") for c in _sse(await chat.text()) if c.get("choices")]+ responses = await client.post("/v1/responses", json={+ "model": "fake-model", "stream": True, "store": False, "input": "config?"})+ events = _sse(await responses.text())+ finally:+ plugins._reset_plugin_managers_for_tests()++ assert len(srv.main_requests()) == 4 # each request ran its commentary + tool round, then answered+ assert raw_leaks(chunks) == [] and "".join(c for c in chunks if c) == REWRITE+ deltas = [e["delta"] for e in events if e.get("type") == "response.output_text.delta"]+ assert raw_leaks(deltas) == [] and "".join(deltas) == REWRITE+ assert [e["text"] for e in events if e.get("type") == "response.output_text.done"] == [REWRITE]diff --git a/tests/gateway/test_hold_stream_delivery.py b/tests/gateway/test_hold_stream_delivery.pynew file mode 100644index 00000000000..391e434b054--- /dev/null+++ b/tests/gateway/test_hold_stream_delivery.py@@ -0,0 +1,154 @@+"""A ``hold_stream`` plugin's session shows the user only the rewritten final, on every chat shape.++Real ``GatewayRunner._run_agent`` + real ``AIAgent`` against a loopback model streaming a reply+that a ``transform_llm_output`` redactor rewrites. The adapters are recording transports (and the+real ``RelayAdapter`` over the stub connector for Slack's stream-is-the-message lane); the base+adapter's own ``_process_message_background`` runs the typing loop and the final send. With+``hold_stream=True`` no draft, edit, native stream frame, split head or commentary bubble ever+carries the raw text, the typing indicator runs while the reply is held, and the final goes out+once, rewritten. The same plugin without the declaration keeps today's stream (control).+"""++import os+from pathlib import Path++import pytest++from gateway.config import Platform, PlatformConfig, StreamingConfig+from gateway.platforms.base import BasePlatformAdapter, SendResult+from gateway.platforms.event import MessageEvent, MessageType+from gateway.session import SessionSource+from tests.fakes.fake_llm_provider import FakeLLMServer+from tests.fakes.redactor_plugin import REWRITE, raw_leaks, redactor_home, redactor_turn+from tests.gateway.test_run_progress_topics import _make_runner+++class _Chat(BasePlatformAdapter):+ """Recording transport: every send/edit/frame lands in ``log`` as ``(kind, text)``."""++ def __init__(self, *, editable=True, limit=4096):+ super().__init__(PlatformConfig(enabled=True, token="***"), Platform.TELEGRAM)+ self.SUPPORTS_MESSAGE_EDITING, self.MAX_MESSAGE_LENGTH = editable, limit+ self.log, self.typing, self._ids = [], 0, 0++ async def connect(self, *, is_reconnect=False):+ return True++ async def disconnect(self):+ return None++ async def send(self, chat_id, content, reply_to=None, metadata=None):+ for chunk in self.truncate_message(content, self.MAX_MESSAGE_LENGTH): # what real adapters do+ self._ids += 1+ self.log.append(("send", chunk))+ return SendResult(success=True, message_id=f"m{self._ids}" if self.SUPPORTS_MESSAGE_EDITING else None)++ async def edit_message(self, chat_id, message_id, content, **_):+ if not self.SUPPORTS_MESSAGE_EDITING or len(content) > self.MAX_MESSAGE_LENGTH:+ return SendResult(success=False, error="cannot edit")+ self.log.append(("edit", content))+ return SendResult(success=True, message_id=message_id)++ async def send_typing(self, chat_id, metadata=None):+ self.typing += 1++ async def get_chat_info(self, chat_id):+ return {"id": chat_id}+++class _NativeStreamChat(_Chat):+ """WeCom's shape: no edits, a native cumulative stream that opens with an empty seed frame."""++ SUPPORTS_NATIVE_STREAMING = True++ def supports_native_streaming(self, chat_type=None, metadata=None):+ return True++ async def send_stream_frame(self, text, *, finalize=False, chat_id=None, reply_to=None, turn_id=None):+ self.log.append(("frame", text))+ return True+++def _relay_slack():+ """Slack fronted by the relay: native ``chat.*Stream`` drafts ARE the message."""+ from gateway.relay.adapter import RelayAdapter+ from tests.gateway.relay.stub_connector import StubConnector+ from tests.gateway.relay.test_relay_slack_dm_streaming import _slack_desc++ desc = _slack_desc(supports_draft_streaming=True)+ adapter = RelayAdapter(PlatformConfig(), desc, transport=StubConnector(desc))+ assert adapter.draft_stream_is_message is True+ return adapter+++def _frames(chat):+ if hasattr(chat, "log"):+ return chat.log+ return [(frame["op"], frame.get("content") or frame.get("text") or "") for frame in chat._transport.sent]+++CHATS = {+ "edits_in_place": lambda: _Chat(editable=True),+ "cannot_edit": lambda: _Chat(editable=False),+ "splits_long_replies": lambda: _Chat(editable=True, limit=60),+ "native_stream": lambda: _NativeStreamChat(editable=False),+ "relay_stream_is_the_message": _relay_slack,+}+++async def _deliver(chat, *, hold, monkeypatch):+ import gateway.run as gateway_run+ from hermes_cli import plugins++ home = Path(os.environ["HERMES_HOME"])+ platform = Platform.SLACK if chat.platform == Platform.RELAY else Platform.TELEGRAM+ source = SessionSource(platform=platform, chat_id="c1", chat_type="dm", user_id="u1")+ event = MessageEvent(text="show me the config", source=source, message_type=MessageType.TEXT)+ session_key = f"agent:main:{platform.value}:dm:c1"+ with FakeLLMServer(redactor_turn(delay_per_chunk=0.03)) as srv:+ redactor_home(home, srv.base_url, hold=hold)+ plugins._reset_plugin_managers_for_tests()+ monkeypatch.setattr(gateway_run, "_hermes_home", home)+ monkeypatch.setattr(gateway_run, "_resolve_runtime_agent_kwargs", lambda: {+ "api_key": "sk-fake-e2e", "base_url": srv.base_url, "provider": "custom", "api_mode": "chat_completions"})+ runner = _make_runner(chat)+ runner.adapters[platform] = chat+ runner.config.streaming = StreamingConfig(enabled=True, transport="auto", edit_interval=0.01,+ buffer_threshold=1, cursor="")+ if hasattr(chat, "_capture_scope"):+ chat._capture_scope(event)++ async def handler(event):+ result = await runner._run_agent(message=event.text, context_prompt="", history=[], source=source,+ session_id="s1", session_key=session_key)+ assert result["final_response"] == REWRITE+ return None if result.get("already_sent") else result["final_response"]++ chat.set_message_handler(handler)+ try:+ await chat._process_message_background(event, session_key)+ finally:+ plugins._reset_plugin_managers_for_tests()+ return _frames(chat)++[email protected]("shape", CHATS)+async def test_a_held_reply_reaches_the_chat_only_as_the_rewrite(shape, monkeypatch):+ chat = CHATS[shape]()+ frames = await _deliver(chat, hold=True, monkeypatch=monkeypatch)++ assert raw_leaks(text for _, text in frames) == []+ # Only plain sends of the final: nothing streamed, so nothing to edit, seal or close.+ assert {kind for kind, _ in frames} - {"typing"} == {"send"}, frames+ assert " ".join(text for _, text in frames).count("[REDACTED]") == 2+ # The typing indicator is what the user sees while the reply is held.+ assert getattr(chat, "typing", 0) or ("typing", "") in frames++[email protected]("shape", ["edits_in_place", "relay_stream_is_the_message"])+async def test_a_transform_that_did_not_ask_keeps_streaming(shape, monkeypatch):+ frames = await _deliver(CHATS[shape](), hold=False, monkeypatch=monkeypatch)++ assert raw_leaks(text for _, text in frames), frames # the raw reply streamed, as beforediff --git a/tests/gateway/test_hold_stream_local_viewer.py b/tests/gateway/test_hold_stream_local_viewer.pynew file mode 100644index 00000000000..e3519268f82--- /dev/null+++ b/tests/gateway/test_hold_stream_local_viewer.py@@ -0,0 +1,79 @@+"""TUI, Desktop and the classic CLI (local viewers of the canonical gateway) show a held reply only+as its rewrite.++Real ``GatewayRunner._run_agent`` on a ``LOCAL`` source with the ``LocalSessionAdapter`` and a+recording session authority (the viewers' event stream), a real ``AIAgent`` and a loopback model.+With a ``hold_stream`` redactor loaded, no ``message.delta`` / ``message.interim`` frame carries+text, and the turn's ``message.complete`` carries the rewritten final (the handler reply is not+swallowed as "already streamed"). A plain transform keeps streaming the raw reply (control).+"""++import os+from pathlib import Path+from unittest.mock import MagicMock++import pytest++from gateway.config import Platform, StreamingConfig+from gateway.session import SessionSource+from gateway.session_local import LocalSessionAdapter+from gateway.session_results import execution_result+from gateway.session_settlement_recovery import completion_payload+from tests.fakes.fake_llm_provider import FakeLLMServer+from tests.fakes.redactor_plugin import REWRITE, raw_leaks, redactor_home, redactor_turn+from tests.gateway.test_run_progress_topics import _make_runner+++async def _local_turn(*, hold, monkeypatch):+ import gateway.run as gateway_run+ from hermes_cli import plugins++ home = Path(os.environ["HERMES_HOME"])+ authority = MagicMock()+ authority.sessions = {"sid": MagicMock()}+ authority.db.get_session.return_value = {"runtime_generation": 1}+ authority.publish_execution.return_value = True # a viewer is attached and takes each frame+ source = SessionSource(platform=Platform.LOCAL, chat_id="sid", user_id="u", chat_type="dm")+ with FakeLLMServer(redactor_turn(delay_per_chunk=0.01)) as srv:+ redactor_home(home, srv.base_url, hold=hold)+ plugins._reset_plugin_managers_for_tests()+ monkeypatch.setattr(gateway_run, "_hermes_home", home)+ monkeypatch.setattr(gateway_run, "_resolve_runtime_agent_kwargs", lambda: {+ "api_key": "sk-fake-e2e", "base_url": srv.base_url, "provider": "custom", "api_mode": "chat_completions"})+ local = LocalSessionAdapter(authority)+ runner = _make_runner(local)+ runner.session_authority = authority+ runner.config.streaming = StreamingConfig(enabled=True, edit_interval=0.01, buffer_threshold=1, cursor="")+ captured = {}+ token = execution_result.set(captured)+ try:+ result = await runner._run_agent(message="show me the config", context_prompt="", history=[],+ source=source, session_id="sid", session_key="agent:main:local:sid")+ finally:+ execution_result.reset(token)+ plugins._reset_plugin_managers_for_tests()+ reply = None if result.get("already_sent") else result["final_response"]+ complete = completion_payload({"admission_id": "a1", "request_id": "r1"}, {"outcome": "completed"},+ reply, captured)+ frames = [(c.args[2], c.args[3]) for c in authority.publish_execution.call_args_list]+ return frames, complete+++def _texts(frames, *kinds):+ return [payload.get("text") for kind, payload in frames if kind in kinds and isinstance(payload, dict)]+++async def test_a_held_local_turn_completes_with_only_the_rewrite(monkeypatch):+ frames, complete = await _local_turn(hold=True, monkeypatch=monkeypatch)++ assert [t for t in _texts(frames, "message.delta", "message.interim") if t] == []+ assert raw_leaks(str(payload) for _, payload in frames) == []+ assert complete["text"] == REWRITE+++async def test_a_plain_transform_still_streams_to_local_viewers(monkeypatch):+ frames, _ = await _local_turn(hold=False, monkeypatch=monkeypatch)++ assert raw_leaks(_texts(frames, "message.delta"))