From 583f5ba13e34da9c2c2354ea5564d3dfae9130b4 Mon Sep 17 00:00:00 2001 From: CleverThis Date: Tue, 5 May 2026 19:31:49 +0000 Subject: [PATCH] fix(cli): add per-tier budget utilization breakdown to context show Extends the budget utilization summary in `context show` to display hot/warm/cold tier utilization percentages individually, satisfying the spec requirement for a per-tier breakdown. Previously only hot tier utilization was shown. - Hot tier: tokens used vs. max_tokens_hot budget - Warm tier: fragment count vs. max_decisions_warm budget - Cold tier: fragment count vs. max_decisions_cold budget Also updates Robot Framework helper to verify per-tier breakdown is present in output, and updates CHANGELOG/CONTRIBUTORS. ISSUES CLOSED: #9586 --- CHANGELOG.md | 11 +++++---- CONTRIBUTORS.md | 2 +- robot/helper_acms_context_cli.py | 8 +++++++ src/cleveragents/cli/commands/acms_context.py | 23 +++++++++++++++---- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a9caa759..8c0e0f01a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,11 +19,12 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - **ACMS Context CLI Commands** (`context show` / `context clear`) (#9586): Implemented two new CLI commands for the ACMS (Advanced Context Management System). `context show - ` displays assembled context for a named view including budget utilization summary - (tokens used vs. budget). `context clear` removes context index entries filtered by - `--path`, `--tag`, or `--tier`; supports `--yes` flag to bypass interactive confirmation - for non-interactive/CI use. Includes full `--help` documentation, input validation, - proper error handling, Robot Framework integration tests, and ASV performance benchmarks. + ` displays assembled context for a named view including a full per-tier budget + utilization summary (hot/warm/cold tokens used vs. budget). `context clear` removes + context index entries filtered by `--path`, `--tag`, or `--tier`; supports `--yes` flag + to bypass interactive confirmation for non-interactive/CI use. Includes full `--help` + documentation, input validation, proper error handling, Robot Framework integration + tests, and ASV performance benchmarks. - Wired `StrategyActor` into the real plan execution path: `_get_plan_executor` in `plan.py` now resolves the strategy actor via `resolve_strategy_actor()` diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 49c780a8d..310fccf55 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -19,4 +19,4 @@ Below are some of the specific details of various contributions. * HAL 9000 has contributed the plan concurrency race-condition fix (#7989): wired `LockService` into the plan lifecycle, guarding `execute_plan()` and `apply_plan()` with plan-level advisory locks and unique per-invocation owner identities to prevent silent concurrent state corruption. * This project was made possible thanks to considerable donation of time, money, and resources by CleverThis, Inc. * HAL 9000 has contributed automated bug fixes, CLI output formatting improvements, and ongoing maintenance as part of the CleverAgents automation system. -* HAL 9000 has contributed the ACMS context CLI commands (`context show` and `context clear`) for the ACMS v1 milestone, including full BDD test coverage, Robot Framework integration tests, and ASV performance benchmarks (issue #9586). +* HAL 9000 has contributed the ACMS context CLI commands (`context show` and `context clear`) for the ACMS v1 milestone, including full BDD test coverage, Robot Framework integration tests, ASV performance benchmarks, and per-tier budget utilization breakdown (issue #9586). diff --git a/robot/helper_acms_context_cli.py b/robot/helper_acms_context_cli.py index dafd7168e..c2f026f11 100644 --- a/robot/helper_acms_context_cli.py +++ b/robot/helper_acms_context_cli.py @@ -150,6 +150,14 @@ def _cmd_context_show() -> int: if expected not in output: print(f"acms-fail: expected {expected!r} in output\n{output}") return 1 + # Verify per-tier budget utilization breakdown is present + for tier_label in ("Hot tier", "Warm tier", "Cold tier"): + if tier_label not in output: + print( + f"acms-fail: expected per-tier breakdown" + f" '{tier_label}' in output\n{output}" + ) + return 1 print("acms-context-show-ok") return 0 diff --git a/src/cleveragents/cli/commands/acms_context.py b/src/cleveragents/cli/commands/acms_context.py index 7dfb28cf2..71cf25cc5 100644 --- a/src/cleveragents/cli/commands/acms_context.py +++ b/src/cleveragents/cli/commands/acms_context.py @@ -133,18 +133,31 @@ def acms_context_show( # Display tier metrics using actual token counts per tier metrics = tier_service.get_metrics() budget = tier_service.budget - utilization = _format_budget_utilization(hot_tokens, budget.max_tokens_hot or 1) + hot_utilization = _format_budget_utilization( + hot_tokens, budget.max_tokens_hot or 1 + ) + warm_utilization = _format_budget_utilization( + metrics.warm_count, budget.max_decisions_warm or 1 + ) + cold_utilization = _format_budget_utilization( + metrics.cold_count, budget.max_decisions_cold or 1 + ) console.print("\n[bold]Budget Utilization:[/bold]") console.print( - f" Hot tier: {metrics.hot_count} fragments ({hot_tokens:,} tokens)" + f" Hot tier: {metrics.hot_count} fragments" + f" ({hot_tokens:,} tokens)" + f" — {hot_utilization} of token budget" ) console.print( - f" Warm tier: {metrics.warm_count} fragments ({warm_tokens:,} tokens)" + f" Warm tier: {metrics.warm_count} fragments" + f" ({warm_tokens:,} tokens)" + f" — {warm_utilization} of decision budget" ) console.print( - f" Cold tier: {metrics.cold_count} fragments ({cold_tokens:,} tokens)" + f" Cold tier: {metrics.cold_count} fragments" + f" ({cold_tokens:,} tokens)" + f" — {cold_utilization} of decision budget" ) - console.print(f" Hot utilization: {utilization}") except CleverAgentsError as e: _logger.exception("ACMS context show failed for view %r", view)