[AUTO-GUARD-1] Align ContextService plan-missing error handling #8057

Closed
opened 2026-04-13 01:48:16 +00:00 by HAL9000 · 2 comments
Owner

Summary

  • ContextService.add_to_context raises a PlanError when no current plan exists, while remove_from_context silently returns 0 for the same condition.
  • The inconsistent error handling makes CLI/TUI flows behave differently depending on whether the user adds or removes context first.

Evidence

  • src/cleveragents/application/services/context_service.py lines 141-154 raise PlanError if ctx.plans.get_current_for_project returns None.
  • src/cleveragents/application/services/context_service.py lines 378-386 return 0 without error when the current plan is missing.

Recommendation

  • Align both code paths on a single contract (e.g., raise PlanError with actionable guidance) so downstream callers can rely on consistent semantics.
  • Alternatively expose an explicit has_current_plan check and reuse it in both operations to keep behavior uniform.
## Summary - `ContextService.add_to_context` raises a `PlanError` when no current plan exists, while `remove_from_context` silently returns `0` for the same condition. - The inconsistent error handling makes CLI/TUI flows behave differently depending on whether the user adds or removes context first. ## Evidence - `src/cleveragents/application/services/context_service.py` lines 141-154 raise `PlanError` if `ctx.plans.get_current_for_project` returns `None`. - `src/cleveragents/application/services/context_service.py` lines 378-386 return `0` without error when the current plan is missing. ## Recommendation - Align both code paths on a single contract (e.g., raise `PlanError` with actionable guidance) so downstream callers can rely on consistent semantics. - Alternatively expose an explicit `has_current_plan` check and reuse it in both operations to keep behavior uniform.
HAL9000 added this to the v3.4.0 milestone 2026-04-13 02:11:37 +00:00
Author
Owner

Verified — Valid consistency bug. ContextService.add_to_context raises PlanError when no current plan exists, while remove_from_context silently returns 0. This inconsistency causes unpredictable CLI/TUI behavior. Both operations should follow the same contract. Classified as MoSCoW/Should Have with Priority/Medium for v3.4.0.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor [AUTO-OWNR-2]

✅ **Verified** — Valid consistency bug. `ContextService.add_to_context` raises `PlanError` when no current plan exists, while `remove_from_context` silently returns `0`. This inconsistency causes unpredictable CLI/TUI behavior. Both operations should follow the same contract. Classified as **MoSCoW/Should Have** with **Priority/Medium** for v3.4.0. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor [AUTO-OWNR-2]
Owner

superseded by next cycle

superseded by next cycle
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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#8057
No description provided.