Ma77Ball commented on code in PR #9432:
URL: https://github.com/apache/texera/pull/9432#discussion_r4662417761


##########
frontend/src/app/workspace/component/agent/agent-panel/react-step-detail-modal/react-step-detail-modal.component.ts:
##########
@@ -18,7 +18,7 @@
  */
 
 import { Component, Input, Output, EventEmitter } from "@angular/core";
-import { ReActStep } from "../../../../service/agent/agent-types";
+import { ReActStep, ModelMessage, TextPart, ToolCallPart, ToolResultPart } 
from "../../../../service/agent/agent-types";

Review Comment:
   Rewrote the change summary to match the SDK-types approach (ModelMessage[] 
input, re-exported TextPart/ToolCallPart/ToolResultPart, type-narrowing 
helpers, buildToolCallNameMap removed, output unwrapped from its { type, value 
} envelope) and corrected the test count to 25.
   



##########
frontend/src/app/workspace/component/agent/agent-panel/react-step-detail-modal/react-step-detail-modal.component.ts:
##########
@@ -27,6 +27,15 @@ import { NzDescriptionsComponent, 
NzDescriptionsItemComponent } from "ng-zorro-a
 import { NzTagComponent } from "ng-zorro-antd/tag";
 import { NzCollapseComponent, NzCollapsePanelComponent } from 
"ng-zorro-antd/collapse";
 
+/** The array content of a ModelMessage, i.e. its typed parts rather than a 
plain string. */
+type MessageParts = Exclude<ModelMessage["content"], string>;
+
+/** A tool-result part's output is a structured { type, value }; unwrap the 
displayable value. */
+function toolResultValue(part: ToolResultPart): unknown {
+  const output = part.output as { value?: unknown };
+  return output?.value ?? part.output;

Review Comment:
   Added the `?? ""` fallback so a tool-result with no output renders an empty 
string, and getToolResultFullItems no longer reads `.length` off undefined.
   



##########
frontend/src/app/workspace/component/agent/agent-panel/react-step-detail-modal/react-step-detail-modal.component.ts:
##########
@@ -27,6 +27,15 @@ import { NzDescriptionsComponent, 
NzDescriptionsItemComponent } from "ng-zorro-a
 import { NzTagComponent } from "ng-zorro-antd/tag";
 import { NzCollapseComponent, NzCollapsePanelComponent } from 
"ng-zorro-antd/collapse";
 
+/** The array content of a ModelMessage, i.e. its typed parts rather than a 
plain string. */
+type MessageParts = Exclude<ModelMessage["content"], string>;

Review Comment:
   Removed the MessageParts alias and the four `as` casts; the helpers now 
filter `msg.content` directly after the string guard, which type-checks under 
strict (`tsc --noEmit` clean).
   



##########
frontend/src/app/workspace/component/agent/agent-panel/react-step-detail-modal/react-step-detail-modal.component.spec.ts:
##########
@@ -225,38 +227,24 @@ describe("ReActStepDetailModalComponent", () => {
   describe("getToolResultFullItems / getToolResultItems", () => {
     function toolMessage(): any {
       return {
+        role: "tool",
         content: [
-          { type: "tool-result", toolCallId: "tc1", result: "short result" },
-          { type: "tool-result", toolCallId: "tc2", output: { rows: 3 } },
-          { type: "tool-result", toolCallId: "tc3", content: "after context 
compaction" },
+          { type: "tool-result", toolCallId: "tc1", toolName: "addOperator", 
output: "short result" },

Review Comment:
   Reshaped the tool-result fixtures to SDK `{ type, value }` outputs so the 
tests exercise the unwrap path, and added a case asserting a missing output 
renders an empty string with a zero token count.
   



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