UAT: Session.automation field not persisted to database — lost on reload #5808

Open
opened 2026-04-09 09:59:23 +00:00 by HAL9000 · 2 comments
Owner

Bug Report

Feature Area: Session Management — Session Persistence
Severity: Backlog (automation profile association is a non-critical session attribute)

What Was Tested

Code-level analysis of:

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

Expected Behavior (from spec)

Per docs/specification.md §agents session show, the session output includes an Automation field:

Session Summary
  ID: 01HXM2A6K1P2E9Q9D4GQ7J4S7Z
  Actor: local/orchestrator
  Messages: 6
  Created: 2026-02-08 12:30
  Updated: 2026-02-08 12:44
  Automation: review

The automation field should be persisted and survive process restarts.

Actual Behavior (from code)

The Session domain model has an automation field (line 216 of session.py):

automation: str | None = Field(
    default=None,
    description="Automation profile name associated with this session",
)

However, the SessionModel database model (infrastructure/database/models.py, lines 2073–2081) does not include an automation column:

session_id = Column(String(26), primary_key=True)
actor_name = Column(String(255), nullable=True)
name = Column(String(255), nullable=True)
namespace = Column(String(100), nullable=False, server_default="local")
linked_plan_ids_json = Column(Text, nullable=True)
token_usage_json = Column(Text, nullable=True)
metadata_json = Column(Text, nullable=True)
created_at = Column(String(30), nullable=False)
updated_at = Column(String(30), nullable=False)

The from_domain() method (lines 2157–2167) also does not serialize automation:

model = cls(
    session_id=session.session_id,
    name=session.name,
    actor_name=session.actor_name,
    namespace=session.namespace,
    linked_plan_ids_json=json.dumps(session.linked_plan_ids),
    token_usage_json=token_usage_json,
    metadata_json=json.dumps(session.metadata),
    created_at=session.created_at.isoformat(),
    updated_at=session.updated_at.isoformat(),
)

The to_domain() method (lines 2126–2137) also does not restore automation.

Code Location

  • src/cleveragents/infrastructure/database/models.py, lines 2073–2174 (SessionModel)
  • src/cleveragents/infrastructure/database/repositories.py, lines 4172–4226 (SessionRepository.update())

Steps to Reproduce

  1. Create a session with an automation profile set in metadata
  2. Restart the process
  3. Load the session — automation field will be None

Impact

The automation field shown in agents session show output will always be None after a process restart, even if it was set during session creation.


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

## Bug Report **Feature Area:** Session Management — Session Persistence **Severity:** Backlog (automation profile association is a non-critical session attribute) ## What Was Tested Code-level analysis of: - `src/cleveragents/domain/models/core/session.py` — `Session` domain model - `src/cleveragents/infrastructure/database/models.py` — `SessionModel` database model ## Expected Behavior (from spec) Per `docs/specification.md` §`agents session show`, the session output includes an `Automation` field: ``` Session Summary ID: 01HXM2A6K1P2E9Q9D4GQ7J4S7Z Actor: local/orchestrator Messages: 6 Created: 2026-02-08 12:30 Updated: 2026-02-08 12:44 Automation: review ``` The `automation` field should be persisted and survive process restarts. ## Actual Behavior (from code) The `Session` domain model has an `automation` field (line 216 of `session.py`): ```python automation: str | None = Field( default=None, description="Automation profile name associated with this session", ) ``` However, the `SessionModel` database model (`infrastructure/database/models.py`, lines 2073–2081) does **not** include an `automation` column: ```python session_id = Column(String(26), primary_key=True) actor_name = Column(String(255), nullable=True) name = Column(String(255), nullable=True) namespace = Column(String(100), nullable=False, server_default="local") linked_plan_ids_json = Column(Text, nullable=True) token_usage_json = Column(Text, nullable=True) metadata_json = Column(Text, nullable=True) created_at = Column(String(30), nullable=False) updated_at = Column(String(30), nullable=False) ``` The `from_domain()` method (lines 2157–2167) also does not serialize `automation`: ```python model = cls( session_id=session.session_id, name=session.name, actor_name=session.actor_name, namespace=session.namespace, linked_plan_ids_json=json.dumps(session.linked_plan_ids), token_usage_json=token_usage_json, metadata_json=json.dumps(session.metadata), created_at=session.created_at.isoformat(), updated_at=session.updated_at.isoformat(), ) ``` The `to_domain()` method (lines 2126–2137) also does not restore `automation`. ## Code Location - `src/cleveragents/infrastructure/database/models.py`, lines 2073–2174 (`SessionModel`) - `src/cleveragents/infrastructure/database/repositories.py`, lines 4172–4226 (`SessionRepository.update()`) ## Steps to Reproduce 1. Create a session with an automation profile set in metadata 2. Restart the process 3. Load the session — `automation` field will be `None` ## Impact The `automation` field shown in `agents session show` output will always be `None` after a process restart, even if it was set during session creation. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium — The Session.automation field not being persisted is a data integrity bug. The spec requires the automation field to appear in agents session show output, which means it must survive process restarts. However, this is not blocking core functionality — sessions still work, just without the automation profile association being persisted.
  • Milestone: v3.3.0 — Session persistence is part of the session management feature set which is core to v3.3.0 (Corrections + Subplans + Checkpoints). The fix requires adding an automation column to SessionModel and updating from_domain()/to_domain() methods.
  • Story Points: 2 — S — Adding a column to the database model, updating serialization/deserialization, and writing a migration is a focused change, estimated 1-4 hours.
  • MoSCoW: MoSCoW/Should have — The spec shows the automation field in agents session show output. It should be persisted for correctness. Not blocking milestone delivery but should be fixed.
  • Parent Epic: Needs linking to Session Management Epic

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

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium — The `Session.automation` field not being persisted is a data integrity bug. The spec requires the `automation` field to appear in `agents session show` output, which means it must survive process restarts. However, this is not blocking core functionality — sessions still work, just without the automation profile association being persisted. - **Milestone**: v3.3.0 — Session persistence is part of the session management feature set which is core to v3.3.0 (Corrections + Subplans + Checkpoints). The fix requires adding an `automation` column to `SessionModel` and updating `from_domain()`/`to_domain()` methods. - **Story Points**: 2 — S — Adding a column to the database model, updating serialization/deserialization, and writing a migration is a focused change, estimated 1-4 hours. - **MoSCoW**: MoSCoW/Should have — The spec shows the `automation` field in `agents session show` output. It should be persisted for correctness. Not blocking milestone delivery but should be fixed. - **Parent Epic**: Needs linking to Session Management Epic --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner
HAL9000 added this to the v3.2.0 milestone 2026-04-09 10:22:33 +00:00
HAL9000 modified the milestone from v3.2.0 to v3.3.0 2026-04-09 10:27:49 +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#5808
No description provided.