diff --git a/CHANGELOG.md b/CHANGELOG.md index 193d137b5..469ec4a52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Changed `wf10_batch.robot` to be less likely to create files, and `plan_generation_graph.robot` to give more test answers. ## [Unreleased] +- **feat(context): PriorityContextStrategy** (#9997 / PR #10772): Implements a priority-based context strategy that ranks context fragments by configurable priority scores — default role-based rules (system > tool > user > assistant), exponential recency decay (7-day half-life), and explicit priority tag boost. Supports custom scoring function injection and custom PriorityRule list injection. Registered in the ACMS pipeline under key `priority_context`. `PriorityRule` uses Pydantic `BaseModel` for architecture conformance. Includes 18 BDD scenarios covering all acceptance criteria. - **fix(cli/plan): plan correct JSON output envelope fix and BDD test coverage** (#8584 / PR #8662): Restructured `agents plan correct --format json` output to nest correction fields under `data.correction` (e.g., `data.correction.mode`) and populate the spec-required CLI envelope with `command="plan correct"`, `status`, `exit_code`, `timing`, and `messages` fields. Added three BDD scenarios in `features/tdd_plan_correct_json_output.feature` validating the envelope structure for both revert and append modes. - **fix(cli): add --url flag to resource add for git resource type** (#6322): Added support for the `--url` flag on `agents resource add git` command, allowing users to specify a remote URL for git resources. The flag is validated to only apply to git resource types. Includes Behave BDD tests in `features/resource_cli_git_url_flag.feature` and Robot Framework integration tests verifying correct URL validation and CLI behavior. - **Session create JSON envelope** (#6441): Fixed `agents session create --format json` returning a flat `data` dict instead of the spec-required nested structure with `data.session`, `data.settings`, and `data.actor_details` sub-objects. The `command` field is now populated correctly. Extended JSON envelope coverage to `agents session list`, `show`, `delete --format json`, `export --output-format json`, and `import --format json` so all session commands emit a structured `messages[].text` field (`"0 sessions listed"`, `"Session details loaded"`, `"Session deleted"`, `"Export completed"`, `"Import completed"`). diff --git a/src/cleveragents/application/services/acms_service.py b/src/cleveragents/application/services/acms_service.py index 940576029..a4953305d 100644 --- a/src/cleveragents/application/services/acms_service.py +++ b/src/cleveragents/application/services/acms_service.py @@ -74,6 +74,22 @@ def _get_semantic_chunking_strategy_class() -> type: return _SemanticChunkingStrategy +# Lazy import helper for PriorityContextStrategy (issue #9997). +_PriorityContextStrategy: type | None = None + + +def _get_priority_context_strategy_class() -> type: + """Return the :class:`PriorityContextStrategy` class, importing lazily.""" + global _PriorityContextStrategy + if _PriorityContextStrategy is None: + from cleveragents.application.services.priority_context_strategy import ( + PriorityContextStrategy, + ) + + _PriorityContextStrategy = PriorityContextStrategy + return _PriorityContextStrategy + + _SPEC_BUILTIN_STRATEGIES: dict[str, Any] | None = None @@ -815,6 +831,10 @@ class ACMSPipeline: if "semantic_chunking" not in self._strategies: _sc_cls = _get_semantic_chunking_strategy_class() self._strategies["semantic_chunking"] = cast(ContextStrategy, _sc_cls()) + # Register PriorityContextStrategy (issue #9997). + if "priority_context" not in self._strategies: + _pc_cls = _get_priority_context_strategy_class() + self._strategies["priority_context"] = cast(ContextStrategy, _pc_cls()) # Register the 6 spec-required built-in strategies via adapters. # These strategies implement the domain-model ContextStrategy protocol # (strategy_stubs.py) and are wrapped in SpecStrategyAdapter instances