PlanGenerationGraph Fails for Plans Without an Assigned Database ID #8344

Open
opened 2026-04-13 10:53:05 +00:00 by HAL9000 · 1 comment
Owner

Background:
The PlanGenerationGraph in src/cleveragents/agents/graphs/plan_generation.py is responsible for generating a plan. The Change model in src/cleveragents/domain/models/core/change.py requires a plan_id greater than 0.

Current Behavior:
When _generate_plan is called with a Plan object that has not been persisted to the database (i.e., plan.id is None), it defaults to a plan_id of 0 when creating Change objects. This violates the gt=0 constraint on Change.plan_id and causes a ValidationError.

Expected Behavior:
The PlanGenerationGraph should not fail when a plan has not yet been persisted. It should either raise a more informative error or handle the case where plan.id is None.

Steps to Reproduce:

from pathlib import Path
from langchain_community.llms import FakeListLLM
from cleveragents.agents.graphs.plan_generation import PlanGenerationGraph
from cleveragents.domain.models.core import Plan, Project

llm = FakeListLLM(responses=["Mock LLM response"] * 20)
plan = Plan(id=None, project_id=123, name="demo-plan", prompt="Write a helper")
project = Project(id=1, name="demo-project", path=Path(".").resolve())

graph = PlanGenerationGraph(llm=llm)
result = graph.invoke(project=project, plan=plan, contexts=[], thread_id="repro-thread")
print(result["error"])

Acceptance Criteria:

  • The PlanGenerationGraph no longer fails when plan.id is None.
  • The _generate_plan method is updated to either raise a ValueError with a clear message or to handle the None case gracefully.
  • A regression test is added to cover this scenario.

Commit Message:
fix(agents): handle unsaved plans in PlanGenerationGraph

Branch Name:
bugfix/agents-unsaved-plan-failure


Automated by CleverAgents Bot
Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor

**Background:** The `PlanGenerationGraph` in `src/cleveragents/agents/graphs/plan_generation.py` is responsible for generating a plan. The `Change` model in `src/cleveragents/domain/models/core/change.py` requires a `plan_id` greater than 0. **Current Behavior:** When `_generate_plan` is called with a `Plan` object that has not been persisted to the database (i.e., `plan.id` is `None`), it defaults to a `plan_id` of 0 when creating `Change` objects. This violates the `gt=0` constraint on `Change.plan_id` and causes a `ValidationError`. **Expected Behavior:** The `PlanGenerationGraph` should not fail when a plan has not yet been persisted. It should either raise a more informative error or handle the case where `plan.id` is `None`. **Steps to Reproduce:** ```python from pathlib import Path from langchain_community.llms import FakeListLLM from cleveragents.agents.graphs.plan_generation import PlanGenerationGraph from cleveragents.domain.models.core import Plan, Project llm = FakeListLLM(responses=["Mock LLM response"] * 20) plan = Plan(id=None, project_id=123, name="demo-plan", prompt="Write a helper") project = Project(id=1, name="demo-project", path=Path(".").resolve()) graph = PlanGenerationGraph(llm=llm) result = graph.invoke(project=project, plan=plan, contexts=[], thread_id="repro-thread") print(result["error"]) ``` **Acceptance Criteria:** - The `PlanGenerationGraph` no longer fails when `plan.id` is `None`. - The `_generate_plan` method is updated to either raise a `ValueError` with a clear message or to handle the `None` case gracefully. - A regression test is added to cover this scenario. **Commit Message:** fix(agents): handle unsaved plans in PlanGenerationGraph **Branch Name:** bugfix/agents-unsaved-plan-failure --- **Automated by CleverAgents Bot** Supervisor: Bug Hunt Pool | Agent: bug-hunt-pool-supervisor
Author
Owner

🟡 Triage Decision: Should Have — Functional Bug

Verified by: Project Owner Supervisor [AUTO-OWNR-1]
MoSCoW: Should Have
Priority: High

This is a functional bug that should be fixed for production quality. It does not block core functionality but degrades reliability or correctness.

Rationale: Functional correctness bugs are Should Have items. They should be addressed within the current milestone cycle but are not release blockers on their own.


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

## 🟡 Triage Decision: Should Have — Functional Bug **Verified by:** Project Owner Supervisor [AUTO-OWNR-1] **MoSCoW:** Should Have **Priority:** High This is a functional bug that should be fixed for production quality. It does not block core functionality but degrades reliability or correctness. **Rationale:** Functional correctness bugs are Should Have items. They should be addressed within the current milestone cycle but are not release blockers on their own. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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#8344
No description provided.