weiqingy opened a new issue, #547: URL: https://github.com/apache/flink-agents/issues/547
### Search before asking - [x] I searched in the [issues](https://github.com/apache/flink-agents/issues) and found nothing similar. ### Description `AgentPlan` (624 lines) mixes plan definition, resource caching/resolution, Python bridge wiring, and serialization into one class. This makes the plan mutable after construction, prevents testing resource resolution independently, and couples Python MCP discovery logic to the plan definition. ### What is currently not ideal? - `AgentPlan` is **mutable** after construction — `setPythonResourceAdapter()` writes to the transient `resourceCache` - Resource resolution (`getResource()`) and cleanup (`close()`) are runtime concerns living on a serializable plan object - Python MCP tool/prompt discovery is entangled with the plan — AgentPlan directly references `PythonMCPServer`, `PythonResourceAdapter` - Cannot test resource resolution without constructing a full AgentPlan - Blocks runtime MCP reloading — the plan owns the cache, so refreshing tools requires mutating the plan ### How should it be fixed? Extract two classes: 1. **`ResourceCache`** (~80 lines) — Lazy resource resolution, caching, dependency injection, and close/cleanup. Created by the operator in `open()`, owned by the operator lifecycle. 2. **`PythonResourceBridge`** (~55 lines) — Static method that discovers tools/prompts from Python MCP servers and registers them in the cache. Called from `ActionExecutionOperator.initPythonResourceAdapter()`. After extraction, `AgentPlan` becomes an immutable data object (~490 lines) holding actions, resource providers, and config. The removed public methods are `getResource()`, `close()`, and `setPythonResourceAdapter()`. ### Files affected - `plan/.../AgentPlan.java` — remove extracted methods and transient fields - `plan/.../ResourceCache.java` — **new** - `plan/.../PythonResourceBridge.java` — **new** - `runtime/.../RunnerContextImpl.java` — delegate to `ResourceCache` instead of `AgentPlan` - `runtime/.../JavaRunnerContextImpl.java` — constructor change - `runtime/.../PythonRunnerContextImpl.java` — constructor change - `runtime/.../ActionExecutionOperator.java` — create and own `ResourceCache` - 6 test files updated to use `ResourceCache` directly ### Are you willing to submit a PR? - [x] I'm willing to submit a PR! -- 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]
