UAT: ContextAssemblyPipeline.assemble() ignores ContextRequest.preferred_strategies — ConfidenceWeightedSelector preference boost never applied #2105

Open
opened 2026-04-03 04:05:38 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/acms-pipeline-preferred-strategies-ignored
  • Commit Message: fix(acms): pass ContextRequest to ConfidenceWeightedSelector for preferred_strategies boost
  • Milestone: v3.7.0
  • Parent Epic: #396

Summary

The ContextAssemblyPipeline.assemble() method in acms_pipeline.py accepts a request: ContextRequest | None parameter and passes it to self._budget_allocator.allocate(). However, it does NOT pass the request to self._strategy_selector.select().

The ConfidenceWeightedSelector.select() method reads preferred_strategies from the request dict to apply a 1.5x confidence boost to preferred strategies. But the pipeline passes only {"strategy": strategy_name} to the selector — it never includes the preferred_strategies from the ContextRequest.

This means ContextRequest.preferred_strategies is completely ignored during strategy selection, even though the spec defines it as a way for actors to hint which strategies to prefer.

Expected Behavior (from spec)

When a ContextRequest with preferred_strategies=["semantic-embedding", "arce"] is passed to assemble(), the ConfidenceWeightedSelector should apply a 1.5x confidence boost to those strategies, making them more likely to be selected.

Actual Behavior

The preferred_strategies field in ContextRequest is silently ignored. The selector always receives {"strategy": strategy_name} without any preferred_strategies key, so the preference boost in ConfidenceWeightedSelector is never triggered.

Code Location

src/cleveragents/application/services/acms_pipeline.py, ContextAssemblyPipeline.assemble():

# Line ~380: selector is called without the ContextRequest
candidates = self._strategy_selector.select(
    all_strategies,
    {"strategy": strategy_name},  # ← preferred_strategies from request is NOT included
)

The ConfidenceWeightedSelector.select() at line ~145:

preferred: list[str] = request.get("preferred_strategies", [])  # Always empty!

The same issue exists in ACMSPipeline.assemble() in acms_service.py.

Steps to Reproduce

from cleveragents.application.services.acms_pipeline import ContextAssemblyPipeline
from cleveragents.domain.models.acms.crp import ContextRequest
from cleveragents.domain.models.core.context_fragment import ContextBudget

pipeline = ContextAssemblyPipeline()
request = ContextRequest(
    query="test",
    preferred_strategies=["relevance"],  # This should boost relevance strategy
)
# preferred_strategies is ignored — the selector never sees it
payload = pipeline.assemble(
    plan_id="01JQTESTPN00000000000000AA",
    fragments=[],
    budget=ContextBudget(max_tokens=1000, reserved_tokens=0),
    request=request,
)

Impact

  • Medium severity: The preferred_strategies feature is completely non-functional. Actors that set preferred_strategies in their ContextRequest get no benefit.
  • The ConfidenceWeightedSelector has dead code for the preference boost that is never triggered.

Fix

Pass the ContextRequest's preferred_strategies to the selector:

selector_request = {"strategy": strategy_name}
if request is not None and request.preferred_strategies:
    selector_request["preferred_strategies"] = list(request.preferred_strategies)

candidates = self._strategy_selector.select(all_strategies, selector_request)

Subtasks

  • Update ContextAssemblyPipeline.assemble() to include preferred_strategies from ContextRequest in the selector request dict
  • Update ACMSPipeline.assemble() with the same fix
  • Add a BDD scenario testing that preferred_strategies in ContextRequest causes the preference boost to be applied
  • Verify ConfidenceWeightedSelector preference boost works end-to-end

Definition of Done

  • ContextRequest.preferred_strategies is passed to ConfidenceWeightedSelector
  • ConfidenceWeightedSelector applies the 1.5x boost to preferred strategies
  • BDD test added and passing
  • No regressions

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Metadata - **Branch**: `fix/acms-pipeline-preferred-strategies-ignored` - **Commit Message**: `fix(acms): pass ContextRequest to ConfidenceWeightedSelector for preferred_strategies boost` - **Milestone**: v3.7.0 - **Parent Epic**: #396 ## Summary The `ContextAssemblyPipeline.assemble()` method in `acms_pipeline.py` accepts a `request: ContextRequest | None` parameter and passes it to `self._budget_allocator.allocate()`. However, it does NOT pass the request to `self._strategy_selector.select()`. The `ConfidenceWeightedSelector.select()` method reads `preferred_strategies` from the `request` dict to apply a 1.5x confidence boost to preferred strategies. But the pipeline passes only `{"strategy": strategy_name}` to the selector — it never includes the `preferred_strategies` from the `ContextRequest`. This means `ContextRequest.preferred_strategies` is completely ignored during strategy selection, even though the spec defines it as a way for actors to hint which strategies to prefer. ## Expected Behavior (from spec) When a `ContextRequest` with `preferred_strategies=["semantic-embedding", "arce"]` is passed to `assemble()`, the `ConfidenceWeightedSelector` should apply a 1.5x confidence boost to those strategies, making them more likely to be selected. ## Actual Behavior The `preferred_strategies` field in `ContextRequest` is silently ignored. The selector always receives `{"strategy": strategy_name}` without any `preferred_strategies` key, so the preference boost in `ConfidenceWeightedSelector` is never triggered. ## Code Location `src/cleveragents/application/services/acms_pipeline.py`, `ContextAssemblyPipeline.assemble()`: ```python # Line ~380: selector is called without the ContextRequest candidates = self._strategy_selector.select( all_strategies, {"strategy": strategy_name}, # ← preferred_strategies from request is NOT included ) ``` The `ConfidenceWeightedSelector.select()` at line ~145: ```python preferred: list[str] = request.get("preferred_strategies", []) # Always empty! ``` The same issue exists in `ACMSPipeline.assemble()` in `acms_service.py`. ## Steps to Reproduce ```python from cleveragents.application.services.acms_pipeline import ContextAssemblyPipeline from cleveragents.domain.models.acms.crp import ContextRequest from cleveragents.domain.models.core.context_fragment import ContextBudget pipeline = ContextAssemblyPipeline() request = ContextRequest( query="test", preferred_strategies=["relevance"], # This should boost relevance strategy ) # preferred_strategies is ignored — the selector never sees it payload = pipeline.assemble( plan_id="01JQTESTPN00000000000000AA", fragments=[], budget=ContextBudget(max_tokens=1000, reserved_tokens=0), request=request, ) ``` ## Impact - Medium severity: The `preferred_strategies` feature is completely non-functional. Actors that set `preferred_strategies` in their `ContextRequest` get no benefit. - The `ConfidenceWeightedSelector` has dead code for the preference boost that is never triggered. ## Fix Pass the `ContextRequest`'s `preferred_strategies` to the selector: ```python selector_request = {"strategy": strategy_name} if request is not None and request.preferred_strategies: selector_request["preferred_strategies"] = list(request.preferred_strategies) candidates = self._strategy_selector.select(all_strategies, selector_request) ``` ## Subtasks - [ ] Update `ContextAssemblyPipeline.assemble()` to include `preferred_strategies` from `ContextRequest` in the selector request dict - [ ] Update `ACMSPipeline.assemble()` with the same fix - [ ] Add a BDD scenario testing that `preferred_strategies` in `ContextRequest` causes the preference boost to be applied - [ ] Verify `ConfidenceWeightedSelector` preference boost works end-to-end ## Definition of Done - [ ] `ContextRequest.preferred_strategies` is passed to `ConfidenceWeightedSelector` - [ ] `ConfidenceWeightedSelector` applies the 1.5x boost to preferred strategies - [ ] BDD test added and passing - [ ] No regressions --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
freemo added this to the v3.7.0 milestone 2026-04-03 04:05:43 +00:00
freemo self-assigned this 2026-04-03 16:58:07 +00:00
Author
Owner

MoSCoW classification: Should Have

Rationale: This issue addresses a spec requirement or important quality improvement. It should be included in the milestone if possible.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

MoSCoW classification: **Should Have** Rationale: This issue addresses a spec requirement or important quality improvement. It should be included in the milestone if possible. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#2105
No description provided.