fix(typecheck): 5 Pyright errors in session CLI and service — references to non-existent Session.automation_profile, SessionService.list_messages(), and invalid checksum concatenation #2109

Open
opened 2026-04-03 04:08:50 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: fix/session-typecheck-errors
  • Commit Message: fix(typecheck): resolve 5 Pyright errors in session CLI commands and session service
  • Milestone: v3.7.0
  • Parent Epic: #868

Problem

The nox -e typecheck quality gate fails with 5 Pyright errors on master. These errors are integration gaps introduced by multiple session-related PRs (#1566, #1567, #1569, #1481) that added CLI features referencing domain model attributes and service methods that do not exist.

Error 1–2: Invalid checksum string concatenation (session_service.py)

File: src/cleveragents/application/services/session_service.py

  • Line 263: checksum = "sha256:" + data.get("checksum")data.get("checksum") returns Any | None, and "sha256:" + None is a type error.
  • Line 268: data_without_checksum = "sha256:" + {k: v for k, v in data.items() if k != "checksum"} — concatenating a string literal with a dict is a type error.

These were introduced by PR #1481 (session export checksum stored with sha256 prefix per spec #1450). The logic is also semantically wrong — line 268 attempts to concatenate "sha256:" with a dict comprehension, which would raise a TypeError at runtime.

Error 3–4: Session.automation_profile does not exist (session.py)

File: src/cleveragents/cli/commands/session.py

  • Line 223: session.automation_profile or 'default' — the Session domain model (src/cleveragents/domain/models/core/session.py) has no automation_profile field.
  • Line 383: session.automation_profile or '(none)' — same issue.

The specification (session create and session show examples) shows an Automation field in the output, but the Session domain model was never updated to include automation_profile. PRs #1566 and #1567 added CLI rendering code that references this non-existent field.

Error 5: SessionService.list_messages() does not exist (session.py)

File: src/cleveragents/cli/commands/session.py

  • Line 493: messages = service.list_messages(session_id)SessionService (defined in src/cleveragents/domain/models/core/session.py) has no list_messages() method. The available methods are: create(), get(), list(), delete(), append_message(), export_session(), import_session(), update_token_usage().

This was introduced by PR #1569 (session delete rich output) which needs the message count before deletion.

Root Cause

Multiple session CLI PRs were implemented independently and assumed domain model fields/methods that were never created. The PRs passed lint but were not validated against nox -e typecheck before merge.

Impact

  • Blocks nox -e typecheck — the entire typecheck quality gate fails
  • Runtime crashes — lines 263 and 268 would raise TypeError at runtime if import_session() is called
  • Runtime crashes — lines 223 and 383 would raise AttributeError at runtime when showing/creating sessions

Subtasks

  • Add automation_profile: str | None field to the Session domain model, or derive it from the session's actor configuration
  • Fix session_service.py lines 263 and 268 to correctly handle the sha256 checksum prefix (handle None case, fix dict concatenation)
  • Either add list_messages() to SessionService or use session.messages directly in the delete command
  • Verify nox -e typecheck passes with zero errors
  • Verify nox -e unit_tests still passes (once #1609 is resolved)

Definition of Done

  • nox -e typecheck passes with zero errors
  • All session CLI commands work at runtime without AttributeError or TypeError
  • PR merged and this issue closed

Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-milestone-reviewer

## Metadata - **Branch**: `fix/session-typecheck-errors` - **Commit Message**: `fix(typecheck): resolve 5 Pyright errors in session CLI commands and session service` - **Milestone**: v3.7.0 - **Parent Epic**: #868 ## Problem The `nox -e typecheck` quality gate **fails with 5 Pyright errors** on master. These errors are integration gaps introduced by multiple session-related PRs (#1566, #1567, #1569, #1481) that added CLI features referencing domain model attributes and service methods that do not exist. ### Error 1–2: Invalid checksum string concatenation (session_service.py) **File**: `src/cleveragents/application/services/session_service.py` - **Line 263**: `checksum = "sha256:" + data.get("checksum")` — `data.get("checksum")` returns `Any | None`, and `"sha256:" + None` is a type error. - **Line 268**: `data_without_checksum = "sha256:" + {k: v for k, v in data.items() if k != "checksum"}` — concatenating a string literal with a `dict` is a type error. These were introduced by PR #1481 (session export checksum stored with sha256 prefix per spec #1450). The logic is also **semantically wrong** — line 268 attempts to concatenate `"sha256:"` with a dict comprehension, which would raise a `TypeError` at runtime. ### Error 3–4: Session.automation_profile does not exist (session.py) **File**: `src/cleveragents/cli/commands/session.py` - **Line 223**: `session.automation_profile or 'default'` — the `Session` domain model (`src/cleveragents/domain/models/core/session.py`) has no `automation_profile` field. - **Line 383**: `session.automation_profile or '(none)'` — same issue. The specification (session create and session show examples) shows an `Automation` field in the output, but the `Session` domain model was never updated to include `automation_profile`. PRs #1566 and #1567 added CLI rendering code that references this non-existent field. ### Error 5: SessionService.list_messages() does not exist (session.py) **File**: `src/cleveragents/cli/commands/session.py` - **Line 493**: `messages = service.list_messages(session_id)` — `SessionService` (defined in `src/cleveragents/domain/models/core/session.py`) has no `list_messages()` method. The available methods are: `create()`, `get()`, `list()`, `delete()`, `append_message()`, `export_session()`, `import_session()`, `update_token_usage()`. This was introduced by PR #1569 (session delete rich output) which needs the message count before deletion. ## Root Cause Multiple session CLI PRs were implemented independently and assumed domain model fields/methods that were never created. The PRs passed lint but were not validated against `nox -e typecheck` before merge. ## Impact - **Blocks `nox -e typecheck`** — the entire typecheck quality gate fails - **Runtime crashes** — lines 263 and 268 would raise `TypeError` at runtime if `import_session()` is called - **Runtime crashes** — lines 223 and 383 would raise `AttributeError` at runtime when showing/creating sessions ## Subtasks - [ ] Add `automation_profile: str | None` field to the `Session` domain model, or derive it from the session's actor configuration - [ ] Fix `session_service.py` lines 263 and 268 to correctly handle the sha256 checksum prefix (handle `None` case, fix dict concatenation) - [ ] Either add `list_messages()` to `SessionService` or use `session.messages` directly in the delete command - [ ] Verify `nox -e typecheck` passes with zero errors - [ ] Verify `nox -e unit_tests` still passes (once #1609 is resolved) ## Definition of Done - [ ] `nox -e typecheck` passes with zero errors - [ ] All session CLI commands work at runtime without `AttributeError` or `TypeError` - [ ] PR merged and this issue closed --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-milestone-reviewer
freemo added this to the v3.7.0 milestone 2026-04-03 04:09:09 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Critical (confirmed) — This blocks the typecheck quality gate on master. 5 Pyright errors including runtime crash scenarios (TypeError from string+None concatenation, AttributeError from missing Session.automation_profile). The typecheck gate is a hard requirement per CONTRIBUTING.md.
  • Milestone: v3.7.0 (confirmed — session CLI integration gaps)
  • MoSCoW: Must Have — The nox -e typecheck quality gate is a mandatory pass criterion for all work. A broken typecheck gate on master blocks all development. This must be fixed immediately.
  • Parent Epic: #868 (confirmed correct)

This is the highest-priority issue in the current backlog. It blocks the typecheck quality gate and causes runtime crashes in session CLI commands.


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

Issue triaged by project owner: - **State**: Verified - **Priority**: Critical (confirmed) — **This blocks the typecheck quality gate on master.** 5 Pyright errors including runtime crash scenarios (TypeError from string+None concatenation, AttributeError from missing Session.automation_profile). The typecheck gate is a hard requirement per CONTRIBUTING.md. - **Milestone**: v3.7.0 (confirmed — session CLI integration gaps) - **MoSCoW**: Must Have — The `nox -e typecheck` quality gate is a mandatory pass criterion for all work. A broken typecheck gate on master blocks all development. This must be fixed immediately. - **Parent Epic**: #868 (confirmed correct) **This is the highest-priority issue in the current backlog.** It blocks the typecheck quality gate and causes runtime crashes in session CLI commands. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

Fast-Tracked to State/Verified - Critical CI Blocker

Verification performed by: product-builder (aggressive mode)
Timestamp: 2026-04-03 04:15 UTC

This issue blocks the entire CI pipeline (typecheck gate). Manual verification confirms:

Problem statement clear: 5 specific Pyright errors identified with file/line references
Root cause identified: Integration gap from PRs #1566, #1567, #1569, #1481
Fix approach documented: Add missing fields, fix string concatenation, add service methods
Subtasks defined: Clear checklist with verification steps
DoD specified: Typecheck passes, no runtime crashes
Metadata complete: Branch name, commit message, milestone, epic

Fast-tracking to State/Verified to enable immediate implementation by implementor-pool-v2.


Automated by CleverAgents Bot
Supervisor: Product Builder | Agent: product-builder

## ✅ Fast-Tracked to State/Verified - Critical CI Blocker **Verification performed by**: product-builder (aggressive mode) **Timestamp**: 2026-04-03 04:15 UTC This issue blocks the entire CI pipeline (typecheck gate). Manual verification confirms: ✅ **Problem statement clear**: 5 specific Pyright errors identified with file/line references ✅ **Root cause identified**: Integration gap from PRs #1566, #1567, #1569, #1481 ✅ **Fix approach documented**: Add missing fields, fix string concatenation, add service methods ✅ **Subtasks defined**: Clear checklist with verification steps ✅ **DoD specified**: Typecheck passes, no runtime crashes ✅ **Metadata complete**: Branch name, commit message, milestone, epic **Fast-tracking to State/Verified** to enable immediate implementation by implementor-pool-v2. --- **Automated by CleverAgents Bot** Supervisor: Product Builder | Agent: product-builder
freemo self-assigned this 2026-04-03 16:58:06 +00:00
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#2109
No description provided.