UAT: Session.linked_plans with phase/state not persisted — only flat linked_plan_ids stored in database #5852

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

Bug Report

Feature Area: Session Management — Session Persistence / Linked Plans
Severity: Backlog (linked plan details are informational, not blocking core operations)

What Was Tested

Code-level analysis of:

  • src/cleveragents/domain/models/core/session.pySession and LinkedPlan models
  • src/cleveragents/infrastructure/database/models.pySessionModel

Expected Behavior (from spec)

Per docs/specification.md §agents session show, the session output includes linked plans with phase and state:

Linked Plans
Plan ID                     Phase    State
--------------------------  -------  --------
01HXM8C2ZK4Q7C2B3F2R4VYV6J  execute  complete

The Session domain model has a linked_plans field of type list[LinkedPlan] (line 229):

linked_plans: list[LinkedPlan] = Field(
    default_factory=list,
    description="Linked plans with phase and state details",
)

Where LinkedPlan contains plan_id, phase, and state.

Actual Behavior (from code)

The SessionModel database model (models.py lines 2077) only stores a flat JSON list of plan IDs:

linked_plan_ids_json = Column(Text, nullable=True)

There is no column for storing linked_plans with their phase and state details.

The to_domain() method (lines 2110–2136) only restores linked_plan_ids (flat list), not linked_plans (with phase/state):

linked_plan_ids: list[str] = json.loads(
    cast(str, self.linked_plan_ids_json or "[]")
)
# ...
return Session(
    # ...
    linked_plan_ids=linked_plan_ids,
    # linked_plans is NOT restored
)

The as_cli_dict() method in session.py (lines 392–399) handles this with a fallback:

elif self.linked_plan_ids:
    # Fallback: if only flat IDs are available, emit minimal objects
    result["linked_plans"] = [
        {"plan_id": pid, "phase": "", "state": ""}
        for pid in self.linked_plan_ids
    ]

This means agents session show will always display empty phase and state for linked plans after a process restart.

Code Location

  • src/cleveragents/infrastructure/database/models.py, lines 2077, 2110–2136 (SessionModel)
  • src/cleveragents/domain/models/core/session.py, lines 229–233 (linked_plans field)

Impact

The Linked Plans table in agents session show will always show empty Phase and State columns after a process restart, even if plans have progressed through their lifecycle.


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

## Bug Report **Feature Area:** Session Management — Session Persistence / Linked Plans **Severity:** Backlog (linked plan details are informational, not blocking core operations) ## What Was Tested Code-level analysis of: - `src/cleveragents/domain/models/core/session.py` — `Session` and `LinkedPlan` models - `src/cleveragents/infrastructure/database/models.py` — `SessionModel` ## Expected Behavior (from spec) Per `docs/specification.md` §`agents session show`, the session output includes linked plans with phase and state: ``` Linked Plans Plan ID Phase State -------------------------- ------- -------- 01HXM8C2ZK4Q7C2B3F2R4VYV6J execute complete ``` The `Session` domain model has a `linked_plans` field of type `list[LinkedPlan]` (line 229): ```python linked_plans: list[LinkedPlan] = Field( default_factory=list, description="Linked plans with phase and state details", ) ``` Where `LinkedPlan` contains `plan_id`, `phase`, and `state`. ## Actual Behavior (from code) The `SessionModel` database model (`models.py` lines 2077) only stores a flat JSON list of plan IDs: ```python linked_plan_ids_json = Column(Text, nullable=True) ``` There is no column for storing `linked_plans` with their `phase` and `state` details. The `to_domain()` method (lines 2110–2136) only restores `linked_plan_ids` (flat list), not `linked_plans` (with phase/state): ```python linked_plan_ids: list[str] = json.loads( cast(str, self.linked_plan_ids_json or "[]") ) # ... return Session( # ... linked_plan_ids=linked_plan_ids, # linked_plans is NOT restored ) ``` The `as_cli_dict()` method in `session.py` (lines 392–399) handles this with a fallback: ```python elif self.linked_plan_ids: # Fallback: if only flat IDs are available, emit minimal objects result["linked_plans"] = [ {"plan_id": pid, "phase": "", "state": ""} for pid in self.linked_plan_ids ] ``` This means `agents session show` will always display empty `phase` and `state` for linked plans after a process restart. ## Code Location - `src/cleveragents/infrastructure/database/models.py`, lines 2077, 2110–2136 (`SessionModel`) - `src/cleveragents/domain/models/core/session.py`, lines 229–233 (`linked_plans` field) ## Impact The `Linked Plans` table in `agents session show` will always show empty `Phase` and `State` columns after a process restart, even if plans have progressed through their lifecycle. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.2.0 milestone 2026-04-09 11:37:13 +00:00
Author
Owner

Label compliance fix applied:

  • Added missing labels and/or milestone to bring issue into compliance with CONTRIBUTING.md

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

Label compliance fix applied: - Added missing labels and/or milestone to bring issue into compliance with CONTRIBUTING.md --- **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.

Reference
cleveragents/cleveragents-core#5852
No description provided.