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


##########
agent-service/src/agent/util/context-utils.spec.ts:
##########
@@ -0,0 +1,101 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { describe, expect, test } from "bun:test";
+import type { ModelMessage } from "ai";
+import { assembleContext } from "./context-utils";
+import { WorkflowState } from "../workflow-state";
+import type { ReActStep } from "../../types/agent";
+import type { OperatorPredicate } from "../../types/workflow";
+
+function step(messageId: string, role: "user" | "agent", stepId: number, 
content: string, isEnd: boolean): ReActStep {
+  return {
+    id: `${messageId}-${stepId}`,
+    messageId,
+    stepId,
+    timestamp: 0,
+    role,
+    content,
+    isBegin: true,
+    isEnd,
+  };
+}
+
+function makeOperator(id: string): OperatorPredicate {
+  return {
+    operatorID: id,
+    operatorType: "TestOp",
+    operatorVersion: "1.0",
+    operatorProperties: {},
+    inputPorts: [],
+    outputPorts: [],
+    showAdvanced: false,
+  };
+}
+
+// assembleContext always joins string sections, so narrowing the ModelMessage
+// content to string is safe.
+function contentOf(result: ModelMessage[]): string {
+  return result[0].content as string;
+}

Review Comment:
   Nit: the invariant “assembleContext returns a single { role: "user", 
content: string } message” is only asserted in the empty-steps test. Consider 
enforcing it in the shared helper so every test case catches a regression in 
the wrapper shape as well as the markdown content.



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