Skip to content

fix(cli): resolve session DB default against the data dir#3503

Merged
Sayt-0 merged 2 commits into
docker:mainfrom
dgageot:fix/session-db-follows-data-dir
Jul 7, 2026
Merged

fix(cli): resolve session DB default against the data dir#3503
Sayt-0 merged 2 commits into
docker:mainfrom
dgageot:fix/session-db-follows-data-dir

Conversation

@dgageot

@dgageot dgageot commented Jul 7, 2026

Copy link
Copy Markdown
Member

The --session-db default for run, serve a2a, and serve acp was computed at flag-registration time as ~/.cagent/session.db (using paths.GetHomeDir()), before the root PersistentPreRunE applied the --data-dir override via paths.SetDataDir. As a result, --data-dir never relocated the session database: sessions were always read from and written to ~/.cagent/session.db, making past sessions stored under a custom data dir invisible.

The flag default is now empty. A new sessionDBPath() helper in cmd/root/flags.go lazily resolves it to <data-dir>/session.db at command run time, after any directory overrides have been applied. An explicit --session-db value still wins and ~ expansion is preserved. serve api keeps its separate CWD-relative session.db default, unchanged.

New regression tests in cmd/root/session_db_test.go cover helper resolution, explicit-flag precedence, and wiring through createSessionRequest. Docs in docs/features/cli/index.md and docs/features/acp/index.md are updated to reflect the corrected defaults and the previously missing --session-db row in the serve a2a table.

dgageot added 2 commits July 7, 2026 12:03
Baking the default at flag-registration time always produced
~/.cagent/session.db, ignoring --data-dir. The default is now resolved
lazily via sessionDBPath() so --data-dir is honoured.

Assisted-By: Claude
@dgageot dgageot requested a review from a team as a code owner July 7, 2026 10:25

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

The lazy sessionDBPath() helper correctly defers path resolution until after PersistentPreRunE has applied any --data-dir override. All three call-sites (run.go via payload.go, a2a.go, acp.go) route through the helper. Explicit --session-db values still take priority, ~ expansion is preserved, and unused imports are properly cleaned up. No logic errors, nil dereferences, race conditions, or security issues were found in the added code.

@aheritier aheritier added kind/fix PR fixes a bug (maps to fix:). Use on PRs only. area/cli CLI commands, flags, output formatting area/docs Documentation changes labels Jul 7, 2026
@Sayt-0 Sayt-0 merged commit 67dbc95 into docker:main Jul 7, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli CLI commands, flags, output formatting area/docs Documentation changes kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants