Pr0Beginner opened a new pull request, #1502:
URL: https://github.com/apache/flink-agents/pull/1502

   ### Purpose of change
   
   **Problem:**
   The built-in `ReActAgent` only accepts a single `CHAT_MODEL` 
`ResourceDescriptor` and cannot use a `ModelRouter`. Its `skills` merging 
assumes a single chat model descriptor, and its `output_schema` native 
structured output check probes `_default_chat_model` before routing occurs.
   
   **Solution:**
   - **Aligned Java & Python APIs**: Added `model_router` to Python 
`ReActAgent.__init__` and `modelRouter(ResourceDescriptor)` to Java 
`ReActAgent.Builder`, enforcing strict XOR with `chat_model`/`chatModel`, 
router descriptor recognition (preventing misplacement across `chat_model` and 
`model_router`), cross-language guards, reserved internal candidate-name 
checks, and eager router declaration validation.
   - **Routing Integration**: In router mode, `ReActAgent` registers the router 
under `ResourceType.MODEL_ROUTER` (`_default_model_router`), sets 
`use_model_router=true` on `startAction`, and emits 
`ChatRequestEvent(model="_default_model_router", ...)` to reuse existing 
`ChatModelAction` routing, fallback, and escalation.
   - **Agent-Level `skills` Across Router Candidates**: Declared compile-time 
`_router_skill_bindings` on `startAction` (cloned and stripped during 
`AgentPlan` extraction) and augmented router candidate `CHAT_MODEL` descriptors 
in `AgentPlan` after `AGENT` sub-agent compilation and before 
`addBuiltInTools()` / `validateRoutingStrategies()`, preserving per-candidate 
`bash` opt-in and `allowed_commands`. Aligned sub-agent candidate localization 
and `_skills_config` merging with root-only `ResourceCache` inheritance and 
binding-aware memoization, flattened `SkillSourceSpec` in 
`PythonResourceProvider.provide` for in-JVM Pemja calls, and expanded 
`validateJudge` to forbid `skills_sources`.
   - **`output_schema` Handling**: When `use_model_router=true`, `ReActAgent` 
skips `_default_chat_model` probing and uses the JSON schema prompt during 
reasoning, while `ChatModelInvoker` still applies native structured output 
finalization per selected/fallback/escalated candidate where supported.
   - **Tests & Docs**: Added Java and Python unit/plan tests covering 
validation, candidate augmentation, sub-agent localization/memoization, Pemja 
flattening, and schema instructions, and updated `model_routing.md`, 
`react_agent.md`, `structured-output.md`, and `subagents.md`.
   
   ### Documentation
   
   - [ ] `doc-needed`
   - [ ] `doc-not-needed`
   - [x] `doc-included`
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   - [x] Yes
   - [ ] No
   
   Generated-by: Antigravity (Gemini)
   


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