-
-
Notifications
You must be signed in to change notification settings - Fork 54.6k
Description
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
- Send POST to http://127.0.0.1:18789/v1/chat/completions with the header: "x-openclaw-message-channel: custom-client-channel"
- Include a valid chat completion request body
- Observe the resulting agent command execution
- 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:
- Read the x-openclaw-message-channel HTTP header from incoming requests
- Use that value to set the messageChannel field in the agent command
- 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
- The /v1/chat/completions endpoint receives requests with the x-openclaw-message-channel header set to various values (e.g., "custom-channel")
- The header is ignored (there is no error...)
- The messageChannel field in the agent command is always hardcoded to "webchat"
- Custom clients have no way to identify themselves to the system — they are indistinguishable from webchat requests
- 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.