Skip to content

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

Exclude mutable accounting metadata from feedback snapshots

Barack Sokullu83986a415073
diff --git a/docs/security-model.md b/docs/security-model.md
index 457732dbc..2287ee545 100644
--- a/docs/security-model.md
+++ b/docs/security-model.md
@@ -217,8 +217,9 @@ Feedback prepares a snapshot of the conversation selected when the rating prompt
opened. A recording cutoff captured before the asynchronous lookup excludes
later runs, events, screenshots, and completion details, even in the same
conversation. Untimestamped records are excluded from feedback snapshots;
-ordinary full-session exports remain unbounded. A dedicated dialog must
-authorize the actual attachment before it leaves the browser: GitHub uploads
+mutable byte counters, omission flags, and repair metadata are excluded with
+an explanatory note. Ordinary full-session exports remain unbounded. A dedicated
+dialog must authorize the actual attachment before it leaves the browser: GitHub uploads
files immediately, even before issue submission.
Viewing a trace and continuing without it never authorize an upload. The handoff
is restricted to the chat panel, an exact GitHub repository and destination tab,
diff --git a/src/chrome/src/trace/session-export.js b/src/chrome/src/trace/session-export.js
index 01514e496..2e784a369 100644
--- a/src/chrome/src/trace/session-export.js
+++ b/src/chrome/src/trace/session-export.js
@@ -2,6 +2,13 @@ import { buildTraceExportPayload } from './export-contract.js';
import { sanitizeTraceExport } from '../agent/trace-export.js';
import { buildTraceStats } from './stats.js';
+// These fields change independently of retained events; the current row cannot
+// tell us their values when the rating prompt opened.
+const MUTABLE_RUN_FIELDS = [
+ 'losslessBytes', 'losslessBytesEncoding', 'feedbackBytes', 'feedbackEventsOmitted',
+ 'repairedBy', 'repairedAt', 'repairReason',
+];
+
// Run in the downloading extension page, never send this JSON through runtime
// messaging: screenshots can make it larger than the browser message limit.
// Export the stored session without the Markdown preview's text/run limits.
@@ -32,6 +39,8 @@ export async function exportRecordedSession(store, sessionId, version = '', { sn
const stats = buildTraceStats(events);
delete stats.hasLoopError;
exportedRun = { ...run, ...stats };
+ for (const field of MUTABLE_RUN_FIELDS) delete exportedRun[field];
+ snapshotOmissions.add('Run-level byte counters, diagnostic omission flags, and repair metadata cannot be reconstructed at the recording cutoff and are excluded.');
if (!beforeSnapshot(run.endedAt)) {
// Completion fields may have been written after the prompt opened.
exportedRun = { ...exportedRun, endedAt: null, durationMs: null, status: 'running', finalContent: null, feedbackSnapshotIncomplete: true };
diff --git a/src/firefox/src/trace/session-export.js b/src/firefox/src/trace/session-export.js
index 01514e496..2e784a369 100644
--- a/src/firefox/src/trace/session-export.js
+++ b/src/firefox/src/trace/session-export.js
@@ -2,6 +2,13 @@ import { buildTraceExportPayload } from './export-contract.js';
import { sanitizeTraceExport } from '../agent/trace-export.js';
import { buildTraceStats } from './stats.js';
+// These fields change independently of retained events; the current row cannot
+// tell us their values when the rating prompt opened.
+const MUTABLE_RUN_FIELDS = [
+ 'losslessBytes', 'losslessBytesEncoding', 'feedbackBytes', 'feedbackEventsOmitted',
+ 'repairedBy', 'repairedAt', 'repairReason',
+];
+
// Run in the downloading extension page, never send this JSON through runtime
// messaging: screenshots can make it larger than the browser message limit.
// Export the stored session without the Markdown preview's text/run limits.
@@ -32,6 +39,8 @@ export async function exportRecordedSession(store, sessionId, version = '', { sn
const stats = buildTraceStats(events);
delete stats.hasLoopError;
exportedRun = { ...run, ...stats };
+ for (const field of MUTABLE_RUN_FIELDS) delete exportedRun[field];
+ snapshotOmissions.add('Run-level byte counters, diagnostic omission flags, and repair metadata cannot be reconstructed at the recording cutoff and are excluded.');
if (!beforeSnapshot(run.endedAt)) {
// Completion fields may have been written after the prompt opened.
exportedRun = { ...exportedRun, endedAt: null, durationMs: null, status: 'running', finalContent: null, feedbackSnapshotIncomplete: true };
diff --git a/test/feedback-traces.mjs b/test/feedback-traces.mjs
index c5ec13045..3cd8bfa38 100644
--- a/test/feedback-traces.mjs
+++ b/test/feedback-traces.mjs
@@ -152,6 +152,33 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
assert.match(await fallback.blob.text(), /CLICK_FAILED/);
});
+ test(`${build}: snapshot headers are unchanged by later accounting, omission flags or repairs`, async () => {
+ const run = { runId: 'r', conversationId: 'chosen', startedAt: 1, endedAt: null, status: 'running',
+ lossless: true, losslessBytes: 100, losslessBytesEncoding: 'utf8', feedbackOnly: true,
+ feedbackBytes: 200, feedbackHistoryOmitted: true };
+ const events = [{ seq: 1, ts: 20, kind: 'tool', data: { name: 'click_ax', result: { success: true } } }];
+ const store = { listRuns: async () => [structuredClone(run)],
+ getRunEvents: async () => structuredClone(events), getScreenshot: async () => null };
+ const first = JSON.parse(await (await prepareFeedbackTrace(store, 'chosen', 'test', { snapshotAt: 100 })).blob.text());
+ Object.assign(run, { losslessBytes: 987654, feedbackBytes: 123456, feedbackEventsOmitted: true,
+ endedAt: 250, status: 'error', repairedBy: 'LATER REPAIR', repairedAt: 250, repairReason: 'LATER REASON' });
+ events.push({ seq: 2, ts: 250, kind: 'tool', data: { losslessBudgetOmitted: true } });
+ const second = await prepareFeedbackTrace(store, 'chosen', 'test', { snapshotAt: 100 });
+ const payload = JSON.parse(await second.blob.text());
+ assert.deepEqual(payload.runs, first.runs);
+ assert.deepEqual(payload.feedbackOmissions, first.feedbackOmissions);
+ for (const field of ['losslessBytes', 'losslessBytesEncoding', 'feedbackBytes', 'feedbackEventsOmitted', 'repairedBy', 'repairedAt', 'repairReason']) {
+ assert.equal(payload.runs[0].run[field], undefined);
+ }
+ assert.equal(payload.runs[0].run.feedbackHistoryOmitted, true, 'start-time diagnostic policy is immutable');
+ assert.doesNotMatch(await second.originalBlob.text(), /987654|123456|LATER/);
+ const full = JSON.parse((await exportRecordedSession(store, 'chosen', 'test')).json);
+ assert.equal(full.runs[0].run.losslessBytes, 987654);
+ assert.equal(full.runs[0].run.feedbackEventsOmitted, true);
+ assert.equal(full.runs[0].run.repairedAt, 250);
+ assert.equal(run.losslessBytes, 987654, 'snapshot projection must not mutate stored headers');
+ });
+
test(`${build}: exports preserve diagnostic codes without exposing credential code fields`, async () => {
const events = [
{ seq: 1, kind: 'tool', data: { name: 'fill_ax', args: { code: 'QUOTA', password: 'private-password' },
@@ -433,6 +460,8 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
const snapshot = JSON.parse(attachment);
assert.deepEqual(snapshot.runs.map(entry => entry.run.runId), ['r']);
assert.equal(snapshot.runs[0].run.finalContent, null);
+ assert.equal(snapshot.runs[0].run.losslessBytes, undefined);
+ assert.equal(snapshot.runs[0].run.losslessBytesEncoding, undefined);
assert.equal(snapshot.runs[0].events.filter(event => event.kind === 'screenshot').length, 1);
assert.match(await github.locator('textarea').inputValue(), /Clicking failed/);
await github.addScriptTag({ content }); assert.equal(await github.evaluate(() => uploads), 1);