openclaw - ✅(Solved) Fix ACP_SESSION_INIT_FAILED for gemini: sessions ensure/new returns no valid session id [2 pull requests, 4 comments, 4 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#43667Fetched 2026-04-08 00:16:31
View on GitHub
Comments
4
Participants
4
Timeline
7
Reactions
0
Author
Timeline (top)
commented ×4cross-referenced ×2subscribed ×1

ACP session init fails for gemini harness: neither sessions ensure nor sessions new returns valid session identifiers.

Error Message

ACP error (ACP_SESSION_INIT_FAILED): ACP session init failed: neither 'sessions ensure' nor 'sessions new' returned valid session identifiers for agent:gemini:acp:93eb6e87-7b86-428d-8087-6e0e06a6c3b8.

Root Cause

ACP session init fails for gemini harness: neither sessions ensure nor sessions new returns valid session identifiers.

Fix Action

Fixed

PR fix notes

PR #44124: Improve ACP spawn and timeout diagnostics

Description (problem / solution / changelog)

Summary

  • add a reusable ACP diagnostic formatter that preserves nested stderr/stdout/cause details
  • log richer context when sessions_spawn(runtime=\"acp\") fails during ACP session initialization
  • include last tool error and recent message targets in embedded run timeout logs

Why

Several current ACP/session issues are hard to debug from gateway logs because failures collapse down to generic strings like ACP_SESSION_INIT_FAILED, acpx exited with code 1, or a bare embedded timeout line.

This does not change runtime behavior or routing. It makes the failure path observable enough to diagnose workspace/cwd mismatches, backend stderr, and timeout context without reproducing everything interactively.

Related

  • #43667
  • #43661

Testing

  • corepack pnpm vitest run src/acp/runtime/errors.test.ts src/agents/acp-spawn.test.ts

AI assistance

AI-assisted. I reviewed and tested the patch locally.

Changed files

  • src/acp/runtime/errors.test.ts (modified, +40/-1)
  • src/acp/runtime/errors.ts (modified, +96/-0)
  • src/agents/acp-spawn.ts (modified, +5/-0)
  • src/agents/pi-embedded-runner/run/attempt.ts (modified, +24/-1)

PR #44151: Improve ACP spawn and timeout diagnostics

Description (problem / solution / changelog)

Summary

  • add reusable ACP diagnostic helpers that preserve nested stderr/stdout/cause details in log output
  • log richer context when sessions_spawn(runtime="acp") fails during ACP session initialization
  • include last tool error and recent message targets in embedded run timeout logs
  • carry forward the latest generated Swift protocol models required by current main
  • keep config help-label coverage in sync for the current gateway.push* fields
  • preserve falsy primitive ACP causes like 0 and false in diagnostic output

Why

Several current ACP/session issues are hard to debug from gateway logs because failures collapse down to generic strings like ACP_SESSION_INIT_FAILED, acpx exited with code 1, or a bare embedded timeout line.

This patch does not change ACP runtime behavior or routing. It makes the failure path observable enough to diagnose workspace/cwd mismatches, backend stderr, and timeout context without reproducing everything interactively.

The Swift protocol update and config help-label adjustment are carry-forward fixes needed to keep the PR green against the latest main.

Related

  • #43667
  • #43661

Testing

  • pnpm vitest run src/acp/runtime/errors.test.ts src/agents/acp-spawn.test.ts src/config/schema.help.quality.test.ts
  • pnpm protocol:check
  • pnpm check (local run hit existing unrelated format issues in ui/src/styles/chat/grouped.css, ui/src/styles/chat/layout.css, and ui/src/styles/layout.css)

AI assistance

AI-assisted. I reviewed and tested the patch locally.

Changed files

  • apps/macos/Sources/OpenClawProtocol/GatewayModels.swift (modified, +5/-1)
  • apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift (modified, +5/-1)
  • src/acp/runtime/errors.test.ts (modified, +57/-1)
  • src/acp/runtime/errors.ts (modified, +98/-0)
  • src/agents/acp-spawn.ts (modified, +5/-0)
  • src/agents/pi-embedded-runner/run/attempt.ts (modified, +24/-1)
  • src/config/schema.labels.ts (modified, +5/-5)
  • src/config/sessions/targets.test.ts (modified, +9/-10)
  • ui/src/styles/chat/grouped.css (modified, +10/-7)
  • ui/src/styles/chat/layout.css (modified, +3/-1)
  • ui/src/styles/layout.css (modified, +4/-4)

Code Example

{
  "acp": {
    "enabled": true,
    "backend": "acpx",
    "defaultAgent": "gemini",
    "allowedAgents": ["gemini"]
  },
  "plugins": {
    "entries": {
      "acpx": {
        "enabled": true
      }
    }
  }
}

---

/acp spawn gemini --mode oneshot --thread off --cwd /home/sd4142395/.openclaw/workspace --label gemini-clean-2

---

ACP error (ACP_SESSION_INIT_FAILED): ACP session init failed: neither 'sessions ensure' nor 'sessions new' returned valid session identifiers for agent:gemini:acp:93eb6e87-7b86-428d-8087-6e0e06a6c3b8.
next: If this session is stale, recreate it with /acp spawn and rebind the thread.
RAW_BUFFERClick to expand / collapse

Summary

ACP session init fails for gemini harness: neither sessions ensure nor sessions new returns valid session identifiers.

Environment

  • OpenClaw: 2026.3.8 (3caab92)
  • OS: Linux x64
  • Channel: Telegram direct chat
  • Gemini CLI binary is installed and works locally (gemini --version and one-shot prompt both succeed).

ACP config (minimal)

{
  "acp": {
    "enabled": true,
    "backend": "acpx",
    "defaultAgent": "gemini",
    "allowedAgents": ["gemini"]
  },
  "plugins": {
    "entries": {
      "acpx": {
        "enabled": true
      }
    }
  }
}

Repro command

/acp spawn gemini --mode oneshot --thread off --cwd /home/sd4142395/.openclaw/workspace --label gemini-clean-2

Expected

  • ACP session is created for gemini
  • a usable ACP session identifier is returned

Actual

ACP error (ACP_SESSION_INIT_FAILED): ACP session init failed: neither 'sessions ensure' nor 'sessions new' returned valid session identifiers for agent:gemini:acp:93eb6e87-7b86-428d-8087-6e0e06a6c3b8.
next: If this session is stale, recreate it with /acp spawn and rebind the thread.

Also reproduced with:

  • agent:gemini:acp:329d6212-3b3a-4a52-a767-af2dc8d78652

Notes

  • This does not look like a harness binary issue (local gemini CLI path works).
  • Seems to be ACP session-init path incompatibility/non-conforming return payload from sessions ensure/new.

extent analysis

Fix Plan

The issue seems to be related to the ACP session initialization failure. To fix this, we need to modify the ACP configuration and ensure that the sessions ensure and sessions new commands return valid session identifiers.

Code Changes

We can try to modify the ACP configuration to use a different backend or modify the existing backend configuration. Here is an example of how to modify the ACP configuration:

{
  "acp": {
    "enabled": true,
    "backend": "acpx",
    "defaultAgent": "gemini",
    "allowedAgents": ["gemini"],
    "sessionInitRetry": 3,
    "sessionInitTimeout": 30000
  },
  "plugins": {
    "entries": {
      "acpx": {
        "enabled": true,
        "sessionEnsureCmd": "sessions ensure --retry 3 --timeout 30000",
        "sessionNewCmd": "sessions new --retry 3 --timeout 30000"
      }
    }
  }
}

In the above example, we have added sessionInitRetry and sessionInitTimeout properties to the ACP configuration to retry the session initialization with a timeout. We have also modified the sessionEnsureCmd and sessionNewCmd properties to include retry and timeout options.

Verification

To verify that the fix worked, you can try running the /acp spawn command again with the modified ACP configuration. If the session initialization is successful, you should see a valid session identifier returned.

Extra Tips

  • Make sure to restart the OpenClaw service after modifying the ACP configuration.
  • You can also try increasing the retry count and timeout values to see if it resolves the issue.
  • If the issue persists, you can try enabling debug logging for the ACP plugin to see more detailed error messages.

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