[codex] add configurable user-agent for openai-compatible provider calls#222
Merged
[codex] add configurable user-agent for openai-compatible provider calls#222
Conversation
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses issue #216 (Alibaba Bailian / DashScope compatibility:
405 Method Not Allowedwhen validating/using OpenAI-compatible endpoints in MicroClaw).The likely provider-side gating condition in this case is that MicroClaw was sending some LLM-related HTTP requests without an explicit
User-Agent, while OpenClaw and other interactive clients typically send a product-identifying UA.This change adds a consistent User-Agent for MicroClaw OpenAI-compatible call paths and makes it overrideable for provider-specific troubleshooting.
Root Cause
MicroClaw OpenAI-compatible request paths used
reqwest::Client::new()in several places, which did not set an explicit MicroClaw UA string:src/llm.rs)src/setup.rs)/models apiprovider listing calls (src/chat_commands.rs)In contrast, OpenClaw codebase patterns include explicit
User-Agentusage across many network call paths.Changes
Added a shared helper in
src/http_client.rs:llm_user_agent()returns:MICROCLAW_LLM_USER_AGENTwhen set and non-emptyMicroClaw/<version> (+https://github.com/microclaw/microclaw)Wired this UA into OpenAI-compatible related call paths:
OpenAiProviderHTTP client insrc/llm.rssrc/setup.rssrc/chat_commands.rs(both anthropic and openai-compatible listing paths)Exported new module via
src/lib.rs.Added tests for default and override UA behavior in
src/http_client.rs.Validation
cargo fmtcargo test -q llm_user_agentImpact
MICROCLAW_LLM_USER_AGENTfor fast provider compatibility testing.Closes #216