-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Problem
The Pi adapter hardcodes the session directory to ~/.openclaw/agents/main/sessions/. This doesn't work for:
- Custom state directories — OpenClaw supports
OPENCLAW_STATE_DIRenv var to relocate the state directory (common for staging/production setups on the same machine, documented here) - Multi-agent setups — OpenClaw supports multiple named agents under
agents/<agentId>/sessions/(seedocs/pi.md), but the adapter only readsagents/main/
My setup
I run staging and production OpenClaw on the same VPS with separate state dirs and multiple agents:
$STAGING_STATE_DIR/agents/agent-a/sessions/ (8 sessions)
$STAGING_STATE_DIR/agents/main/sessions/ (17 sessions)
$PRODUCTION_STATE_DIR/agents/main/sessions/ (31 sessions)
The adapter finds none of these — it only reads ~/.openclaw/agents/main/sessions/.
Proposed Solution
Two small changes:
1. Respect OPENCLAW_STATE_DIR env var
func resolveBaseDir() string {
if dir := os.Getenv("OPENCLAW_STATE_DIR"); dir != "" {
return dir
}
home, _ := os.UserHomeDir()
return filepath.Join(home, ".openclaw")
}2. Scan agents/*/sessions/ instead of just agents/main/sessions/
// Glob all agent directories
entries, _ := os.ReadDir(filepath.Join(baseDir, "agents"))
for _, e := range entries {
sessDir := filepath.Join(baseDir, "agents", e.Name(), "sessions")
// add to watch list
}Impact
- CWD filtering still works correctly (each session has its own
cwdin the header) - The watcher watches all agent directories with
fsnotify - Session names remain unique (UUIDs)
- No API changes needed — just broader discovery
Usage
# Point sidecar at a specific OpenClaw instance
OPENCLAW_STATE_DIR=/path/to/state sidecarI've already built a working patch locally — happy to submit a PR if you'd prefer that. All 42 existing Pi adapter tests pass with the changes.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Projects
Status
Todo