From 292d87afa2b1dbd1b845e9961da152a50b1befe4 Mon Sep 17 00:00:00 2001 From: ciregenz Date: Fri, 31 Jul 2026 15:58:49 -0700 Subject: [PATCH] [eric] browser: test the element-index leak fix and pin the renderer's row template --- backend/tests/test_browser_index_leak.py | 95 ++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 backend/tests/test_browser_index_leak.py diff --git a/backend/tests/test_browser_index_leak.py b/backend/tests/test_browser_index_leak.py new file mode 100644 index 00000000..a7e4d833 --- /dev/null +++ b/backend/tests/test_browser_index_leak.py @@ -0,0 +1,95 @@ +"""The browser subsystem's click-by-index rows must never reach a human. + +`[1]` is what BrowserListInteractives hands the +browser sub-agent so it can click by number. A user asked a normal agent to list a +page's interactive elements and got those rows back verbatim in chat. The rows are +produced in the renderer (frontend/src/shared/browserCommandHandler.ts) and ride into +the transcript on the sub-agent's summary, so both the laundering and the renderer's +template are pinned here. +""" + +import asyncio +import re +from pathlib import Path + +from backend.apps.agents.browser import browser_agent as BA +from backend.apps.agents.browser.browser_history import PAGE_STATE_MARKER +from backend.apps.agents.browser.humanize_element_rows import humanize_element_rows + +# Verbatim from the bug report: six rows the agent pasted into a normal chat, on one line. +LEAKED_REPLY = ( + '[1] [2]