Copilot commented on code in PR #6009:
URL: https://github.com/apache/texera/pull/6009#discussion_r3524554783


##########
agent-service/src/agent/tools/workflow-execution-tools.ts:
##########
@@ -504,35 +449,36 @@ export async function executeOperatorAndFormat(
     const opInfo = result.operators[operatorId];
     if (!opInfo) {
       return createErrorResult(
-        formatExecutionError(undefined, undefined, [`No result found for 
operator: ${operatorId}`])
+        formatExecutionError(undefined, [makeExecutionFailure(`No result found 
for operator: ${operatorId}`, "")])
       );
     }
 
-    if (opInfo.error) {
+    const opError = getOperatorErrorText(opInfo);
+    if (opError) {
       if (options.onResult) {
         options.onResult(operatorId, opInfo);
       }
-      return createErrorResult(formatExecutionError(undefined, [{ operatorId, 
error: opInfo.error }]));
+      return createErrorResult(formatExecutionError([{ operatorId, error: 
opError }]));
     }
 
-    if (!opInfo.result || !Array.isArray(opInfo.result)) {
+    const sampleTuples = opInfo.resultSummary?.sampleTuples;
+    if (!sampleTuples || !Array.isArray(sampleTuples)) {
       return "(no result data)";
     }
 
-    const jsonArray = opInfo.result as Record<string, any>[];
-    const headers = jsonArray.length > 0 ? 
getVisibleResultHeaders(jsonArray[0]) : [];
+    const headers = sampleTuples.length > 0 ? 
getVisibleResultHeaders(sampleTuples[0].tuple) : [];
     const columns = headers.length;
 
     // Notify for every operator in the execution so upstream stats are also 
stored.
     if (options.onResult) {
       for (const [opId, info] of Object.entries(result.operators)) {
-        if (info && !info.error) {
+        if (info && !getOperatorErrorText(info)) {
           options.onResult(opId, info);
         }
       }
     }
 
-    let dataString = jsonToTableFormat(jsonArray);
+    let dataString = formatSampleRowsAsTsv(sampleTuples);
 

Review Comment:
   `executeOperatorAndFormat` always TSV-serializes 
`resultSummary.sampleTuples`. For visualization results this can include the 
raw `html-content`/`json-content` payload, which can (a) leak huge blobs into 
the tool output and (b) bypass the later char-budget trimming because the first 
(oversized) row is always kept. This diverges from `formatOperatorResult`, 
which replaces visualization payload fields with a placeholder before 
formatting.
   
   Scrub visualization payload fields before calling `formatSampleRowsAsTsv` 
(and use the scrubbed rows for header/column derivation as well).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to