UAT: cost_actual_usd column on v3_plans never populated — actual plan cost not tracked #5836

Open
opened 2026-04-09 10:27:46 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: Cost Tracking — Per-Plan Actual Cost
Milestone: v3.5.0 (M6)
Severity: Priority/Backlog — actual cost tracking is silently missing

What Was Tested

The LifecyclePlanModel.cost_actual_usd column and Plan domain model were inspected against the specification's cost tracking requirements.

Expected Behavior (from spec)

The specification states:

The system must track the estimated cost of every plan and tool invocation.
Costs are associated with LLM provider APIs and other metered services.
Budgets can be set at the per-session and per-organization level to act as guardrails.

The LifecyclePlanModel has both:

cost_estimate_usd = Column(Float, nullable=True)  # Pre-execution estimate
cost_actual_usd = Column(Float, nullable=True)     # Post-execution actual

Actual Behavior

The LifecyclePlanModel.from_domain() only sets cost_estimate_usd:

cost_estimate_usd=getattr(plan, "cost_estimate_usd", None),

The Plan domain model (src/cleveragents/domain/models/core/plan.py) only has cost_estimate_usd — there is no cost_actual_usd field.

The TraceService.compute_metrics() computes LLM_TOTAL_COST_USD from LLM traces, but this value is never written back to cost_actual_usd on the plan.

The CostBudgetService tracks session-level costs via record_plan_cost(), but this is not persisted to the plan's cost_actual_usd column.

Code Location

  • src/cleveragents/infrastructure/database/models.pyLifecyclePlanModel.from_domain() doesn't set cost_actual_usd
  • src/cleveragents/domain/models/core/plan.pyPlan domain model missing cost_actual_usd field
  • src/cleveragents/application/services/trace_service.py — computes actual cost but doesn't persist to plan

Impact

  • Users cannot see the actual cost of a completed plan (only the estimate)
  • Budget enforcement cannot compare actual vs. estimated costs
  • Cost reporting is incomplete — cost_actual_usd is always NULL
  • The CostBudgetService session tracking and the plan's cost column are disconnected

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

## Bug Report **Feature Area**: Cost Tracking — Per-Plan Actual Cost **Milestone**: v3.5.0 (M6) **Severity**: Priority/Backlog — actual cost tracking is silently missing ### What Was Tested The `LifecyclePlanModel.cost_actual_usd` column and `Plan` domain model were inspected against the specification's cost tracking requirements. ### Expected Behavior (from spec) The specification states: > The system must track the estimated cost of every plan and tool invocation. > Costs are associated with LLM provider APIs and other metered services. > Budgets can be set at the per-session and per-organization level to act as guardrails. The `LifecyclePlanModel` has both: ```python cost_estimate_usd = Column(Float, nullable=True) # Pre-execution estimate cost_actual_usd = Column(Float, nullable=True) # Post-execution actual ``` ### Actual Behavior The `LifecyclePlanModel.from_domain()` only sets `cost_estimate_usd`: ```python cost_estimate_usd=getattr(plan, "cost_estimate_usd", None), ``` The `Plan` domain model (`src/cleveragents/domain/models/core/plan.py`) only has `cost_estimate_usd` — there is no `cost_actual_usd` field. The `TraceService.compute_metrics()` computes `LLM_TOTAL_COST_USD` from LLM traces, but this value is never written back to `cost_actual_usd` on the plan. The `CostBudgetService` tracks session-level costs via `record_plan_cost()`, but this is not persisted to the plan's `cost_actual_usd` column. ### Code Location - `src/cleveragents/infrastructure/database/models.py` — `LifecyclePlanModel.from_domain()` doesn't set `cost_actual_usd` - `src/cleveragents/domain/models/core/plan.py` — `Plan` domain model missing `cost_actual_usd` field - `src/cleveragents/application/services/trace_service.py` — computes actual cost but doesn't persist to plan ### Impact - Users cannot see the actual cost of a completed plan (only the estimate) - Budget enforcement cannot compare actual vs. estimated costs - Cost reporting is incomplete — `cost_actual_usd` is always `NULL` - The `CostBudgetService` session tracking and the plan's cost column are disconnected --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.5.0 milestone 2026-04-09 13:53:46 +00:00
Author
Owner

Milestone compliance fix applied:

  • Assigned to milestone: v3.5.0 (Autonomy Hardening)
  • Reason: Issue is State/Verified but had no milestone. Issue body explicitly states "Milestone: v3.5.0 (M6)" — cost tracking belongs to v3.5.0 scope.

Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: backlog-groomer

Milestone compliance fix applied: - Assigned to milestone: **v3.5.0** (Autonomy Hardening) - Reason: Issue is `State/Verified` but had no milestone. Issue body explicitly states "Milestone: v3.5.0 (M6)" — cost tracking belongs to v3.5.0 scope. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: backlog-groomer
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#5836
No description provided.