feat: honor --data-dir for prompt history and sandbox forwarding - #4496
Merged
Merged
Conversation
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
gtardif
approved these changes
Oct 1, 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.
--data-dirpreviously only steered the agent's own data storage; prompthistory and the local sandbox kept using their own hardcoded defaults
(
~/.cagent/historyand the real home directory), so overriding the datadirectory 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.jsonlocation, includingmigration of any pre-existing file, from the selected data directory instead
of the hardcoded default, while still falling back to
~/.cagent/historywhen no override is given. A
DOCKER_AGENT_DATA_DIRenvironment variable isnow also honored, with precedence
--data-dirflag over the env var over theexisting default; no legacy
CAGENT_*alias was added. Leading~in--data-diris expanded to the home directory while preserving a literal$in the rest of the path, and the resolved override is forwarded to thelocal 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, historymigration, and sandbox forwarding, and the relevant docs
(
docs/configuration/overview,docs/configuration/sandbox,docs/features/cli,docs/features/sessions) were updated to describe thenew behavior.