fix(cli): resolve session DB default against the data dir#3503
Merged
Conversation
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
Assisted-By: docker-agent
docker-agent
reviewed
Jul 7, 2026
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
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.
Sayt-0
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
--session-dbdefault forrun,serve a2a, andserve acpwas computed at flag-registration time as~/.cagent/session.db(usingpaths.GetHomeDir()), before the rootPersistentPreRunEapplied the--data-diroverride viapaths.SetDataDir. As a result,--data-dirnever 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 incmd/root/flags.golazily resolves it to<data-dir>/session.dbat command run time, after any directory overrides have been applied. An explicit--session-dbvalue still wins and~expansion is preserved.serve apikeeps its separate CWD-relativesession.dbdefault, unchanged.New regression tests in
cmd/root/session_db_test.gocover helper resolution, explicit-flag precedence, and wiring throughcreateSessionRequest. Docs indocs/features/cli/index.mdanddocs/features/acp/index.mdare updated to reflect the corrected defaults and the previously missing--session-dbrow in theserve a2atable.