Skip to content

fix(cron): preserve channel ID case in MCP loopback delivery context (#75261)#75303

Closed
hclsys wants to merge 1 commit into
openclaw:mainfrom
hclsys:fix/75261-mcp-loopback-cron-lowercase-channelid
Closed

fix(cron): preserve channel ID case in MCP loopback delivery context (#75261)#75303
hclsys wants to merge 1 commit into
openclaw:mainfrom
hclsys:fix/75261-mcp-loopback-cron-lowercase-channelid

Conversation

@hclsys

@hclsys hclsys commented Apr 30, 2026

Copy link
Copy Markdown

Summary

Fixes #75261 — cron jobs created via mcp__openclaw__cron action=add with sessionTarget=current from a Claude CLI subprocess (MCP loopback path) stored a lowercased Matrix room ID in delivery.to, causing M_UNKNOWN: non-create event for room of unknown version [500] on every cron run.

Root cause: The MCP loopback tool resolution path (resolveGatewayScopedTools called from McpLoopbackToolCache) had no currentChannelId. The cron tool fell back to inferDeliveryFromSessionKey, which passes the session key through parseAgentSessionKeynormalizeOptionalLowercaseString → lowercase.

The fix from #71798 (inferDeliveryFromContext) already preserves the channel ID correctly, but only activates when currentChannelId is populated. This PR threads the case-sensitive channel ID through the entire loopback pipeline:

  1. RunCliAgentParams.currentChannelId (new field)
  2. OPENCLAW_MCP_CURRENT_CHANNEL_ID env var → x-openclaw-current-channel-id header
  3. McpRequestContext.currentChannelId (parsed from header, not normalized to lowercase)
  4. McpLoopbackToolCache.resolveresolveGatewayScopedToolscreateOpenClawTools

Test plan

  • New regression test: x-openclaw-current-channel-id header with mixed-case Matrix room ID is passed unchanged to resolveGatewayScopedTools (currentChannelId: "!c9p9XFWiH5Szl4yZiP:matrix.example")
  • Existing createMcpLoopbackServerConfig test updated to assert the new header template is present
  • 60/60 mcp-http.test.ts tests pass; 1799/1799 gateway tests pass

🤖 Generated with Claude Code

…penclaw#75261)

Thread the inbound x-openclaw-current-channel-id header through the MCP
loopback request context into resolveGatewayScopedTools and on to the
cron tool's currentDeliveryContext. Without this, the loopback path had
no currentChannelId so inferDeliveryFromSessionKey fell back, which
runs the session key through parseAgentSessionKey (normalizeOptionalLowercaseString)
and lowercases the Matrix room ID in cron delivery.to.

Adds regression test: x-openclaw-current-channel-id header preserved
case-sensitively through to tool resolution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: XS r: too-many-prs Auto-close: author has more than twenty active PRs. labels Apr 30, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because the author has more than 10 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime r: too-many-prs Auto-close: author has more than twenty active PRs. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: cron with sessionTarget=current still lowercases Matrix roomId in 2026.4.27 (regression of #71798 via MCP loopback path)

1 participant