bobbai00 commented on code in PR #9432:
URL: https://github.com/apache/texera/pull/9432#discussion_r4651730902
##########
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:
**Must fix:**
The PR description still describes round 1: local `MessagePart` and
`InputMessage` interfaces, helpers taking `InputMessage | null`, and a
`buildToolCallNameMap` guard. This import replaced all of that with the SDK
types. The repo squash-merges with the PR body as the commit message, so the
stale text would land in history. Suggested replacement for "What changes were
proposed":
```markdown
- Typed `ReActStep.inputMessages` as the SDK's `ModelMessage[]` and
re-exported `TextPart`, `ToolCallPart`, and `ToolResultPart` from `ai` in
`agent-types.ts`, instead of the local interfaces #9429 proposed.
- The modal's message helpers take `ModelMessage | null` and narrow content
parts by `type`; `getToolCallSummaries` reads `input` and returns `fullArgs` as
`Record<string, unknown>`.
- Tool-result names come from the part's own `toolName` (falling back to
`toolCallId`), so `buildToolCallNameMap` is removed, and tool-result output is
unwrapped from its `{ type, value }` envelope for display.
- `formatResult`, `formatJson`, and `getToolResult` use `unknown` for the
payloads they stringify.
```
##########
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:
**Advisory:**
Main ended this chain with `?? ""`, so a part without `output` rendered
empty. Now `toolResultValue` returns `undefined`, `JSON.stringify(undefined)`
is `undefined` too, and `resultStr.length` (line 162) throws a `TypeError`
while the panel header renders. Nothing sends such a part today
([`context-utils.ts:101`](https://github.com/apache/texera/blob/f030df12b73c2c6a8f2e8b325c6e762d54fead7f/agent-service/src/agent/util/context-utils.ts#L101)),
but the old default costs nothing to keep.
```suggestion
return output?.value ?? part.output ?? "";
```
##########
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:
**Advisory:**
This alias only feeds the four `msg.content as MessageParts` casts.
TypeScript already narrows `msg.content` after the string check, and the
helpers type-check without either (TypeScript 5.9.3, ai 5.0.93, `strict`).
Since `as` is unchecked, the cast would also hide a dropped string guard.
Suggest removing both and calling `msg.content.filter(...)` directly.
##########
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:
**Advisory:**
`ToolResultPart.output` is a `{ type, value }` envelope, so tsc rejects this
raw string (`Type 'string' is not assignable to type
'LanguageModelV2ToolResultOutput'`). That is why these fixtures need `as any`.
It also means no test reaches the unwrap in `toolResultValue`, the one line
whose output differs from main. SDK-shaped outputs fix both: `{ type: "text",
value: "short result" }`, `{ type: "json", value: { rows: 3 } }`, and the same
for `"ok"` on line 55. The existing assertions still hold.
--
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]