Skip to content

Commit 9dd2eec

Browse files
committed
add elements to step_end
1 parent fa4e499 commit 9dd2eec

File tree

8 files changed

+416
-120
lines changed

8 files changed

+416
-120
lines changed

sentience/agent.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,11 @@ def act( # noqa: C901
486486
"signals": verify_signals,
487487
}
488488

489+
# Build elements data for pre field (include diff_status from snap_with_diff)
490+
# Use the same format as build_snapshot_event for consistency
491+
snapshot_event_data = TraceEventBuilder.build_snapshot_event(snap_with_diff)
492+
pre_elements = snapshot_event_data.get("elements", [])
493+
489494
# Build complete step_end event
490495
step_end_data = TraceEventBuilder.build_step_end_event(
491496
step_id=step_id,
@@ -498,6 +503,7 @@ def act( # noqa: C901
498503
llm_data=llm_data,
499504
exec_data=exec_data,
500505
verify_data=verify_data,
506+
pre_elements=pre_elements,
501507
)
502508

503509
_safe_tracer_call(
@@ -1045,6 +1051,11 @@ async def act( # noqa: C901
10451051
"signals": verify_signals,
10461052
}
10471053

1054+
# Build elements data for pre field (include diff_status from snap_with_diff)
1055+
# Use the same format as build_snapshot_event for consistency
1056+
snapshot_event_data = TraceEventBuilder.build_snapshot_event(snap_with_diff)
1057+
pre_elements = snapshot_event_data.get("elements", [])
1058+
10481059
# Build complete step_end event
10491060
step_end_data = TraceEventBuilder.build_step_end_event(
10501061
step_id=step_id,
@@ -1057,6 +1068,7 @@ async def act( # noqa: C901
10571068
llm_data=llm_data,
10581069
exec_data=exec_data,
10591070
verify_data=verify_data,
1071+
pre_elements=pre_elements,
10601072
)
10611073

10621074
_safe_tracer_call(

sentience/extension/background.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ async function handleScreenshotCapture(_tabId, options = {}) {
144144
async function handleSnapshotProcessing(rawData, options = {}) {
145145
const MAX_ELEMENTS = 10000; // Safety limit to prevent hangs
146146
const startTime = performance.now();
147-
147+
148148
try {
149149
// Safety check: limit element count to prevent hangs
150150
if (!Array.isArray(rawData)) {
151151
throw new Error('rawData must be an array');
152152
}
153-
153+
154154
if (rawData.length > MAX_ELEMENTS) {
155155
console.warn(`[Sentience Background] ⚠️ Large dataset: ${rawData.length} elements. Limiting to ${MAX_ELEMENTS} to prevent hangs.`);
156156
rawData = rawData.slice(0, MAX_ELEMENTS);
@@ -186,7 +186,7 @@ async function handleSnapshotProcessing(rawData, options = {}) {
186186
// Add timeout protection (18 seconds - less than content.js timeout)
187187
analyzedElements = await Promise.race([
188188
wasmPromise,
189-
new Promise((_, reject) =>
189+
new Promise((_, reject) =>
190190
setTimeout(() => reject(new Error('WASM processing timeout (>18s)')), 18000)
191191
)
192192
]);

sentience/extension/content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function handleSnapshotRequest(data) {
9292
if (responded) return; // Already responded via timeout
9393
responded = true;
9494
clearTimeout(timeoutId);
95-
95+
9696
const duration = performance.now() - startTime;
9797

9898
// Handle Chrome extension errors (e.g., background script crashed)

0 commit comments

Comments
 (0)