Files
cleveragents-core/features/session_create_error.feature
T
Brent E. Edwards a58cfd7b6b
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 16s
CI / build (pull_request) Successful in 17s
CI / quality (pull_request) Successful in 18s
CI / security (pull_request) Successful in 37s
CI / typecheck (pull_request) Successful in 43s
CI / unit_tests (pull_request) Successful in 3m2s
CI / integration_tests (pull_request) Successful in 3m23s
CI / docker (pull_request) Successful in 40s
CI / coverage (pull_request) Successful in 6m27s
CI / benchmark-regression (pull_request) Successful in 33m46s
fix(cli): handle missing database in session list command
Add a 'db' Singleton provider to the DI Container class, backed by a
new _build_db_session_factory() helper that creates a shared SQLAlchemy
engine and sessionmaker.  This resolves the AttributeError raised when
_get_session_service() called container.db() on a container that had no
such provider.

Additional fixes in this commit:

- Ensure structlog routes through stdlib logging to stderr before
  accessing the DI container, preventing debug log lines from
  contaminating structured CLI output (JSON/YAML).

- Output valid JSON/YAML for empty session lists when --format is
  json or yaml (previously always printed plain text).

- Add db_session.commit() after flush in SessionRepository.create()
  so that newly created sessions are immediately visible to subsequent
  queries.

- Remove @tdd_expected_fail tags from all session list (bug #554) and
  session create (bug #570) test scenarios across Behave features and
  Robot Framework suites, since both bugs share the same root cause
  and are resolved by the container fix.

- Fix the session_list_error.feature 'plain output format' assertion
  to match actual plain-format output ('sessions:' instead of the
  Rich table title 'Sessions (').

ISSUES CLOSED: #554, #570
2026-03-11 19:18:33 +00:00

37 lines
1.8 KiB
Gherkin

# Regression tests for bug #570 — the DI container fix has been applied.
# These scenarios verify that `agents session create` works correctly through
# the real DI container path after `agents init`.
Feature: Session create command resolves DI container wiring
As a developer using the agents CLI
I want "agents session create" to work after a fresh init
So that I can create interactive sessions without a DI container error
Background:
Given a session-create-error CLI runner using the real DI path
@tdd_bug @tdd_bug_570
Scenario: Session create produces a new session
When I invoke session-create-error create with no arguments
Then the session-create-error command should exit successfully
And the session-create-error output should contain "session_id:"
@tdd_bug @tdd_bug_570
Scenario: Created session persists and can be retrieved
When I invoke session-create-error create with no arguments
Then the session-create-error command should exit successfully
When I invoke session-create-error list to verify persistence
Then the session-create-error list should show at least one session
@tdd_bug @tdd_bug_570
Scenario: Session create with custom actor succeeds
When I invoke session-create-error create with actor "openai/gpt-4"
Then the session-create-error command should exit successfully
And the session-create-error output should contain "openai/gpt-4"
And the session-create-error output should contain "session_id:"
@tdd_bug @tdd_bug_570
Scenario: Session create with arbitrary actor name succeeds
When I invoke session-create-error create with actor "nonexistent/bogus-actor-999"
Then the session-create-error command should exit successfully
And the session-create-error output should contain "nonexistent/bogus-actor-999"