sangkyoonnam opened a new pull request, #1487: URL: https://github.com/apache/flink-agents/pull/1487
Linked issue: Part of #1437 ### Purpose of change This is PR 1 of 3 for the Python side of #1437, following the split agreed on the issue. It adds the declaration that #1363 added in Java: `Escalation.tiers(...)`, `.when(...)` with `QualitySignals.decision(...)` or `QualitySignals.custom(...)`, `.max_escalations(n)`, and `ModelRouterBuilder.escalation(...)`, with Java's builder names in snake case. The builder writes the same `escalation_tiers`, `escalation_signals` and `escalation_max` arguments as Java, and the declaration accepts a router with tiers and no strategy, as Java does. Python doesn't execute escalation yet, so a router that declares tiers fails with "not supported in Python yet". Plan validation rejects it with the router's name, whether the descriptor came from the builder, YAML or a restored plan, and `ModelRouter` resource creation rejects tiers merged from `ModelRouter.*` configuration. Before this change, `RouterDeclaration` dropped these arguments without an error, including ones merged from `ModelRouter.*` configuration. This PR doesn't add the quality context and verdict types, the evaluator, the chat action loop, recovery or docs; those come in PRs 2 and 3. ### Behavioral Semantics Decoding a descriptor checks shapes, and validation applies Java's rules: at least two distinct tiers, every tier a candidate, a positive cap, and per-signal arguments. Errors from plan validation name the router once, as in `Model router 'x' escalation needs at least two tiers`. ### Tests `test_escalation.py` covers the descriptor arguments against Java's keys, the plan rejection of a built router, the tier, cap and signal rules, and `ModelRouter.*` configuration applied when a restored plan provides the router. `test_model_routing_validation.py` covers the plan-time rejection and the error text. `pytest flink_agents/api flink_agents/plan flink_agents/runtime/tests`: 2746 passed, 18 skipped. Ruff 0.11.13 passed. ### API Adds `flink_agents.api.chat_models.escalation` (`Escalation`, `EscalationSignal`, `QualitySignals`) and `ModelRouterBuilder.escalation(...)`. `RouterDeclaration` gains the three `escalation_*` fields and an `escalation` property, and `strategy_type` becomes optional, so `RouterDeclaration.strategy` returns `None` for a tiers-only router. ### Documentation - [ ] `doc-needed` - [x] `doc-not-needed` - [ ] `doc-included` `model_routing.md` still says Python does not yet support `escalation(...)`, which stays true after this PR; PR 3 rewrites that line. ### Was this patch authored or co-authored using generative AI tooling? - [x] Yes - [ ] No Generated-by: Claude Code 2.1.331 (Claude Opus 5.5) -- 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]
