openclaw - ✅(Solved) Fix [Bug]: sessions_spawn tool hardcodes channel names instead of using plugin metadata [1 pull requests, 2 comments, 2 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#56303Fetched 2026-04-08 01:42:31
View on GitHub
Comments
2
Participants
2
Timeline
8
Reactions
0
Author
Timeline (top)
referenced ×3commented ×2cross-referenced ×2labeled ×1

The sessions_spawn tool in pi-embedded-BaSvmUpW.js hardcodes channel-specific logic (e.g., opts?.agentChannel === "wechat"), requiring code modifications for each new channel (feishu, telegram, discord, etc.). This violates the open/closed principle and duplicates channel plugin metadata that already declares threading capabilities.

Error Message

// Error without thread=true: "status": "error", "error": "mode="session" requires thread=true so the subagent can stay bound to a thread."

Root Cause

The sessions_spawn tool in pi-embedded-BaSvmUpW.js hardcodes channel-specific logic (e.g., opts?.agentChannel === "wechat"), requiring code modifications for each new channel (feishu, telegram, discord, etc.). This violates the open/closed principle and duplicates channel plugin metadata that already declares threading capabilities.

Fix Action

Fix / Workaround

  1. Configure Feishu channel in openclaw.json
  2. Send message to Feishu bot: "帮我写个代码"
  3. Main agent calls: sessions_spawn({ agentId: "coder", mode: "run" })
  4. Without explicit thread: true, subagent creation fails
  5. Current workaround requires hardcoding "feishu" check in core code

// Success with manual workaround: { "status": "accepted", "childSessionKey": "agent:coder:subagent:xxx", "modelApplied": true }


Workaround exists but suboptimal (hardcoding channel names).

PR fix notes

PR #56334: delete

Description (problem / solution / changelog)

delete

Changed files

  • 2026-03-28.md (added, +384/-0)
  • AGENTS.md (modified, +21/-0)
  • extensions/ollama/src/provider-models.ts (modified, +3/-0)
  • extensions/telegram/src/bot-native-commands.test.ts (modified, +61/-0)
  • extensions/telegram/src/bot-native-commands.ts (modified, +4/-1)
  • src/agents/command/session.ts (modified, +11/-0)
  • src/agents/pi-tools.read.media-url.test.ts (added, +130/-0)
  • src/agents/pi-tools.read.ts (modified, +40/-5)
  • src/channels/conversation-binding-context.ts (modified, +9/-2)
  • src/channels/thread-bindings-policy.ts (modified, +26/-0)
  • src/config/sessions/store-validation.test.ts (added, +151/-0)
  • src/config/sessions/store-validation.ts (added, +81/-0)
  • src/config/sessions/store.ts (modified, +15/-1)

Code Example

const isFeishuChannel = opts?.agentChannel === "feishu";
const thread = params.thread === true || (isFeishuChannel && runtime === "subagent");

This requires:

Modifying core code for each new channel
Maintaining hardcoded channel name lists
LLM prompts must include technical details like "飞书渠道必须添加 thread: true"


### OpenClaw version

2026.3.24

### Operating system

Linux (tested on Ubuntu 24.04)

### Install method

npm install -g openclaw

### Model

local/qwen3.5:9b (main agent) coding-plan/glm-5 (Coder expert)

### Provider / routing chain

Feishu channel → Main agent (qwen3.5:9b) → sessions_spawn → Coder subagent (GLM-5)

### Additional provider/model setup details

_No response_

### Logs, screenshots, and evidence
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

The sessions_spawn tool in pi-embedded-BaSvmUpW.js hardcodes channel-specific logic (e.g., opts?.agentChannel === "wechat"), requiring code modifications for each new channel (feishu, telegram, discord, etc.). This violates the open/closed principle and duplicates channel plugin metadata that already declares threading capabilities.

Steps to reproduce

  1. Configure Feishu channel in openclaw.json
  2. Send message to Feishu bot: "帮我写个代码"
  3. Main agent calls: sessions_spawn({ agentId: "coder", mode: "run" })
  4. Without explicit thread: true, subagent creation fails
  5. Current workaround requires hardcoding "feishu" check in core code

Expected behavior

The framework should automatically inject thread: true and mode: "session" for channels that declare this requirement in their plugin configuration, without hardcoding channel names in core code.

Main agent should only specify business logic (which expert to call), not technical implementation details.

Actual behavior

Current implementation (line 112131 in pi-embedded-BaSvmUpW.js):

const isFeishuChannel = opts?.agentChannel === "feishu";
const thread = params.thread === true || (isFeishuChannel && runtime === "subagent");

This requires:

Modifying core code for each new channel
Maintaining hardcoded channel name lists
LLM prompts must include technical details like "飞书渠道必须添加 thread: true"


### OpenClaw version

2026.3.24

### Operating system

Linux (tested on Ubuntu 24.04)

### Install method

npm install -g openclaw

### Model

local/qwen3.5:9b (main agent) coding-plan/glm-5 (Coder expert)

### Provider / routing chain

Feishu channel → Main agent (qwen3.5:9b) → sessions_spawn → Coder subagent (GLM-5)

### Additional provider/model setup details

_No response_

### Logs, screenshots, and evidence

```shell
Feishu enterprise self-built app
WebSocket event subscription enabled
dmPolicy: pairing
Subagents configured: analyst, coder, researcher, generalist, planner

### Logs, screenshots, and evidence

// Current hardcoded implementation (pi-embedded-BaSvmUpW.js:112131)
const isFeishuChannel = opts?.agentChannel === "feishu";
const effectiveMode = isFeishuChannel && runtime === "subagent" ? "session" : mode;
const thread = params.thread === true || (isFeishuChannel && runtime === "subagent");

// Error without thread=true:
{
  "status": "error",
  "error": "mode=\"session\" requires thread=true so the subagent can stay bound to a thread."
}

// Success with manual workaround:
{
  "status": "accepted",
  "childSessionKey": "agent:coder:subagent:xxx",
  "modelApplied": true
}

Impact and severity

Severity: Medium

Impact:

  • Architectural debt - violates separation of concerns
  • Maintenance burden - each new channel requires core code changes
  • LLM confusion - models must remember channel-specific technical details
  • Prompt pollution - SOUL.md cluttered with implementation details
  • Not scalable - wechat, telegram, discord all need similar logic

Workaround exists but suboptimal (hardcoding channel names).

Additional information

Related files:

  • packages/pi-embedded/src/pi-embedded-BaSvmUpW.js (line ~112131)
  • packages/extensions/feishu/src/index.js (plugin definition)
  • packages/plugin-sdk/src/channel-plugin.ts (plugin schema)

Channel plugins already declare capabilities.threads: true but this metadata is not used by sessions_spawn tool.

Similar pattern exists for replyToMode resolution which correctly reads channel plugin config.

extent analysis

Fix Plan

To address the issue, we need to modify the sessions_spawn tool to automatically inject thread: true and mode: "session" for channels that declare this requirement in their plugin configuration.

Step-by-Step Solution

  1. Load channel plugin metadata: In pi-embedded-BaSvmUpW.js, load the channel plugin metadata from the openclaw.json configuration file.
  2. Check threading capability: Check if the channel plugin declares capabilities.threads: true.
  3. Inject thread and mode: If the channel plugin declares threading capability, inject thread: true and mode: "session" into the sessions_spawn parameters.

Example Code

// Load channel plugin metadata
const channelPlugin = getChannelPluginMetadata(opts.agentChannel);

// Check threading capability
const threadingCapability = channelPlugin.capabilities.threads;

// Inject thread and mode if necessary
const thread = params.thread === true || (threadingCapability && runtime === "subagent");
const effectiveMode = threadingCapability && runtime === "subagent" ? "session" : mode;

Verification

To verify the fix, follow these steps:

  1. Configure a channel (e.g., Feishu) in openclaw.json with capabilities.threads: true.
  2. Send a message to the channel bot.
  3. Call sessions_spawn with the channel agent ID and mode.
  4. Verify that the subagent is created successfully without requiring thread: true in the input parameters.

Extra Tips

  • Ensure that all channel plugins declare their threading capabilities correctly in their metadata.
  • Consider adding validation for channel plugin metadata to prevent incorrect configurations.
  • Review other parts of the codebase for similar patterns and apply the same fix to ensure consistency and scalability.

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…

FAQ

Expected behavior

The framework should automatically inject thread: true and mode: "session" for channels that declare this requirement in their plugin configuration, without hardcoding channel names in core code.

Main agent should only specify business logic (which expert to call), not technical implementation details.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: sessions_spawn tool hardcodes channel names instead of using plugin metadata [1 pull requests, 2 comments, 2 participants]