Skip to content

feat(decision_cascade): add single-batch UI gate and catalog-pruning router - #4321

Closed
gspencergoog wants to merge 11 commits into
feat/decision-kernel-standalonefrom
feat/decision-cascade
Closed

gspencergoog wants to merge 11 commits into
feat/decision-kernel-standalonefrom
feat/decision-cascade

Conversation

@gspencergoog

Copy link
Copy Markdown
Collaborator

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

  • Added a2ui.inference_formats.experimental.decision_cascade exporting DecisionCascadeRouter, CascadeConfig, CascadeTier, ExpressSurfaceSpec, and RouteDecision.
  • Implemented single-batch decision evaluation that decides whether a turn needs UI, routes between TEXT_ONLY, TEMPLATE, PRUNED_EXPRESS, FULL_EXPRESS, and SANDBOX_APP, and prunes catalogs while preserving layout floors and ancestor/descendant closure.
  • Added unit tests in python/a2ui_agent/tests/decision_cascade/test_cascade_router.py and updated python/a2ui_agent/CHANGELOG.md.

Impact & Risks

  • Isolated under a2ui.inference_formats.experimental.decision_cascade and decorated with @experimental; not imported by public barrels.
  • Depends only on the shared a2ui.inference_formats.experimental.decision facade (enforced by test_experimental_import_isolation.py).

Testing

  • uv run pyink --check python/a2ui_agent
  • uv run mypy --follow-imports=silent python/a2ui_agent/src/a2ui/inference_formats/experimental/decision_cascade/*.py
  • A2UI_SUPPRESS_EXPERIMENTAL_FEATURE_WARNINGS=1 uv run pytest python/a2ui_agent/tests/decision_cascade/ python/a2ui_agent/tests/test_experimental_import_isolation.py -q

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

…router

Signed-off-by: Greg Spencer <gspencer@google.com>
…g latency_budget_ms

Signed-off-by: Greg Spencer <gspencer@google.com>
Comment thread python/a2ui_agent/CHANGELOG.md Resolved
…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.
gspencergoog added a commit that referenced this pull request Dec 1, 2026
- 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.
gspencergoog added a commit that referenced this pull request Dec 1, 2026
- 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.
@gspencergoog

Copy link
Copy Markdown
Collaborator Author

Closing this PR in favor of the modularized replacement stack.

@jacobsimionato: a2ui.experimental.decision.cascade (DecisionCascadeRouter, UI gate, and closure-preserving catalog pruner) has been moved into #4474, with previous review comments incorporated.

🤖 Agent-generated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants