-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
area/routingRouting engine: catalog, graph, router, cardsRouting engine: catalog, graph, router, cardscomplexity/simpleStraightforward change, minimal riskStraightforward change, minimal riskenhancementNew feature or requestNew feature or requestmilestone/v0.3v0.3 — Production readinessv0.3 — Production readinesspriority/mediumMedium priority — production readinessMedium priority — production readiness
Description
Problem
In multi-turn conversations, agents sometimes re-call the same tool or route to inappropriate tools for the current phase. There is no way to express "don't route to X" or "exclude tools matching tag Y". This leads to redundant tool calls and wasted tokens.
For example, after successfully calling db_query, the agent might route to it again on the next turn instead of moving to send_email. Exclusion patterns prevent these loops.
Proposal
Add exclusion parameters to Router.route():
result = router.route(
query="send the results",
exclude_ids={"db_query", "db_schema"}, # Exclude specific tools
exclude_tags={"database"}, # Exclude all tools with tag
)Implementation
Router.route()signature — addexclude_ids: set[str] | Noneandexclude_tags: set[str] | None- Pre-filter — before beam search, mark excluded leaf nodes as unreachable
- Pruning — if all children of an interior node are excluded, prune the parent too
RouteResult— includeexcluded_count: intshowing how many tools were filtered
Constraints
- Exclusions are applied before scoring (not post-filter)
- If all tools are excluded, raise
RouteErrorwith descriptive message - Empty exclude sets = no filtering (backward-compatible)
Acceptance Criteria
-
Router.route()acceptsexclude_idsandexclude_tagsparameters - Excluded tools never appear in route results
- Interior nodes with all-excluded children are pruned
-
RouteErrorraised if all tools are excluded - Empty exclusions produce identical results to current behavior
-
RouteResultreports excluded count - Tests cover ID exclusion, tag exclusion, full-prune edge case
File Paths
src/contextweaver/routing/router.py(edit)tests/test_router.py(edit)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/routingRouting engine: catalog, graph, router, cardsRouting engine: catalog, graph, router, cardscomplexity/simpleStraightforward change, minimal riskStraightforward change, minimal riskenhancementNew feature or requestNew feature or requestmilestone/v0.3v0.3 — Production readinessv0.3 — Production readinesspriority/mediumMedium priority — production readinessMedium priority — production readiness