Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

fix: preserve browser batch boundaries and sibling receipts

Barack Sokulluad49bcb75f67
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 45897c8dd..fea917393 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ This changelog was generated from the repository Git history and release tags. V
- `browser_batch` runs predictable browser actions in order in one model round trip on Chrome and Firefox. Mid allows up to 6 actions and Full up to 10; Dev inherits its provider tier. Each action keeps its normal permission and verification checks, and failures or submits stop the remaining work for a fresh turn. A final page read can follow navigation. Ask and Compact keep their existing tool surface; an internal `browserBatchEnabled` switch disables batching.
### Fixed
+- Keep each retained browser batch result inside its original untrusted-content boundaries when trimming context. Rejected batches no longer overwrite a native sibling's execution receipt when its call ID resembles a generated batch child ID.
- Mastodon: deleting your own post no longer stops at Mastodon's "Delete post?" confirmation. WebBrain opened the post's "…" menu and chose Delete, and the confirmation that its own click opened was refused as "not inside one identifiable record". When the menu entry was clicked no model had read its caption yet, so WebBrain had not tied the confirmation to the post, and while the confirmation is open Mastodon makes the rest of the page inert, which WebBrain read as the post and your account being hidden. Mastodon's dangerous entries on your own post now count as its deletion by page structure, the post and your account behind the confirmation still count, and Mastodon's own confirm button is recognized in windows narrower than 1175 px, where Mastodon shows no composer beside the timeline. A confirmation that WebBrain's click did not open, another account's post, and anything inert without Mastodon's confirmation open still bind nothing. With Mastodon's confirmation turned off, the dangerous entry is checked as the deletion itself even before its caption is read.
- Ask mode: an answer being written no longer disappears and starts over when you use the page meanwhile. In a WhatsApp trace, typing a draft and clicking in the chat while the answer was written threw the answer away twice and wrote it again each time, and the answer that finally stayed, written after you stopped, was the shortest. Scrolling, selecting, clicking and typing on the page, and the page's changes from them, now leave the answer as it is: it is about the page as you asked about it, and the run ends without waiting for you to stop typing. Navigating the page to another address still starts the answer over.
- Posting on another site after a correction: after a Mastodon post, "ok now on X" no longer leaves WebBrain going back and forth between the two sites, typing the X post again each time. It counted X as the same platform as Mastodon, because it reads account names only on X and Bluesky, and asked to find the Mastodon post on X itself, which can never happen. The site a post was made on now names its platform when no account name was read, and a post on another site goes ahead once a page has been read since the correction, provided the task made no earlier post on that site. What the task attempted is saved with the conversation, and just before each action that may post or submit something, so this still holds when the task continues after WebBrain restarted, and a post already sent on X under the correction is not sent again by a later run of the task. When the task did post on that site before, or WebBrain has no full record of its earlier attempts, it stops once and says so, instead of searching for a post it cannot find. A search, a settings save or consent click on X, a click that sent nothing or a form the page rejected is not such a post; a click that Stop interrupted after it was sent counts. On the other hosts and clients of X and Bluesky, such as X Pro, whose Post buttons WebBrain does not recognize, anything sent that may have been a post counts as one, so a post from X Pro is not repeated on x.com; this includes a Post button whose caption no model read in time, which looked like a harmless button, while Enter in the post editor there edits the draft and is not a post. If that record cannot be saved just before a possible post on X or Bluesky, the post is not sent and WebBrain says why, as it already does when a run's recovery checkpoint cannot be saved. x.com and twitter.com are one platform.
diff --git a/docs/prompt-injection-defense.md b/docs/prompt-injection-defense.md
index e3946bda9..267ffa428 100644
--- a/docs/prompt-injection-defense.md
+++ b/docs/prompt-injection-defense.md
@@ -151,8 +151,11 @@ stripping of attacker-supplied boundary markup. Do not unwrap/re-wrap the
aggregate: that would erase the distinct boundaries. The aggregate digest must
use only app-owned action names, execution status and stop reason, never page
text; the generic unwrapper reads only the first block and cannot safely digest
-a multi-result aggregate. Persistence and cancellation must preserve the same
-folded representation without exposing internal sub-call IDs to providers.
+a multi-result aggregate. Context trimming must preserve complete nonce markers
+for every retained child, including the child whose content is cut; omit a child
+if its opening and closing markers cannot both fit. Persistence and cancellation
+must preserve the same folded representation without exposing internal sub-call
+IDs to providers.
### Don't weaken the boundary for "trusted sites"
The master switch (Settings → Permissions) disables **Layer 3 only** (the
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 3644de67a..55a1d6c61 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -36835,19 +36835,31 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
* removed or renamed, so _isUntrustedTool() no longer recognizes it either.
* That combination would launder attacker-controlled page text into the
* trusted trim summary. Re-appending the matching close tag keeps the
- * wrapper detectable regardless of skill registry state.
+ * wrapper detectable regardless of skill registry state. Batch results have
+ * app-owned headers and several boxes: preserve earlier boxes verbatim and
+ * close only the box intersecting the cut, without merging nonce boundaries.
*/
_truncatePreservingUntrustedWrapper(content, limit) {
- const openMatch = content.match(/^<untrusted_page_content\b([^>]*)>\n?/);
- if (!openMatch) {
- return content.slice(0, limit) + '\n[...truncated to fit context]';
- }
- const closeMatch = content.match(/\n?<\/untrusted_page_content\b[^>]*>\s*$/);
- const closeTag = closeMatch ? closeMatch[0] : `\n</untrusted_page_content${openMatch[1]}>`;
- const openTag = openMatch[0];
- const innerLimit = Math.max(0, limit - openTag.length - closeTag.length);
- const inner = content.slice(openTag.length, openTag.length + innerLimit);
- return `${openTag}${inner}\n[...truncated to fit context]${closeTag}`;
+ const suffix = '\n[...truncated to fit context]';
+ const openings = /<untrusted_page_content\b([^>]*)>\n?/g;
+ const closings = /\n?<\/untrusted_page_content\b[^>]*>/g;
+ let openMatch;
+ while ((openMatch = openings.exec(content)) && openMatch.index < limit) {
+ const innerStart = openings.lastIndex;
+ closings.lastIndex = innerStart;
+ const closeMatch = closings.exec(content);
+ const closeTag = closeMatch ? closeMatch[0] : `\n</untrusted_page_content${openMatch[1]}>`;
+ const end = closeMatch ? closings.lastIndex : content.length;
+ if (closeMatch && end <= limit) {
+ openings.lastIndex = end;
+ continue;
+ }
+ // If both markers cannot fit, omit this box rather than emit a partial tag.
+ if (innerStart + closeTag.length > limit) return content.slice(0, openMatch.index) + suffix;
+ const innerEnd = Math.min(limit - closeTag.length, closeMatch?.index ?? content.length);
+ return content.slice(0, innerEnd) + suffix + closeTag;
+ }
+ return content.slice(0, limit) + suffix;
}
_truncateOversizedMessages(tabId, messages) {
diff --git a/src/chrome/src/agent/browser-batch.js b/src/chrome/src/agent/browser-batch.js
index 26064a46a..453597015 100644
--- a/src/chrome/src/agent/browser-batch.js
+++ b/src/chrome/src/agent/browser-batch.js
@@ -94,14 +94,21 @@ export function foldBrowserBatchMessages(messages, { repairPending = false } = {
let end = start + 1;
while (end < messages.length && messages[end].role !== 'assistant') end++;
const tail = messages.slice(start + 1, end);
+ const ids = new Set(assistant.tool_calls.map(call => call.id));
const replacements = new Map(), childIds = new Set();
for (const parent of assistant.tool_calls) {
- if (parent.function?.name !== 'browser_batch' || !parent.id) continue;
+ if (parent.function?.name !== 'browser_batch' || typeof parent.id !== 'string' || !parent.id.trim()
+ || parent.id.includes('::') || assistant.tool_calls.filter(call => call.id === parent.id).length !== 1) continue;
+ // A parent rejection or already folded answer is authoritative. Native
+ // sibling IDs may resemble generated IDs, but never belong to this batch.
+ if (tail.some(message => message.role === 'tool' && message.tool_call_id === parent.id)) continue;
const actions = argsFor(parent)?.actions;
if (!Array.isArray(actions) || !actions.length) continue;
- const children = actions.map((_, i) => tail.find(message => message.role === 'tool' && message.tool_call_id === `${parent.id}::${i}`));
- if (!children.some(Boolean) && (!repairPending || tail.some(message => message.role === 'tool' && message.tool_call_id === parent.id))) continue;
- actions.forEach((_, i) => childIds.add(`${parent.id}::${i}`));
+ const generatedIds = actions.map((_, i) => `${parent.id}::${i}`);
+ const children = generatedIds.map(id => !ids.has(id)
+ ? tail.find(message => message.role === 'tool' && message.tool_call_id === id) : undefined);
+ if (!children.some(Boolean) && !repairPending) continue;
+ for (const id of generatedIds) if (!ids.has(id)) childIds.add(id);
const states = children.map(browserBatchResultStatus);
const ran = states.filter(state => state.ran).length;
const reason = states.find(state => state.reason)?.reason || '';
@@ -130,7 +137,6 @@ export function foldBrowserBatchMessages(messages, { repairPending = false } = {
});
}
}
- const ids = new Set(assistant.tool_calls.map(call => call.id));
const answer = message => message.role === 'tool' && ids.has(message.tool_call_id);
output.push(assistant, ...folded.filter(answer), ...folded.filter(message => !answer(message)));
start = end;
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index e305c97cc..a94ba0cc6 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -34114,19 +34114,31 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
* removed or renamed, so _isUntrustedTool() no longer recognizes it either.
* That combination would launder attacker-controlled page text into the
* trusted trim summary. Re-appending the matching close tag keeps the
- * wrapper detectable regardless of skill registry state.
+ * wrapper detectable regardless of skill registry state. Batch results have
+ * app-owned headers and several boxes: preserve earlier boxes verbatim and
+ * close only the box intersecting the cut, without merging nonce boundaries.
*/
_truncatePreservingUntrustedWrapper(content, limit) {
- const openMatch = content.match(/^<untrusted_page_content\b([^>]*)>\n?/);
- if (!openMatch) {
- return content.slice(0, limit) + '\n[...truncated to fit context]';
- }
- const closeMatch = content.match(/\n?<\/untrusted_page_content\b[^>]*>\s*$/);
- const closeTag = closeMatch ? closeMatch[0] : `\n</untrusted_page_content${openMatch[1]}>`;
- const openTag = openMatch[0];
- const innerLimit = Math.max(0, limit - openTag.length - closeTag.length);
- const inner = content.slice(openTag.length, openTag.length + innerLimit);
- return `${openTag}${inner}\n[...truncated to fit context]${closeTag}`;
+ const suffix = '\n[...truncated to fit context]';
+ const openings = /<untrusted_page_content\b([^>]*)>\n?/g;
+ const closings = /\n?<\/untrusted_page_content\b[^>]*>/g;
+ let openMatch;
+ while ((openMatch = openings.exec(content)) && openMatch.index < limit) {
+ const innerStart = openings.lastIndex;
+ closings.lastIndex = innerStart;
+ const closeMatch = closings.exec(content);
+ const closeTag = closeMatch ? closeMatch[0] : `\n</untrusted_page_content${openMatch[1]}>`;
+ const end = closeMatch ? closings.lastIndex : content.length;
+ if (closeMatch && end <= limit) {
+ openings.lastIndex = end;
+ continue;
+ }
+ // If both markers cannot fit, omit this box rather than emit a partial tag.
+ if (innerStart + closeTag.length > limit) return content.slice(0, openMatch.index) + suffix;
+ const innerEnd = Math.min(limit - closeTag.length, closeMatch?.index ?? content.length);
+ return content.slice(0, innerEnd) + suffix + closeTag;
+ }
+ return content.slice(0, limit) + suffix;
}
_truncateOversizedMessages(tabId, messages) {
diff --git a/src/firefox/src/agent/browser-batch.js b/src/firefox/src/agent/browser-batch.js
index 26064a46a..453597015 100644
--- a/src/firefox/src/agent/browser-batch.js
+++ b/src/firefox/src/agent/browser-batch.js
@@ -94,14 +94,21 @@ export function foldBrowserBatchMessages(messages, { repairPending = false } = {
let end = start + 1;
while (end < messages.length && messages[end].role !== 'assistant') end++;
const tail = messages.slice(start + 1, end);
+ const ids = new Set(assistant.tool_calls.map(call => call.id));
const replacements = new Map(), childIds = new Set();
for (const parent of assistant.tool_calls) {
- if (parent.function?.name !== 'browser_batch' || !parent.id) continue;
+ if (parent.function?.name !== 'browser_batch' || typeof parent.id !== 'string' || !parent.id.trim()
+ || parent.id.includes('::') || assistant.tool_calls.filter(call => call.id === parent.id).length !== 1) continue;
+ // A parent rejection or already folded answer is authoritative. Native
+ // sibling IDs may resemble generated IDs, but never belong to this batch.
+ if (tail.some(message => message.role === 'tool' && message.tool_call_id === parent.id)) continue;
const actions = argsFor(parent)?.actions;
if (!Array.isArray(actions) || !actions.length) continue;
- const children = actions.map((_, i) => tail.find(message => message.role === 'tool' && message.tool_call_id === `${parent.id}::${i}`));
- if (!children.some(Boolean) && (!repairPending || tail.some(message => message.role === 'tool' && message.tool_call_id === parent.id))) continue;
- actions.forEach((_, i) => childIds.add(`${parent.id}::${i}`));
+ const generatedIds = actions.map((_, i) => `${parent.id}::${i}`);
+ const children = generatedIds.map(id => !ids.has(id)
+ ? tail.find(message => message.role === 'tool' && message.tool_call_id === id) : undefined);
+ if (!children.some(Boolean) && !repairPending) continue;
+ for (const id of generatedIds) if (!ids.has(id)) childIds.add(id);
const states = children.map(browserBatchResultStatus);
const ran = states.filter(state => state.ran).length;
const reason = states.find(state => state.reason)?.reason || '';
@@ -130,7 +137,6 @@ export function foldBrowserBatchMessages(messages, { repairPending = false } = {
});
}
}
- const ids = new Set(assistant.tool_calls.map(call => call.id));
const answer = message => message.role === 'tool' && ids.has(message.tool_call_id);
output.push(assistant, ...folded.filter(answer), ...folded.filter(message => !answer(message)));
start = end;
diff --git a/test/browser-batch-runtime.mjs b/test/browser-batch-runtime.mjs
index f7cce8b63..a82cf75c2 100644
--- a/test/browser-batch-runtime.mjs
+++ b/test/browser-batch-runtime.mjs
@@ -107,6 +107,24 @@ for (const build of ['chrome', 'firefox']) {
for (const message of wire.messages) for (const tool of message.tool_calls || []) assert.doesNotThrow(() => JSON.parse(tool.function.arguments));
});
+ test(`${build}: rejected batch collision preserves the executed native sibling through persistence and provider conversion`, async () => {
+ const h = setup([batch([field(1)]), call('batch::0', 'get_window_info', {})]);
+ await h.run();
+ assert.deepEqual(h.dispatched.map(item => item.name), ['get_window_info']);
+ const results = h.messages.filter(message => message.role === 'tool');
+ assert.deepEqual(results.map(message => message.tool_call_id), ['batch', 'batch::0']);
+ assert.equal(JSON.parse(results[0].content).errorCode, 'invalid_browser_batch');
+ assert.equal(JSON.parse(h.agent._unwrapUntrusted(results[1].content)).success, true);
+ assert.doesNotMatch(results[1].content, /not run|"skipped":true/);
+ const snapshot = h.agent._conversationStorageEntry(1);
+ assert.deepEqual(snapshot.messages.filter(message => message.role === 'tool'), results);
+ const wire = new OpenAICompatibleProvider({ apiKey: 'test', model: 'test' })._buildChatCompletionsBody(snapshot.messages);
+ assert.deepEqual(wire.messages.filter(message => message.role === 'tool').map(message => message.tool_call_id), ['batch', 'batch::0']);
+ const anthropic = new AnthropicProvider({ apiKey: 'test', model: 'claude-test' })._convertMessages(snapshot.messages);
+ const toolResults = anthropic.messages.flatMap(message => Array.isArray(message.content) ? message.content : []).filter(block => block.type === 'tool_result');
+ assert.deepEqual(toolResults.map(block => block.tool_use_id), ['batch', 'batch::0']);
+ });
+
test(`${build}: permission denial stops the batch before any dispatch`, async () => {
const h = setup([batch([field(1), field(2)]), call('sibling', 'get_window_info', {})]);
h.agent.permissions.check = () => ({ allowed: false, needsPrompt: false });
@@ -263,6 +281,54 @@ for (const build of ['chrome', 'firefox']) {
h.agent._releaseRunEntry(1);
});
+ for (const trim of ['normal', 'emergency']) test(`${build}: ${trim} context trimming preserves batch child boundaries and metadata`, async () => {
+ const h = setup([batch(Array.from({ length: 3 }, () => ({ name: 'read_page', input: {} })))]);
+ h.messages.unshift({ role: 'system', content: 'System instructions.' });
+ let reads = 0;
+ h.agent.executeTool = async () => ({ success: true, text: ++reads === 1 ? 'First page.' : 'PRIVATE-PAGE '.repeat(1000) });
+ await h.run();
+ const original = h.messages.find(message => message.tool_call_id === 'batch').content;
+ const openings = content => [...content.matchAll(/<untrusted_page_content id="([^"]+)"[^>]*>/g)].map(match => match[1]);
+ assert.equal(openings(original).length, 3);
+ const digest = h.agent._digestToolResult('browser_batch', original);
+ if (trim === 'normal') assert.equal(h.agent._truncateOversizedMessages(1, h.messages), true);
+ else h.agent._emergencyTrim(h.messages);
+ const result = h.messages.find(message => message.tool_call_id === 'batch').content;
+ const retainedIds = openings(result);
+ assert.equal(retainedIds.length, 2, 'retain the first child and the truncated second child');
+ assert.deepEqual(retainedIds, openings(original).slice(0, 2), 'keep original nonces');
+ assert.deepEqual([...result.matchAll(/<\/untrusted_page_content id="([^"]+)">/g)].map(match => match[1]), retainedIds);
+ assert.ok(result.length <= 2000 + '\n[...truncated to fit context]'.length);
+ assert.equal(h.agent._hasUntrustedWrapper(result), true);
+ assert.equal(h.agent._digestToolResult('browser_batch', result), digest);
+ assertPaired(h.messages);
+ });
+
+ test(`${build}: every batch truncation cutoff keeps whole matching markers`, () => {
+ const { agent } = setup([]);
+ const blocks = [1, 2, 3].map(index => agent._wrapUntrusted('read_page', `PRIVATE-PAGE-${index} `.repeat(5)));
+ const content = `[browser_batch] header\n${blocks.join('\nnext child\n')}\ntrusted trailing note`;
+ const originalIds = [...content.matchAll(/<untrusted_page_content id="([^"]+)">/g)].map(match => match[1]);
+ for (let limit = 1; limit < content.length; limit++) {
+ const result = agent._truncatePreservingUntrustedWrapper(content, limit);
+ const retainedIds = [...result.matchAll(/<untrusted_page_content id="([^"]+)">/g)].map(match => match[1]);
+ assert.deepEqual(retainedIds, originalIds.slice(0, retainedIds.length), `original nonce order at ${limit}`);
+ const outside = result.replace(/<untrusted_page_content id="([^"]+)">[\s\S]*?<\/untrusted_page_content id="\1">/g, '');
+ assert.doesNotMatch(outside, /[<>]|PRIVATE/, `partial marker or unwrapped page bytes at ${limit}`);
+ assert.ok(result.length <= limit + '\n[...truncated to fit context]'.length, `bounded at ${limit}`);
+ }
+ });
+
+ test(`${build}: truncation still closes a legacy single wrapper and leaves plain text behavior intact`, () => {
+ const { agent } = setup([]);
+ const source = agent._wrapUntrusted('read_page', 'PRIVATE-PAGE '.repeat(1000));
+ const result = agent._truncatePreservingUntrustedWrapper(source, 2000);
+ assert.ok(result.startsWith(source.slice(0, source.indexOf('\n'))));
+ assert.ok(result.endsWith(source.slice(source.lastIndexOf('\n'))));
+ assert.equal(agent._hasUntrustedWrapper(result), true);
+ assert.equal(agent._truncatePreservingUntrustedWrapper('ordinary text', 5), 'ordin\n[...truncated to fit context]');
+ });
+
test(`${build}: one auto screenshot after several mutations, paired before supplemental image`, async () => {
const h = setup([batch([field(1), field(2)])]);
let shots = 0;
diff --git a/test/browser-batch.mjs b/test/browser-batch.mjs
index a1a0fbd1e..31019aff7 100644
--- a/test/browser-batch.mjs
+++ b/test/browser-batch.mjs
@@ -64,6 +64,64 @@ for (const build of ['chrome', 'firefox']) {
assert.equal(validateBrowserBatch(parent, { ...options, turnCalls: [parent, sibling] }).ok, false);
});
+ for (const repairPending of [false, true]) {
+ test(`${build}: folding retains rejected parent and executed colliding sibling (repairPending=${repairPending})`, () => {
+ const parent = batch('batch', [field()]);
+ const sibling = call('batch::0', 'get_window_info', {});
+ const rejection = validateBrowserBatch(parent, { ...options, turnCalls: [parent, sibling] }).result;
+ const parentResult = result(parent.id, JSON.stringify(rejection));
+ const siblingResult = result(sibling.id, wrap(JSON.stringify({ success: true, width: 1200 })));
+ const messages = [assistant(parent, sibling), parentResult, siblingResult];
+ const folded = fold(messages, { repairPending });
+ assert.equal(folded, messages, 'A rejected batch must not cause any folding');
+ assert.equal(folded[1], parentResult);
+ assert.equal(folded[2], siblingResult);
+ assert.equal(JSON.parse(folded[1].content).errorCode, 'invalid_browser_batch');
+ assert.equal(fold(folded, { repairPending }), folded);
+ });
+
+ test(`${build}: native child-shaped ID stays separate while another valid batch folds (repairPending=${repairPending})`, () => {
+ const parent = batch('batch', [field()]);
+ const sibling = call('batch::0', 'get_window_info', {});
+ const valid = batch('valid', [field()]);
+ const calls = [parent, sibling, valid];
+ const rejection = result(parent.id, JSON.stringify(validateBrowserBatch(parent, { ...options, turnCalls: calls }).result));
+ const siblingResult = result(sibling.id, success);
+ const messages = [assistant(...calls), rejection, siblingResult, result('valid::0', success), image];
+ const folded = fold(messages, { repairPending });
+ assert.deepEqual(folded.slice(1, 4).map(message => message.tool_call_id), ['batch', 'batch::0', 'valid']);
+ assert.equal(folded[1], rejection);
+ assert.equal(folded[2], siblingResult);
+ assert.match(folded[3].content, /ran 1 of 1 actions/);
+ assert.equal(folded[4], image);
+ assert.equal(fold(folded, { repairPending }), folded, 'A second fold must preserve all original results');
+ });
+
+ test(`${build}: pending parent never consumes a native sibling result (repairPending=${repairPending})`, () => {
+ const sibling = call('batch::0', 'get_window_info', {});
+ const siblingResult = result(sibling.id, success);
+ const messages = [assistant(batch('batch', [field()]), sibling), siblingResult];
+ const folded = fold(messages, { repairPending });
+ assert.equal(folded.find(message => message.tool_call_id === sibling.id), siblingResult);
+ assert.equal(folded.filter(message => message.tool_call_id === sibling.id).length, 1);
+ if (repairPending) assert.match(folded.find(message => message.tool_call_id === 'batch').content, /ran 0 of 1 actions; stop: interrupted/);
+ else assert.equal(folded, messages);
+ assert.equal(fold(folded, { repairPending }), folded);
+ });
+ }
+
+ test(`${build}: rejected malformed or duplicated parent IDs cannot claim child-shaped results`, () => {
+ for (const id of ['', ' ', 42, 'parent::0', 'duplicate']) {
+ const parent = batch(id, [field()]);
+ const sibling = call(`${id}::0`, 'get_window_info', {});
+ const calls = [parent, sibling, ...(id === 'duplicate' ? [batch(id, [field()])] : [])];
+ const parentResult = result(id, JSON.stringify(validateBrowserBatch(parent, { ...options, turnCalls: calls }).result));
+ const siblingResult = result(sibling.id, success);
+ const messages = [assistant(...calls), parentResult, siblingResult];
+ for (const repairPending of [false, true]) assert.equal(fold(messages, { repairPending }), messages);
+ }
+ });
+
test(`${build}: interrupted snapshot repairs missing native siblings without mutating live history`, () => {
const turn = [assistant(batch(), call('native', 'get_window_info', {})), result('parent::0', success), image];
const folded = fold(turn, { repairPending: true });