openclaw - 💡(How to fix) Fix bug: failed/errored ACP sessions not evicted from concurrent session count [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#61539Fetched 2026-04-08 02:57:35
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

When an ACP session fails (e.g., due to permission denial, ACPX config issues, or other errors), it is marked as failed in sessions.json but the in-memory concurrent session count is not decremented. This means failed sessions continue to count against acp.maxConcurrentSessions, causing subsequent spawn attempts to hit the cap even though no sessions are actually running.

Error Message

  1. Error: ACP max concurrent sessions reached (3/3) Failed/errored sessions should be automatically evicted from the concurrent session count. Any terminal state (done, failed, error) should decrement the count.

Root Cause

When an ACP session fails (e.g., due to permission denial, ACPX config issues, or other errors), it is marked as failed in sessions.json but the in-memory concurrent session count is not decremented. This means failed sessions continue to count against acp.maxConcurrentSessions, causing subsequent spawn attempts to hit the cap even though no sessions are actually running.

Fix Action

Fix / Workaround

  • Sessions in terminal states remain in the live count
  • The only workarounds are: manually clearing sessions.json, bumping maxConcurrentSessions, or restarting the gateway (which also doesn't reliably clear the count if sessions.json re-hydrates stale entries)
RAW_BUFFERClick to expand / collapse

Summary

When an ACP session fails (e.g., due to permission denial, ACPX config issues, or other errors), it is marked as failed in sessions.json but the in-memory concurrent session count is not decremented. This means failed sessions continue to count against acp.maxConcurrentSessions, causing subsequent spawn attempts to hit the cap even though no sessions are actually running.

Steps to Reproduce

  1. Set acp.maxConcurrentSessions: 3
  2. Spawn 3 ACP sessions that fail immediately (e.g., with permissionMode not configured, causing ACPX to block all write/exec operations)
  3. All 3 sessions fail and are marked failed in sessions.json
  4. Attempt to spawn a new ACP session
  5. Error: ACP max concurrent sessions reached (3/3)

Expected

Failed/errored sessions should be automatically evicted from the concurrent session count. Any terminal state (done, failed, error) should decrement the count.

Actual

  • Sessions in terminal states remain in the live count
  • The only workarounds are: manually clearing sessions.json, bumping maxConcurrentSessions, or restarting the gateway (which also doesn't reliably clear the count if sessions.json re-hydrates stale entries)

Impact

  • Agents that spawn ACP sessions in workflows can permanently exhaust the session pool after a series of failures
  • Requires manual operator intervention to recover

Environment

  • OpenClaw gateway
  • ACP backend: acpx
  • acp.maxConcurrentSessions: 3 (default)

extent analysis

TL;DR

Decrement the in-memory concurrent session count when an ACP session fails to prevent failed sessions from counting against the maximum concurrent sessions limit.

Guidance

  • Review the session management logic to ensure that failed sessions are properly removed from the in-memory count.
  • Consider implementing a mechanism to automatically evict failed sessions from the concurrent session count, such as a periodic cleanup task.
  • Verify that the sessions.json file is properly updated to reflect the terminal state of failed sessions.
  • Investigate the possibility of adding a retry mechanism or a timeout for failed sessions to prevent them from permanently occupying a session slot.

Example

No explicit code example is provided due to the lack of specific implementation details in the issue.

Notes

The provided guidance assumes that the issue is related to the session management logic and the in-memory count of concurrent sessions. Further investigation may be required to determine the root cause of the issue.

Recommendation

Apply a workaround, such as manually clearing sessions.json or implementing a periodic cleanup task, until a permanent fix can be developed and deployed. This is because the current behavior can lead to permanent exhaustion of the session pool, requiring manual operator intervention to recover.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING