fix: standardize provider user agents with the AstrBot version by Soulter · Pull Request #10082 · AstrBotDevs/AstrBot · GitHub
Skip to content

fix: standardize provider user agents with the AstrBot version - #10082

Merged
Soulter merged 1 commit into
masterfrom
codex/provider-user-agent
Sep 14, 2026
Merged

Soulter merged 1 commit into
masterfrom
codex/provider-user-agent

Conversation

@Soulter

@Soulter Soulter commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Provider requests currently use SDK-specific or hardcoded user agents. Default built-in chat, speech, embedding, and reranking requests to astrbot/<version>, derived from astrbot.__version__. Preserve configured HTTP User-Agent overrides regardless of header casing, and remove hardcoded Claude Code headers from new coding-plan provider templates. Existing saved custom headers are preserved.

Cover both SDK clients and direct HTTP sessions, including SDK-specific handling for Gemini, DashScope, and Edge TTS. Gemini's generated duplicate header is removed after client initialization; Edge TTS uses its shared SDK synthesis-header default because it does not expose a per-client header option.

Validation: ruff format ., ruff check ., and 230 passing targeted Python tests. New tests capture local HTTP and WebSocket requests to verify exact default and custom user agents. External provider authentication and service acceptance were not exercised.

Summary by Sourcery

Standardize provider User-Agent headers around the current AstrBot version while retaining explicit user configuration.

Bug Fixes:

  • Standardize built-in provider request User-Agent headers to astrbot/<version> while preserving configured custom overrides regardless of header casing.
  • Remove hardcoded Claude Code User-Agent values from new coding-plan provider defaults.

Enhancements:

  • Apply consistent User-Agent handling across provider SDK clients, direct HTTP sessions, and Edge TTS WebSocket requests without mutating saved provider configuration.

Tests:

  • Add local HTTP and WebSocket coverage for default, custom, and duplicate User-Agent behavior across provider integrations.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @Soulter, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 days and 4 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

@Soulter
Soulter merged commit d524b87 into master Sep 14, 2026
24 checks passed
@Soulter
Soulter deleted the codex/provider-user-agent branch September 14, 2026 13:24
GuJi08233 added a commit to GuJi08233/AstrBot that referenced this pull request Sep 17, 2026
The StepFun ASR provider predates the provider user agent
standardization (AstrBotDevs#10082) and built its request headers from scratch,
so its requests carried aiohttp's default user agent and silently
ignored the custom_headers config.

Merge self.request_headers into the request, with the SSE protocol
headers (Content-Type, Accept, Authorization) applied last so a custom
Accept cannot break the stream.
BegoniaHe pushed a commit to Xero-Team/Zephirum that referenced this pull request Sep 17, 2026
…otDevs#10082)

Wire build_provider_headers into the fork provider sources, including
openai_chat_completions_source and openai_responses_source. Keep Edge TTS
as a lazy import. Tests live under tests/unit/provider/.

Upstream-Commit: d524b87
Upstream-Author: Soulter <37870767+Soulter@users.noreply.github.com>
Upstream-PR: AstrBotDevs#10082
Sync-Disposition: adapt
Fork-Adaptation: Map openai_source.py onto openai_chat_completions_source.py and openai_responses_source.py; keep Edge TTS importlib loading; omit missing dashscope embedding and TEI sources; tests under tests/unit/provider/.
Tested: uv run pytest tests/unit/provider/test_provider_user_agent.py tests/unit/provider/test_anthropic_kimi_code_provider.py tests/unit/provider/test_openai_chat_completions_source.py tests/unit/provider/test_openai_responses_source.py tests/unit/provider/test_openai_embedding_source.py tests/unit/provider/test_opencode_go_providers.py tests/unit/provider/test_ssycloud_source.py tests/unit/provider/test_mirarouter_source.py -q --test-profile blocking
AI-Generated: true
Generated-At: 2026-09-16T06:51:43Z
BegoniaHe added a commit to Xero-Team/Zephirum that referenced this pull request Sep 17, 2026
Record dispositions for bd046ed..ab42c0d: adapt AstrBotDevs#10082, AstrBotDevs#10069, AstrBotDevs#10084,
AstrBotDevs#10079, and AstrBotDevs#10071; cherry-pick AstrBotDevs#10046; skip AstrBotDevs#10085. Advance the cursor
to ab42c0d and note absorbed 4.28.1 changelog entries.

AI-Generated: true
Generated-At: 2026-09-16T07:05:28Z
buyun14 added a commit to buyun14/AstrBot that referenced this pull request Sep 17, 2026
… test

Upstream AstrBotDevs#10082 injects a versioned User-Agent into every provider's headers;
the PR AstrBotDevs#9852 assertion predates it and must account for the added header.
buyun14 added a commit to buyun14/AstrBot that referenced this pull request Sep 17, 2026
… test

Upstream AstrBotDevs#10082 injects a versioned User-Agent into every provider's headers;
the PR AstrBotDevs#9852 assertion predates it and must account for the added header.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant