da-daken opened a new issue, #1455:
URL: https://github.com/apache/flink-agents/issues/1455

   Linked PR: #1454
   Related: #1452 (retitled to track the Java MCP feature request)
   
   ### Search before asking
   
   - [x] I searched in the 
[issues](https://github.com/apache/flink-agents/issues) and found nothing 
similar.
   
   ### Description
   
   `Aliases.resolveClazz` (Java) and `resolve_clazz` (Python) return the name 
unchanged on an alias miss, so that users can supply custom fully-qualified 
class names. That also makes two very different inputs indistinguishable to the 
loader: a legitimate custom class name and a short alias registered only for 
the other implementation language.
   
   Such a short alias therefore survives YAML loading as a class name:
   
   ```yaml
   mcp_servers:
     - name: m
       clazz: mcp
       type: java
   ```
   
   `mcp` is registered only in the Python `MCP_SERVER` alias bucket. 
`YamlLoader.buildDescriptor` creates a Java descriptor whose class is literally 
`"mcp"`, and `YamlLoader.buildAgents(Path)` succeeds. The failure surfaces 
later during resource construction (`JavaResourceProvider.provide` -> 
`Class.forName("mcp")`), far away from the YAML declaration. The same applies 
to `dashscope` / `chroma` on the Java path and `gemini` / `bedrock` / 
`elasticsearch` on the Python path.
   
   Expected: a short alias registered only for the other language fails during 
YAML loading with `Unknown <Language> alias '<alias>' for <resource kind>`, 
while a custom fully-qualified class name remains valid.
   
   Scope of the fix (PR #1454):
   - Add alias-ownership helpers to `Aliases.java` and `aliases.py`.
   - Reject such aliases in both YAML loaders, for shared and agent-local 
declarations.
   - Keep custom fully-qualified class names valid, including Java decision 
models and external sub-agents.
   - Do not change which resource kinds a loader supports. Java MCP support is 
tracked separately in #1452 and will be implemented in a separate PR.
   
   ### How to reproduce
   
   ```java
   Path yaml = Files.writeString(tmp.resolve("agent.yaml"),
           "mcp_servers:\n"
                   + "  - name: m\n"
                   + "    clazz: mcp\n"
                   + "    type: java\n");
   YamlLoader.buildAgents(yaml); // succeeds; descriptor class is "mcp"
   ```
   
   ```yaml
   chat_model_connections:
     - name: c
       clazz: dashscope
       type: java
   ```
   
   ```python
   _, resources, _ = build_agents(path)  # 
JavaResourceDescriptor(clazz="dashscope")
   ```
   
   ### Version and environment
   
   main at 555cf397d2d303d1846ee367e5c9040c3f0da3e3, Java 21, Python 3.12, 
macOS.
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR! (PR #1454)
   


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