Skip to content

Commit 02814db

Browse files
author
techartdev
committed
feat: update version to 0.5.60 and enhance session lock cleanup for non-default agents
1 parent dd6b7ec commit 02814db

3 files changed

Lines changed: 30 additions & 10 deletions

File tree

openclaw_assistant/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33
All notable changes to the OpenClaw Assistant Home Assistant Add-on will be documented in this file.
44

5+
## [0.5.60] - 2026-03-10
6+
7+
### Fixed
8+
- **Session lock cleanup ignored non-default agents**: `cleanup_session_locks` was hardcoded to `agents/main/sessions`, skipping stale locks for any agent with a custom `forcedAgentId`. Stale locks could block the gateway from opening sessions for those agents, causing silent fallback to `main`. Cleanup now scans all `agents/*/sessions/` directories.
9+
510
## [0.5.59] - 2026-03-10
611

712
### Fixed
813
- **Gateway restart loop** (issue #95): when the agent or user ran `openclaw gateway restart`, the supervisor loop detected the old PID exiting and immediately spawned a second gateway instance, which collided with the already-restarted one and looped with "another gateway instance is already listening". The supervisor now detects a self-restart (new PID already running on the same port) and re-tracks it instead of spawning a duplicate.
914
- **Remote mode URL not propagated** (issue #93): `start_openclaw_runtime` was reading `gateway.remote.url` back via `openclaw config get`, which can time out (2 s limit at startup) or return an empty/redacted result. The function now uses `$GATEWAY_REMOTE_URL` directly from the already-parsed add-on options, which is the same value the config helper writes to `openclaw.json`.
1015
- **Terminal CLI unreachable in tailnet mode** (issue #90): when `gateway_bind_mode=tailnet` (or `access_mode=tailnet_https`), the gateway binds only to the Tailscale IP. The local CLI always connects via `ws://127.0.0.1:PORT`, causing "Gateway not running" inside the add-on terminal. A lightweight loopback relay (Node.js) is now started automatically to forward `127.0.0.1:PORT → TAILSCALE_IP:PORT`, making all terminal CLI commands work normally. Token auth is still enforced end-to-end by the gateway.
16+
- **Session lock cleanup ignored non-default agents**: `cleanup_session_locks` was hardcoded to `agents/main/sessions`, skipping stale locks for any agent with a custom `forcedAgentId`. Stale locks could block the gateway from opening sessions for those agents, causing silent fallback to `main`. Cleanup now scans all `agents/*/sessions/` directories.
1117

1218
### Added
1319
- **MCP auto-configuration for Home Assistant**: new option `auto_configure_mcp` (default: `false`). When enabled and `homeassistant_token` is set, the add-on automatically registers Home Assistant as an MCP server (`mcporter config add HA ...`) on startup. Auto-detects the HA API URL (supervisor proxy or localhost:8123). Re-configures only when the token changes.

openclaw_assistant/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: OpenClaw Assistant
2-
version: "0.5.59"
2+
version: "0.5.60"
33
slug: openclaw_assistant
44
description: Run OpenClaw Assistant (OpenClaw-compatible) as a Home Assistant add-on.
55
url: https://github.com/techartdev/OpenClawHomeAssistant

openclaw_assistant/run.sh

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,9 @@ if [ ! -e /data ]; then
374374
ln -s /config /data || true
375375
fi
376376

377-
# Ensure these exist so cleanup doesn't fail
378-
mkdir -p /config/.openclaw/agents/main/sessions || true
377+
# Ensure the agents base directory exists so cleanup scans work even before first run.
378+
# Do NOT pre-create agent-specific directories; OpenClaw creates them as needed.
379+
mkdir -p /config/.openclaw/agents || true
379380

380381
# ------------------------------------------------------------------------------
381382
# SINGLE-INSTANCE GUARD (prevents multiple gateway runs racing each other)
@@ -397,26 +398,39 @@ gateway_running() {
397398
}
398399

399400
cleanup_session_locks() {
400-
local sessions_dir="/config/.openclaw/agents/main/sessions"
401-
local glob1="${sessions_dir}"/*.jsonl.lock
401+
local agents_dir="/config/.openclaw/agents"
402+
local total_locks=0
403+
local cleaned_dirs=()
402404

405+
# Scan all agent session directories, not just 'main'.
406+
# This is needed for users who have gateway.forcedAgentId set to a non-default agent.
403407
shopt -s nullglob
404-
local locks=( $glob1 )
408+
local all_locks=()
409+
for agent_sessions_dir in "${agents_dir}"/*/sessions; do
410+
local agent_locks=( "${agent_sessions_dir}"/*.jsonl.lock )
411+
if [ ${#agent_locks[@]} -gt 0 ]; then
412+
all_locks+=( "${agent_locks[@]}" )
413+
cleaned_dirs+=( "$agent_sessions_dir" )
414+
total_locks=$(( total_locks + ${#agent_locks[@]} ))
415+
fi
416+
done
405417
shopt -u nullglob
406418

407-
if [ ${#locks[@]} -eq 0 ]; then
419+
if [ "$total_locks" -eq 0 ]; then
408420
return 0
409421
fi
410422

411423
# If gateway is running, do NOT remove locks automatically (could be real).
412424
if gateway_running; then
413425
echo "INFO: Gateway appears to be running; leaving session lock files untouched."
414-
echo "INFO: Locks present: ${#locks[@]}"
426+
echo "INFO: Locks present: $total_locks"
415427
return 0
416428
fi
417429

418-
echo "INFO: Removing stale session lock files (${#locks[@]}) from ${sessions_dir}"
419-
rm -f "${sessions_dir}"/*.jsonl.lock || true
430+
echo "INFO: Removing stale session lock files ($total_locks) across agents: ${cleaned_dirs[*]}"
431+
for agent_sessions_dir in "${cleaned_dirs[@]}"; do
432+
rm -f "${agent_sessions_dir}"/*.jsonl.lock || true
433+
done
420434
}
421435

422436
if [ "$CLEAN_LOCKS_ON_START" = "true" ]; then

0 commit comments

Comments
 (0)