Skip to content

Commit 700aef9

Browse files
esokulluclaude
andcommitted
refactor(agent): freeze shared image budget defaults
Object.freeze the module-level IMAGE_BUDGET so accidental mutation of the shared default throws (modules are strict mode) instead of silently changing every caller. Per-capture overrides already spread into fresh objects. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 84180d8 commit 700aef9

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/chrome/src/agent/image-budget.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33

44
// These defaults match Claude for Chrome. Pixel dimensions and approximate
55
// vision-token area bound provider cost, while the byte/quality fields are
6-
// consumed by each browser's platform-specific image encoder.
7-
export const IMAGE_BUDGET = {
6+
// consumed by each browser's platform-specific image encoder. Frozen so an
7+
// accidental mutation of the shared default throws instead of silently
8+
// changing every caller; per-capture overrides spread into a fresh object.
9+
export const IMAGE_BUDGET = Object.freeze({
810
pxPerToken: 28,
911
maxTargetPx: 1568,
1012
maxTargetTokens: 1568,
1113
maxBase64Chars: 1398100,
1214
initialJpegQuality: 0.75,
1315
minJpegQuality: 0.10,
1416
jpegQualityStep: 0.05,
15-
};
17+
});
1618

1719
export function estimateImageTokens(w, h, pxPerToken) {
1820
return Math.ceil((w / pxPerToken) * (h / pxPerToken));

src/firefox/src/agent/image-budget.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33

44
// These defaults match Claude for Chrome. Pixel dimensions and approximate
55
// vision-token area bound provider cost, while the byte/quality fields are
6-
// consumed by each browser's platform-specific image encoder.
7-
export const IMAGE_BUDGET = {
6+
// consumed by each browser's platform-specific image encoder. Frozen so an
7+
// accidental mutation of the shared default throws instead of silently
8+
// changing every caller; per-capture overrides spread into a fresh object.
9+
export const IMAGE_BUDGET = Object.freeze({
810
pxPerToken: 28,
911
maxTargetPx: 1568,
1012
maxTargetTokens: 1568,
1113
maxBase64Chars: 1398100,
1214
initialJpegQuality: 0.75,
1315
minJpegQuality: 0.10,
1416
jpegQualityStep: 0.05,
15-
};
17+
});
1618

1719
export function estimateImageTokens(w, h, pxPerToken) {
1820
return Math.ceil((w / pxPerToken) * (h / pxPerToken));

0 commit comments

Comments
 (0)