Summary
AGENT_DATA_DIR currently defaults to /data/agents.
This works in Docker (with a mounted volume), but it breaks local non-container setups (especially macOS), where /data is often unavailable or read-only.
This causes runtime failures in endpoints that create directories under AGENT_DATA_DIR (example: enterprise knowledge base file listing/upload paths).
Problem
On local macOS development with no explicit AGENT_DATA_DIR override:
- The app falls back to
/data/agents.
- Code attempts
mkdir(parents=True, exist_ok=True) under /data/....
- The request fails with
OSError: [Errno 30] Read-only file system: '/data'.
- API returns
500 Internal Server Error.
Observed failing path:
/api/enterprise/knowledge-base/files
- Internally creates:
Path(settings.AGENT_DATA_DIR) / "enterprise_info"
Why this matters
- Fresh local setup can fail unexpectedly even before users upload files.
- The default is environment-specific (container-oriented) but used globally.
- This creates avoidable friction for contributors and local operators.
Proposed behavior
Resolve AGENT_DATA_DIR with environment-aware defaults:
- If
AGENT_DATA_DIR is explicitly set, always use it.
- If running in a container, default to
/data/agents (current behavior).
- Otherwise (local host), default to a user-writable path:
- Option A (simple and explicit):
~/.clawith/data/agents
- Option B (OS-conventional): use
platformdirs user data directory + /agents
Either option is fine; the key is avoiding a root-level path by default on host environments.
Additional recommendations
- Expand
~ safely (do not treat it as a literal string path).
- Ensure the directory is created on startup or first use with clear error reporting.
- Log the resolved
AGENT_DATA_DIR at startup for easier diagnostics.
- Update
.env.example and docs to clarify:
- local default path
- Docker path (
/data/agents) with volume mapping
- production recommendation (e.g.
/var/lib/clawith/agents when managed by ops)
Acceptance criteria
- Local macOS/Linux run with no
AGENT_DATA_DIR no longer writes to /data/....
GET /api/enterprise/knowledge-base/files?path= returns 200 (or expected empty list) on fresh local setup.
- Docker deployment behavior remains unchanged.
- Documentation reflects the new default resolution strategy.
Summary
AGENT_DATA_DIRcurrently defaults to/data/agents.This works in Docker (with a mounted volume), but it breaks local non-container setups (especially macOS), where
/datais often unavailable or read-only.This causes runtime failures in endpoints that create directories under
AGENT_DATA_DIR(example: enterprise knowledge base file listing/upload paths).Problem
On local macOS development with no explicit
AGENT_DATA_DIRoverride:/data/agents.mkdir(parents=True, exist_ok=True)under/data/....OSError: [Errno 30] Read-only file system: '/data'.500 Internal Server Error.Observed failing path:
/api/enterprise/knowledge-base/filesPath(settings.AGENT_DATA_DIR) / "enterprise_info"Why this matters
Proposed behavior
Resolve
AGENT_DATA_DIRwith environment-aware defaults:AGENT_DATA_DIRis explicitly set, always use it./data/agents(current behavior).~/.clawith/data/agentsplatformdirsuser data directory +/agentsEither option is fine; the key is avoiding a root-level path by default on host environments.
Additional recommendations
~safely (do not treat it as a literal string path).AGENT_DATA_DIRat startup for easier diagnostics..env.exampleand docs to clarify:/data/agents) with volume mapping/var/lib/clawith/agentswhen managed by ops)Acceptance criteria
AGENT_DATA_DIRno longer writes to/data/....GET /api/enterprise/knowledge-base/files?path=returns200(or expected empty list) on fresh local setup.