agents session create causes an error. #570

Closed
opened 2026-03-04 23:18:38 +00:00 by brent.edwards · 9 comments
Member

Metadata

  • Commit Message: fix(cli): resolve DI container wiring for session create command
  • Branch: fix/m3-session-create-error

Background and Context

Running agents session create after a fresh agents init in a new environment causes an AttributeError: 'DynamicContainer' object has no attribute 'db'. This is the same root cause as #554 — the DI container is not properly wiring the database dependency.

Current Behavior

Running agents session create produces:

Wrapping unexpected exception: AttributeError: 'DynamicContainer' object has no attribute 'db'
Error [500] INTERNAL: An unexpected error occurred

Expected Behavior

agents session create should create a new session and return its details.

Acceptance Criteria

  • agents session create works without error after agents init
  • A new session is created and persisted
  • Session details are displayed in the requested output format

Definition of Done

This issue is complete when:

  • All subtasks below are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.

Subtasks

  • Code: Fix DI container wiring to ensure db attribute is available for session commands
  • Code: Verify session create command creates and persists session correctly
  • Code: This likely shares root cause with #554 — fix should address both
  • Docs: Update session CLI documentation if needed
  • Tests (Behave): Add features/session_create_error.feature covering: create, list after create, error handling
  • Tests (Robot): Add Robot integration scenario for session create lifecycle
  • Tests (ASV): Add benchmarks/session_create_bench.py for session create performance
  • Quality: Verify coverage >=97% via nox -s coverage_report. If coverage is <97% then review the current unit test coverage report at build/coverage.xml and use it to write new Behave based unit tests to improve code coverage.
  • Quality: Run nox (all default sessions, including benchmark), fix any errors if needed ensuring nox passes across entire code base.
## Metadata - **Commit Message**: `fix(cli): resolve DI container wiring for session create command` - **Branch**: `fix/m3-session-create-error` ## Background and Context Running `agents session create` after a fresh `agents init` in a new environment causes an `AttributeError: 'DynamicContainer' object has no attribute 'db'`. This is the same root cause as #554 — the DI container is not properly wiring the database dependency. ## Current Behavior Running `agents session create` produces: ``` Wrapping unexpected exception: AttributeError: 'DynamicContainer' object has no attribute 'db' Error [500] INTERNAL: An unexpected error occurred ``` ## Expected Behavior `agents session create` should create a new session and return its details. ## Acceptance Criteria - [ ] `agents session create` works without error after `agents init` - [ ] A new session is created and persisted - [ ] Session details are displayed in the requested output format ## Definition of Done This issue is complete when: - All subtasks below are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. ## Subtasks - [ ] Code: Fix DI container wiring to ensure `db` attribute is available for session commands - [ ] Code: Verify session create command creates and persists session correctly - [ ] Code: This likely shares root cause with #554 — fix should address both - [ ] Docs: Update session CLI documentation if needed - [ ] Tests (Behave): Add `features/session_create_error.feature` covering: create, list after create, error handling - [ ] Tests (Robot): Add Robot integration scenario for session create lifecycle - [ ] Tests (ASV): Add `benchmarks/session_create_bench.py` for session create performance - [ ] Quality: Verify coverage >=97% via `nox -s coverage_report`. If coverage is <97% then review the current unit test coverage report at `build/coverage.xml` and use it to write new Behave based unit tests to improve code coverage. - [ ] Quality: Run `nox` (all default sessions, including benchmark), fix any errors if needed ensuring nox passes across **entire** code base.
freemo added this to the v3.2.0 milestone 2026-03-05 00:29:34 +00:00
Author
Member

Root Cause Analysis

Same root cause as #554. _get_session_service() at src/cleveragents/cli/commands/session.py:65-66 calls container.db(), but the Container class in container.py has no db provider. The fix for #554 will fix this issue as well since both commands share the same _get_session_service() code path.

TDD PR

PR #595 adds intentionally-failing TDD tests:

  • 3 Behave BDD scenarios (@wip, @tdd, @bug570)
  • 2 Robot Framework integration smoke tests
  • ASV benchmark with track_create_persists tracker

Tests exercise the real _get_session_service() DI path by resetting _service = None and using a file-based SQLite database.

## Root Cause Analysis Same root cause as #554. `_get_session_service()` at `src/cleveragents/cli/commands/session.py:65-66` calls `container.db()`, but the `Container` class in `container.py` has no `db` provider. The fix for #554 will fix this issue as well since both commands share the same `_get_session_service()` code path. ## TDD PR PR #595 adds intentionally-failing TDD tests: - 3 Behave BDD scenarios (`@wip`, `@tdd`, `@bug570`) - 2 Robot Framework integration smoke tests - ASV benchmark with `track_create_persists` tracker Tests exercise the **real** `_get_session_service()` DI path by resetting `_service = None` and using a file-based SQLite database.
Owner

PM Acknowledgment — Day 25 Review

Confirmed — same root cause as #554 (_get_session_service() → missing db provider). The fix for #554 will resolve this issue as well.

Triage Notes

  • TDD PR #595 assigned to @CoreRasurae for review.
  • Fix ownership: @freemo — will be resolved by the same DI container fix as #554.
  • Both issues remain open as separate tickets (per user decision — distinct user-facing symptoms).
  • This issue will be retested and closed once the #554 fix merges.
## PM Acknowledgment — Day 25 Review Confirmed — same root cause as #554 (`_get_session_service()` → missing `db` provider). The fix for #554 will resolve this issue as well. ### Triage Notes - **TDD PR #595** assigned to @CoreRasurae for review. - **Fix ownership**: @freemo — will be resolved by the same DI container fix as #554. - Both issues remain open as separate tickets (per user decision — distinct user-facing symptoms). - This issue will be retested and closed once the #554 fix merges.
Owner

PM Note — Dependency Added

This bug fix is blocked by TDD issue #631 per the mandatory TDD workflow in CONTRIBUTING.md. The failing test scaffolding must be merged before the fix can proceed.

Dependencies:

  • Blocked by: #631 (TDD failing tests for session create)
  • Transitively blocked by: #627 (Behave @tdd_expected_fail tags), #628 (Robot tdd_expected_fail tags)

Note: PR #595 (by @brent.edwards) also contains TDD tests for this bug. #631 is the canonical tracking issue; #595 is the implementation PR.

**PM Note — Dependency Added** This bug fix is **blocked by** TDD issue #631 per the mandatory TDD workflow in CONTRIBUTING.md. The failing test scaffolding must be merged before the fix can proceed. **Dependencies:** - Blocked by: #631 (TDD failing tests for session create) - Transitively blocked by: #627 (Behave `@tdd_expected_fail` tags), #628 (Robot `tdd_expected_fail` tags) **Note:** PR #595 (by @brent.edwards) also contains TDD tests for this bug. #631 is the canonical tracking issue; #595 is the implementation PR.
Owner

PM Escalation (Day 31): This bug is STALLED.

Timeline:

  • TDD issue #631 was merged and closed.
  • TDD PRs #595 (Day 30) and #654 (Day 31) both merged by @brent.edwards — failing tests are in develop.
  • No bugfix/ branch exists on remote for the actual fix. 7+ days have passed since TDD tests were available.

Impact: This is Priority/Critical. Shares root cause with #554 (agents session list). Both are DI container errors — likely fixable in a single PR.

Action required: @brent.edwards — please push a bugfix/ branch with the fix. If this shares root cause with #554, a single PR closing both issues is preferred.

Deadline: Fix branch expected by end of Day 32 (2026-03-12).

**PM Escalation (Day 31)**: This bug is **STALLED**. **Timeline**: - TDD issue #631 was merged and closed. - TDD PRs #595 (Day 30) and #654 (Day 31) both merged by @brent.edwards — failing tests are in develop. - **No `bugfix/` branch exists on remote** for the actual fix. 7+ days have passed since TDD tests were available. **Impact**: This is `Priority/Critical`. Shares root cause with #554 (`agents session list`). Both are DI container errors — likely fixable in a single PR. **Action required**: @brent.edwards — please push a `bugfix/` branch with the fix. If this shares root cause with #554, a single PR closing both issues is preferred. **Deadline**: Fix branch expected by end of Day 32 (2026-03-12).
Author
Member

Implementation Notes

This issue shares the same root cause as #554 and is fixed by the same PR #680.

The _get_session_service() function (used by both session list and session create) called container.db() but the DI container had no db provider. The fix adds a db Singleton provider to the Container class, along with structlog routing and session commit fixes.

All 7 @tdd_expected_fail session create test scenarios now pass without the tag.

## Implementation Notes This issue shares the same root cause as #554 and is fixed by the same PR #680. The `_get_session_service()` function (used by both `session list` and `session create`) called `container.db()` but the DI container had no `db` provider. The fix adds a `db` Singleton provider to the Container class, along with structlog routing and session commit fixes. All 7 `@tdd_expected_fail` session create test scenarios now pass without the tag.
Owner

Escalation: Bug Fix Stalled — 2-Day Deadline

@brent.edwards This bug has had its TDD test merged for 7+ days (PRs #595, #654 merged) but no bugfix/ branch has been pushed to remote. Per CONTRIBUTING.md, bug fixes are never deferred across milestones and are always top priority.

Current state: TDD tests exist in features/session_create_error.feature (4 scenarios tagged @tdd_expected_fail). The tests are passing CI by inverting assertions, confirming the bug is captured. The fix should be straightforward and shares root cause with #554.

Root cause (previously identified): The session create CLI command fails because the DI container is missing the required db provider registration. Same fix as #554.

Deadline: Day 33 (2026-03-13). If no bugfix/ branch is pushed to remote by end of Day 33, this bug will be reassigned. M3 closure is blocked on this fix.

Action required:

  1. Fix together with #554 on branch bugfix/554-session-list-di (shared root cause)
  2. Remove @tdd_expected_fail tags from features/session_create_error.feature
  3. Push to remote and open PR

Recommend fixing #554 and #570 in a single commit since they share the same DI registration root cause.

## Escalation: Bug Fix Stalled — 2-Day Deadline @brent.edwards This bug has had its TDD test merged for **7+ days** (PRs #595, #654 merged) but **no `bugfix/` branch has been pushed to remote**. Per CONTRIBUTING.md, bug fixes are never deferred across milestones and are always top priority. **Current state**: TDD tests exist in `features/session_create_error.feature` (4 scenarios tagged `@tdd_expected_fail`). The tests are passing CI by inverting assertions, confirming the bug is captured. The fix should be straightforward and shares root cause with #554. **Root cause** (previously identified): The `session create` CLI command fails because the DI container is missing the required `db` provider registration. Same fix as #554. **Deadline: Day 33 (2026-03-13)**. If no `bugfix/` branch is pushed to remote by end of Day 33, this bug will be reassigned. M3 closure is blocked on this fix. **Action required**: 1. Fix together with #554 on branch `bugfix/554-session-list-di` (shared root cause) 2. Remove `@tdd_expected_fail` tags from `features/session_create_error.feature` 3. Push to remote and open PR Recommend fixing #554 and #570 in a single commit since they share the same DI registration root cause.
Owner

PM De-escalation — Day 31 (2026-03-11)

The escalation posted earlier today is withdrawn. @brent.edwards delivered PR #680 which fixes the shared _get_session_service() DI issue for both session create (#570) and session list (#554).

Current status:

  • PR #680 is open with all quality gates passing
  • All 4 TDD scenarios in features/session_create_error.feature pass in PR #680
  • PR has one review from @CoreRasurae — all 7 findings addressed by @brent.edwards

Remaining to close this issue:

  1. PR #680 needs merge approval
  2. After merge, verify @tdd_expected_fail tags are removed from features/session_create_error.feature
  3. Confirm all 4 TDD scenarios pass without the expected-fail tag

Note: Bug #570 body should reference TDD counterpart #631 for traceability.

## PM De-escalation — Day 31 (2026-03-11) The escalation posted earlier today is **withdrawn**. @brent.edwards delivered PR #680 which fixes the shared `_get_session_service()` DI issue for both `session create` (#570) and `session list` (#554). **Current status:** - PR #680 is open with all quality gates passing - All 4 TDD scenarios in `features/session_create_error.feature` pass in PR #680 - PR has one review from @CoreRasurae — all 7 findings addressed by @brent.edwards **Remaining to close this issue:** 1. PR #680 needs merge approval 2. After merge, verify `@tdd_expected_fail` tags are removed from `features/session_create_error.feature` 3. Confirm all 4 TDD scenarios pass without the expected-fail tag **Note:** Bug #570 body should reference TDD counterpart #631 for traceability.
Author
Member

Fix submitted in PR #723 (supersedes PR #680). This issue shared the same root cause as #554 — the DI Container had no session_service provider, causing AttributeError on agents session create. PR #723 registers the service properly and adds error handling to all session subcommands.

Fix submitted in PR #723 (supersedes PR #680). This issue shared the same root cause as #554 — the DI Container had no `session_service` provider, causing `AttributeError` on `agents session create`. PR #723 registers the service properly and adds error handling to all session subcommands.
Owner

PM Acknowledgment — Day 32

Confirmed. PR #723 has been formally APPROVED (Review ID 2167). Same root cause fix as #554 — both session DI errors resolved by the same PR.

PR #723 is mergeable and in the critical merge queue. Awaiting @freemo to merge.

Status: Fix verified. Merge imminent.

**PM Acknowledgment — Day 32** Confirmed. PR #723 has been formally **APPROVED** (Review ID 2167). Same root cause fix as #554 — both session DI errors resolved by the same PR. PR #723 is **mergeable** and in the critical merge queue. Awaiting @freemo to merge. **Status**: Fix verified. Merge imminent.
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.

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