Repository navigation
feat(decision_cascade): add single-batch UI gate and catalog-pruning router - #4321
gspencergoog wants to merge 11 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the DecisionCascadeRouter under a2ui.inference_formats.experimental.decision_cascade to handle single-batch UI gating, template selection, and component pruning, along with comprehensive unit tests. The feedback highlights a critical performance bottleneck in the _close_upward function where nested BFS calls lead to O(|comp_names|^4) complexity, potentially blocking the async event loop. Additionally, there are potential TypeError bugs in _build_parent_to_children_edges and _valid_upward_parents if allowed_parents is omitted or None in the catalog schema, which should be guarded against.
fe71fee to
aa995f2
Compare
0cd228f to
fecb6ba
Compare
…router Signed-off-by: Greg Spencer <gspencer@google.com>
…g latency_budget_ms Signed-off-by: Greg Spencer <gspencer@google.com>
fecb6ba to
10e439b
Compare
…cade # Conflicts: # python/a2ui_agent/CHANGELOG.md
Signed-off-by: Greg Spencer <gspencer@google.com>
- Compute surface distances, upward/downward closure, and reachability jointly across all active catalogs keyed by (cid_idx, comp_name), dropping unreachable orphans and falling back to FULL_CATALOG if no Surface-eligible root survives. - Replace hardcoded BasicCatalog layout_floor with a catalog-agnostic structural floor derived from ComponentNodeSpec metadata when layout_floor is None. - Filter registered templates by active catalog_id, reject reserved 'none' IDs, and gate normal-budget template selection on template_min_confidence. - Add CascadeConfig.max_questions and optional batch_formatter hook, plus keyword-only context, conversation, and input_parts on route(). - Decouple CascadeTier and templates from Express (PRUNED_CATALOG, FULL_CATALOG, SurfaceTemplateSpec protocol) and drop the ExpressSurfaceSpec re-export. - Defer CatalogDecisionGraph construction, omit route:tier under tight budgets, propagate upward-closure reachability via incremental BFS, enforce strict _valid_children_for, guard non-finite/zero distributions, and update CHANGELOG.
- Compute surface distances, upward/downward closure, and reachability jointly across all active catalogs keyed by (cid_idx, comp_name), dropping unreachable orphans and falling back to FULL_CATALOG if no Surface-eligible root survives. - Replace hardcoded BasicCatalog layout_floor with a catalog-agnostic structural floor derived from ComponentNodeSpec metadata when layout_floor is None. - Filter registered templates by active catalog_id, reject reserved 'none' IDs, and gate normal-budget template selection on template_min_confidence. - Add CascadeConfig.max_questions and optional batch_formatter hook, plus keyword-only context, conversation, and input_parts on route(). - Decouple CascadeTier and templates from Express (PRUNED_CATALOG, FULL_CATALOG, SurfaceTemplateSpec protocol) and drop the ExpressSurfaceSpec re-export. - Defer CatalogDecisionGraph construction (validating via public resolve_default_catalog_id), omit route:tier under tight budgets, propagate upward-closure reachability via incremental BFS, enforce strict _valid_children_for, and guard non-finite/zero distributions.
- Compute surface distances, upward/downward closure, and reachability jointly across all active catalogs keyed by (cid_idx, comp_name), dropping unreachable orphans and falling back to FULL_CATALOG if no Surface-eligible root survives. - Replace hardcoded BasicCatalog layout_floor with a catalog-agnostic structural floor derived from ComponentNodeSpec metadata when layout_floor is None. - Filter registered templates by active catalog_id, reject reserved 'none' IDs, and gate normal-budget template selection on template_min_confidence. - Add CascadeConfig.max_questions and optional batch_formatter hook, plus keyword-only context, conversation, and input_parts on route(). - Decouple CascadeTier and templates from Express (PRUNED_CATALOG, FULL_CATALOG, SurfaceTemplateSpec protocol) and drop the ExpressSurfaceSpec re-export. - Defer CatalogDecisionGraph construction (validating via public resolve_default_catalog_id), omit route:tier under tight budgets, propagate upward-closure reachability via incremental BFS, enforce strict _valid_children_for, and guard non-finite/zero distributions.
…cade # Conflicts: # python/a2ui_agent/CHANGELOG.md
|
Closing this PR in favor of the modularized replacement stack. @jacobsimionato: 🤖 Agent-generated |
Summary
Adds
DecisionCascadeRouter(a2ui.inference_formats.experimental.decision_cascade) on top of the shared decision kernel for single-batch UI gating, template selection, and closure-preserving catalog pruning before Express generation.Reviewer Focus
python/a2ui_agent/src/a2ui/inference_formats/experimental/decision_cascade/router.py: single-batch question construction (gate:needs_ui,route:tier,route:template,prune:<cid_idx>:<comp>), tight-budget gating, upward/downward catalog closure, and empty-prune fallback toFULL_EXPRESS.python/a2ui_agent/tests/decision_cascade/test_cascade_router.py: gating thresholds, budget routing, closure termination, all-zero distribution handling, and empty pruned catalog fallback.Changes
a2ui.inference_formats.experimental.decision_cascadeexportingDecisionCascadeRouter,CascadeConfig,CascadeTier,ExpressSurfaceSpec, andRouteDecision.TEXT_ONLY,TEMPLATE,PRUNED_EXPRESS,FULL_EXPRESS, andSANDBOX_APP, and prunes catalogs while preserving layout floors and ancestor/descendant closure.python/a2ui_agent/tests/decision_cascade/test_cascade_router.pyand updatedpython/a2ui_agent/CHANGELOG.md.Impact & Risks
a2ui.inference_formats.experimental.decision_cascadeand decorated with@experimental; not imported by public barrels.a2ui.inference_formats.experimental.decisionfacade (enforced bytest_experimental_import_isolation.py).Testing
uv run pyink --check python/a2ui_agentuv run mypy --follow-imports=silent python/a2ui_agent/src/a2ui/inference_formats/experimental/decision_cascade/*.pyA2UI_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS=1 uv run pytest python/a2ui_agent/tests/decision_cascade/ python/a2ui_agent/tests/test_experimental_import_isolation.py -q