Skip to content

[Bug]: /v1/chat/completions ignores x-openclaw-message-channel header #29449

@firebaker

Description

@firebaker

Summary

The /v1/chat/completions endpoint hardcodes messageChannel to "webchat" and ignores the x-openclaw-message-channel HTTP header, breaking channel identification for custom clients.

Steps to reproduce

  1. Send POST to http://127.0.0.1:18789/v1/chat/completions with the header: "x-openclaw-message-channel: custom-client-channel"
  2. Include a valid chat completion request body
  3. Observe the resulting agent command execution
  4. Inspect the resulting agent command — messageChannel will always be "webchat", never "custom-client-channel"

For comparison, /v1/tools/* endpoints in the same codebase correctly read the header and respect custom values.

Expected behavior

The /v1/chat/completions endpoint should:

  1. Read the x-openclaw-message-channel HTTP header from incoming requests
  2. Use that value to set the messageChannel field in the agent command
  3. Default to "webchat" if the header is missing or empty (backward compatibility)

This would make /v1/chat/completions consistent with /v1/tools/* endpoints, which already correctly read this header.

Actual behavior

  1. The /v1/chat/completions endpoint receives requests with the x-openclaw-message-channel header set to various values (e.g., "custom-channel")
  2. The header is ignored (there is no error...)
  3. The messageChannel field in the agent command is always hardcoded to "webchat"
  4. Custom clients have no way to identify themselves to the system — they are indistinguishable from webchat requests
  5. This is inconsistent with /v1/tools/* endpoints, which correctly read and respect the same header

OpenClaw version

2026.2.22-2/45febec

Operating system

Ubuntu 24.04

Install method

Installed via npm globally; Launched as systemd user service (openclaw-gateway.service)

Logs, screenshots, and evidence

**Source code evidence:**

File: src/gateway/openai-http.ts
Function: buildAgentCommandInput() (line ~45)

Current code shows hardcoded value:

messageChannel: "webchat" as const,

Impact and severity

Affected: users, systems, channels

  • Any custom client or integration that needs to be identified as a distinct channel to OpenClaw
  • Developers building HTTP-based clients that want proper channel detection
  • Anyone relying on messageChannel for channel-specific behavior or logging

Severity: Medium — Blocks workflow — custom clients cannot properly identify themselves to the system

Frequency: Always — every request to /v1/chat/completions is affected

Practical consequence:

  • Custom clients are indistinguishable from webchat, making channel-specific features impossible
  • Logging and analytics cannot track custom clients separately
  • Inconsistent with the tool endpoints, which creates confusion for developers
  • Breaks the intent of the x-openclaw-message-channel header mechanism

Workaround: Currently none. Custom clients either accept being labeled as "webchat" or must use the tool endpoints instead of the chat completions endpoint.

Additional information

The tool endpoints (/v1/tools/*) in the same codebase already implement the correct behavior of reading this header, suggesting this was an oversight in the chat completions endpoint rather than a design choice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions