weiqingy commented on code in PR #838:
URL: https://github.com/apache/flink-agents/pull/838#discussion_r3400285473


##########
e2e-test/flink-agents-end-to-end-tests-integration/src/test/java/org/apache/flink/agents/integration/test/ReActAgentTest.java:
##########
@@ -152,8 +154,74 @@ public void testReActAgent() throws Exception {
         checkResult(results);
     }
 
-    // create ReAct agent.
-    private static Agent getAgent() {
+    @Test
+    public void testReActAgentNoOutputSchema() throws Exception {
+        Assumptions.assumeTrue(ollamaReady, String.format("%s is not ready", 
OLLAMA_MODEL));
+        StreamExecutionEnvironment env = 
StreamExecutionEnvironment.getExecutionEnvironment();
+        env.setParallelism(1);
+
+        // Create the table environment
+        StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);
+        tableEnv.getConfig().set("table.exec.result.display.max-column-width", 
"100");
+
+        // Create agents execution environment
+        AgentsExecutionEnvironment agentsEnv =
+                AgentsExecutionEnvironment.getExecutionEnvironment(env, 
tableEnv);
+
+        // register resource to agents execution environment.
+        agentsEnv
+                .addResource(
+                        "ollama",
+                        ResourceType.CHAT_MODEL_CONNECTION,
+                        ResourceDescriptor.Builder.newBuilder(
+                                        
ResourceName.ChatModel.OLLAMA_CONNECTION)
+                                .addInitialArgument("endpoint", 
"http://localhost:11434";)
+                                .addInitialArgument("requestTimeout", 240)
+                                .build())
+                .addResource(
+                        "add",
+                        ResourceType.TOOL,
+                        Tool.fromMethod(
+                                ReActAgentTest.class.getMethod("add", 
Double.class, Double.class)))
+                .addResource(
+                        "multiply",
+                        ResourceType.TOOL,
+                        Tool.fromMethod(
+                                ReActAgentTest.class.getMethod(
+                                        "multiply", Double.class, 
Double.class)));
+
+        agentsEnv.getConfig().set(ERROR_HANDLING_STRATEGY, 
ReActAgent.ErrorHandlingStrategy.RETRY);
+        agentsEnv.getConfig().set(MAX_RETRIES, 3);
+
+        // Declare the ReAct agent without an output schema.
+        Agent agent = getAgent(false);
+
+        // Create input table from sample data
+        Table inputTable =
+                tableEnv.fromValues(
+                        DataTypes.ROW(
+                                DataTypes.FIELD("a", DataTypes.DOUBLE()),
+                                DataTypes.FIELD("b", DataTypes.DOUBLE()),
+                                DataTypes.FIELD("c", DataTypes.DOUBLE())),
+                        Row.of(2131, 29847, 3));
+
+        // Apply agent to the Table; without an output schema the result is a 
string.
+        DataStream<Object> out =
+                agentsEnv
+                        .fromTable(
+                                inputTable,
+                                (KeySelector<Object, Double>)
+                                        value -> (Double) ((Row) 
value).getField("a"))
+                        .apply(agent)
+                        .toDataStream();
+
+        out.print();

Review Comment:
   This test passes as long as `env.execute()` doesn't throw, so it covers "the 
plan serializes and the job runs" — which is the crash this PR fixes — but it 
doesn't pin the contract the no-schema path establishes: that the output comes 
back as a `String`. The Python counterpart goes a step further with `assert 
len(output_list) == 1` and `assert isinstance(output_list[0]["0001"], str)`, 
and the schema-case Java test routes through `checkResult(...)` for an exact 
value check. Would it be worth collecting the output here too — 
`collectAsync()` like the schema test, then asserting `hasNext()` and that the 
value is a `String` — so a regression that emitted nothing or wrongly took the 
`STRUCTURED_OUTPUT` branch in `stopAction` would fail on the Java side as well? 
Or is the intent to keep the Java e2e deliberately lighter than the Python one?



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