bobbai00 commented on code in PR #9259:
URL: https://github.com/apache/texera/pull/9259#discussion_r4450272047


##########
agent-service/src/agent/texera-agent.ts:
##########
@@ -587,7 +587,9 @@ export class TexeraAgent {
           const formattedToolResults = toolResults?.map(tr => ({

Review Comment:
   **Must fix:**
   
   Tool calls the SDK rejects still reach the model as `(succeeded)`. A call 
with schema-invalid input or an unknown tool name becomes a `tool-error` part, 
which `ai` 7.0.58 leaves out of `toolResults`. So it gets no entry here, and 
[`serializeTask`](https://github.com/apache/texera/blob/9b214b669fe187f287a45ed7c6acc0b6c6ae6df7/agent-service/src/agent/util/context-utils.ts#L127-L128)
 defaults to succeeded. For example, `modifyOperator` without its required 
[`summary`](https://github.com/apache/texera/blob/9b214b669fe187f287a45ed7c6acc0b6c6ae6df7/agent-service/src/agent/tools/workflow-crud-tools.ts#L252)
 changes nothing but is reported as succeeded. In delegate mode it also 
triggers the post-step execution below, which [this 
test](https://github.com/apache/texera/blob/9b214b669fe187f287a45ed7c6acc0b6c6ae6df7/agent-service/src/agent/texera-agent.spec.ts#L1039-L1041)
 rules out for rejected modifications. Build the results from the step's 
`content` (`tool-error` as `isError: true`), matc
 h them by `toolCallId` in `serializeTask`, and reuse them for the post-step 
check. 
[texera-agent.spec.ts:1035](https://github.com/apache/texera/blob/9b214b669fe187f287a45ed7c6acc0b6c6ae6df7/agent-service/src/agent/texera-agent.spec.ts#L1035)
 already pins `toolResults: []` for this case, so it can become the regression 
test.



##########
agent-service/src/agent/texera-agent.ts:
##########
@@ -587,7 +587,9 @@ export class TexeraAgent {
           const formattedToolResults = toolResults?.map(tr => ({
             toolCallId: tr.toolCallId,
             output: tr.output,
-            isError: !!(tr.output as any)?.error,
+            isError:
+              (typeof tr.output === "string" && 
tr.output.startsWith("[ERROR]")) ||
+              (typeof tr.output === "object" && tr.output !== null && "error" 
in tr.output && !!tr.output.error),

Review Comment:
   **Advisory:**
   
   This re-spells `createErrorResult`'s `[ERROR]` prefix inline, as line 635 
already does. The object branch has no producer, since every registered tool 
returns a string 
([tools-utility.ts:26-32](https://github.com/apache/texera/blob/9b214b669fe187f287a45ed7c6acc0b6c6ae6df7/agent-service/src/agent/tools/tools-utility.ts#L26-L32)).
 An `isErrorResult(output)` exported next to `createErrorResult` keeps the rule 
beside the format it checks. Use it wherever a result is classified, and drop 
the object branch.



-- 
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