Skip to content

Bug: ACP Claude run accepted but child session history stays empty after env is fixed #38565

@robo7

Description

@robo7

Summary

session_spawn(runtime="acp", agentId="claude", mode="run") is accepted, but the child ACP session history stays empty and no result is written back.

In our environment, direct acpx -> claude works, and Claude/AnyRouter auth is already correctly configured. The remaining failure appears to be in OpenClaw ACP run-mode result persistence / readback for Claude.

Environment

  • OpenClaw: 2026.3.2
  • Node: 22.22.0
  • OS: Linux x64 (Ubuntu)
  • acpx backend: bundled plugin-local acpx
  • Claude Code: 2.1.62
  • Claude routing: AnyRouter via
    • ANTHROPIC_AUTH_TOKEN
    • ANTHROPIC_BASE_URL=https://anyrouter.top

What works

1) Direct Claude Code CLI

Running local claude with the same AnyRouter env works.

2) Direct acpx -> claude

Running acpx claude exec 'Reply with exactly ACPX_OK' works when the same Anthropic env is present.

3) Gateway service env is correct

We persisted the Claude/AnyRouter env into the openclaw-gateway systemd user service and confirmed the running gateway process includes:

  • ANTHROPIC_AUTH_TOKEN
  • ANTHROPIC_BASE_URL
  • MAX_THINKING_TOKENS
  • CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS
  • CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC
  • CLAUDE_CODE_ATTRIBUTION_HEADER

What fails

Using sessions_spawn with ACP Claude one-shot run:

{
  "task": "Reply with exactly: ACP_CLAUDE_OK",
  "runtime": "acp",
  "agentId": "claude",
  "mode": "run",
  "cwd": "/home/ubuntu/.openclaw/workspace",
  "timeoutSeconds": 300
}

Response is accepted, e.g.:

{
  "status": "accepted",
  "childSessionKey": "agent:claude:acp:<uuid>",
  "runId": "<uuid>",
  "mode": "run",
  "note": "initial ACP task queued in isolated session; follow-ups continue in the bound thread."
}

But then:

  • sessions_history(childSessionKey) returns an empty message list
  • no assistant output is ever visible
  • no usable child result is written back

Additional observations

Earlier failure mode

Before fixing gateway env inheritance for Claude/AnyRouter, gateway logs showed:

  • AcpRuntimeError: acpx exited with code 1
  • code=ACP_TURN_FAILED

That part is now fixed by persisting Anthropic env into the gateway service.

Current failure mode

After env fix + killing lingering claude processes + restarting gateway:

  • ACP Claude runs are still accepted
  • but sessions_history remains empty
  • and we no longer see the previous ACP_TURN_FAILED / acpx exited with code 1 error

So the remaining issue looks more like:

  • ACP mode:"run" accepted the task
  • but result persistence / assistant reply readback for Claude never lands in the child session history

Likely direction

While debugging the built code, it looks like ACP spawn/run flow differs from native subagent flow:

  • subagent path explicitly registers run state and has result readback helpers
  • ACP path appears to return accepted after dispatching the agent message, but result visibility for Claude run-mode may be incomplete / broken in this path

This may be:

  1. a Claude-specific ACP runtime integration bug,
  2. a run-mode result writeback bug,
  3. or a related regression around ACP child session history population.

Related issue

This may be related to #28786, but our current symptom is slightly different:

  • not just immediate ACP_TURN_FAILED
  • now the task is accepted, yet child session history stays empty

Repro steps

  1. Configure ACP backend acpx
  2. Ensure agentId="claude" is allowed
  3. Persist Anthropic/Claude env into the openclaw-gateway service
  4. Restart gateway
  5. Call sessions_spawn(runtime="acp", agentId="claude", mode="run")
  6. Inspect returned childSessionKey
  7. Call sessions_history(childSessionKey)

Actual result

Accepted ACP Claude run, but empty child history and no assistant result.

Expected result

The child ACP Claude session should contain assistant output, and one-shot run results should be readable from session history / normal result plumbing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions