openclaw - 💡(How to fix) Fix [Bug]: Malformed agent session key when spawning subagent via sessions_spawn [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#59605Fetched 2026-04-08 02:42:40
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Error Message

lane task error: lane=main durationMs=0 error="Error: Malformed agent session key; refusing workspace resolution." lane task error: lane=session:agent:agent-quant durationMs=7 error="Error: Malformed agent session key; refusing workspace resolution."

Root Cause

The subagent lane is being constructed as session:agent:agent-quant which is invalid:

  1. parseAgentSessionKey expects format: agent:<agentId>:<rest> (at least 3 parts starting with "agent:")
  2. The lane format session:agent:agent-quant starts with session: not agent:
  3. This causes classifySessionKeyShape to return "malformed_agent" and the error is thrown

Fix Action

Workaround

None found. The subagent functionality is currently broken for this configuration.

Code Example

Malformed agent session key; refusing workspace resolution.

---

lane task error: lane=main durationMs=0 error="Error: Malformed agent session key; refusing workspace resolution."
lane task error: lane=session:agent:agent-quant durationMs=7 error="Error: Malformed agent session key; refusing workspace resolution."

---

{
  "agents": {
    "list": [
      {
        "id": "main",
        "subagents": {
          "allowAgents": ["agent-electrical", "agent-quant", "agent-data", "agent-programmer", "agent-reviewer"]
        }
      },
      {
        "id": "agent-quant",
        "name": "量化助理",
        "workspace": "D:\openclawagent\quant",
        "model": {"primary": "bailian/qwen3-max-2026-01-23"}
      }
    ]
  },
  "tools": {
    "agentToAgent": {
      "enabled": true,
      "allow": ["main", "agent-electrical", "agent-quant", "agent-data", "agent-programmer", "agent-reviewer"]
    }
  }
}
RAW_BUFFERClick to expand / collapse

Bug Description

When the main agent calls sessions_spawn with agentId: "agent-quant" (or other subagent IDs), the subagent fails with:

Malformed agent session key; refusing workspace resolution.

Log Evidence

lane task error: lane=main durationMs=0 error="Error: Malformed agent session key; refusing workspace resolution."
lane task error: lane=session:agent:agent-quant durationMs=7 error="Error: Malformed agent session key; refusing workspace resolution."

Analysis

The subagent lane is being constructed as session:agent:agent-quant which is invalid:

  1. parseAgentSessionKey expects format: agent:<agentId>:<rest> (at least 3 parts starting with "agent:")
  2. The lane format session:agent:agent-quant starts with session: not agent:
  3. This causes classifySessionKeyShape to return "malformed_agent" and the error is thrown

Expected Behavior

Subagent spawned via sessions_spawn should use proper session key format like:

  • agent:main:subagent:<uuid> or
  • Lane should be subagent per CommandLane.Subagent

Environment

  • OpenClaw version: 2026.4.1
  • Node: 22.16.0
  • OS: Windows 10

Configuration

{
  "agents": {
    "list": [
      {
        "id": "main",
        "subagents": {
          "allowAgents": ["agent-electrical", "agent-quant", "agent-data", "agent-programmer", "agent-reviewer"]
        }
      },
      {
        "id": "agent-quant",
        "name": "量化助理",
        "workspace": "D:\openclawagent\quant",
        "model": {"primary": "bailian/qwen3-max-2026-01-23"}
      }
    ]
  },
  "tools": {
    "agentToAgent": {
      "enabled": true,
      "allow": ["main", "agent-electrical", "agent-quant", "agent-data", "agent-programmer", "agent-reviewer"]
    }
  }
}

Workaround

None found. The subagent functionality is currently broken for this configuration.

extent analysis

TL;DR

Update the lane construction to use the correct format, starting with "agent:" instead of "session:", to fix the malformed agent session key error.

Guidance

  • Verify that the parseAgentSessionKey function is correctly implemented and expects the format agent:<agentId>:<rest>.
  • Check the code that constructs the subagent lane and update it to use the correct format, such as agent:main:subagent:<uuid> or subagent per CommandLane.Subagent.
  • Review the configuration file to ensure that the subagent IDs are correctly specified and match the expected format.
  • Test the updated code with different subagent IDs to ensure that the issue is resolved.

Example

No code snippet is provided as the issue does not include the relevant code sections.

Notes

The issue seems to be related to the incorrect construction of the subagent lane, which causes the parseAgentSessionKey function to return an error. Updating the lane construction to use the correct format should resolve the issue.

Recommendation

Apply workaround by updating the lane construction to use the correct format, as the root cause of the issue is identified and a fix is possible.

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