Skip to content

feat: honor --data-dir for prompt history and sandbox forwarding - #4496

Merged
dgageot merged 3 commits into
docker:mainfrom
dgageot:worktree-board-93772d1b0298d1e9
Oct 1, 2026
Merged

dgageot merged 3 commits into
docker:mainfrom
dgageot:worktree-board-93772d1b0298d1e9

Conversation

@dgageot

@dgageot dgageot commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

--data-dir previously only steered the agent's own data storage; prompt
history and the local sandbox kept using their own hardcoded defaults
(~/.cagent/history and the real home directory), so overriding the data
directory didn't fully isolate a run. This made it hard to run multiple
independent instances or test with a scratch directory without leftover
state leaking in from the real home.

Prompt history now resolves its history.json location, including
migration of any pre-existing file, from the selected data directory instead
of the hardcoded default, while still falling back to ~/.cagent/history
when no override is given. A DOCKER_AGENT_DATA_DIR environment variable is
now also honored, with precedence --data-dir flag over the env var over the
existing default; no legacy CAGENT_* alias was added. Leading ~ in
--data-dir is expanded to the home directory while preserving a literal
$ in the rest of the path, and the resolved override is forwarded to the
local sandbox, which canonicalizes it and enforces workspace containment,
including when the sandbox is launched implicitly via an ancestor flag
lookup.

Regression tests cover the new precedence rules, ~ expansion, history
migration, and sandbox forwarding, and the relevant docs
(docs/configuration/overview, docs/configuration/sandbox,
docs/features/cli, docs/features/sessions) were updated to describe the
new behavior.

Resolve the data dir through ExpandHomeDir so a quoted tilde from the
flag or env var works, and have the sandbox forward that same
resolved value through its existing containment checks instead of
ignoring env-only overrides.

Assisted-By: cagent
@dgageot
dgageot requested a review from a team as a code owner October 1, 2026 15:39
@dgageot
dgageot added this pull request to the merge queue Oct 1, 2026
@aheritier aheritier added area/core Core agent runtime, session management area/docs Documentation changes area/testing Test infrastructure, CI/CD, test runners, evaluation kind/feat PR adds a new feature (maps to feat:). Use on PRs only. labels Oct 1, 2026
Merged via the queue into docker:main with commit 7fa1d0f Oct 1, 2026
22 checks passed
@dgageot
dgageot deleted the worktree-board-93772d1b0298d1e9 branch October 1, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Core agent runtime, session management area/docs Documentation changes area/testing Test infrastructure, CI/CD, test runners, evaluation kind/feat PR adds a new feature (maps to feat:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants