fix: use OpenAI default_headers for Kimi User-Agent#67
Conversation
The httpx Client headers were being overwritten by the OpenAI SDK's own User-Agent. Using default_headers on the OpenAI client ensures the header reaches Kimi's agent whitelist check. Verified: full pipeline run succeeds with real Kimi API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates the Kimi (Moonshot AI) OpenAI-compatible provider to ensure a required coding-agent User-Agent header survives the OpenAI SDK’s request construction, preventing Kimi 403 access_terminated_error failures.
Changes:
- Stop using a custom
httpx.Client(headers=...)(which gets overridden by the OpenAI SDK’s own headers). - Provide
User-Agentvia the OpenAI client’sdefault_headersso it’s merged into every request. - Move the 120s timeout configuration onto the OpenAI client (
timeout=120.0).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
LGTM — fix is correct. The root cause is right: the OpenAI SDK's own middleware sets Moving Removing the Good to merge. |
Problem
Kimi's API rejects requests without a recognized coding agent User-Agent header (403
access_terminated_error). Our KimiProvider set the header viahttpx.Client(headers=...), but the OpenAI SDK overwrites it with its own User-Agent.Fix
Use
default_headerson the OpenAI client instead — these merge into every request without being overwritten.Verified
Full pipeline run with real Kimi API: 2 videos, 8 API calls, ~19K tokens, 2 personalized results.
Test plan
🤖 Generated with Claude Code