Repository navigation
Description
Bug Description
When a user connects their ChatGPT subscription (via OAuth device-code flow) and then tries to save an LLM profile using a subscription model (e.g. gpt-6-astra), the pre-flight validation fails with:
litellm.AuthenticationError: AuthenticationError: OpenAIException - {
"error": {
"message": "Incorrect API key provided: None. You can find your API key at https://platform.openai.com/account/api-keys.",
"type": "invalid_request_error",
"param": null,
"code": "invalid_api_key"
}
}
Root Cause
The validate_profile endpoint in openhands-agent-server/openhands/agent_server/profiles_router.py deserializes the submitted LLM config via plain Pydantic but never calls create_subscription_llm_from_config() — unlike LLM.from_persisted() which does.
When the frontend sends a new subscription profile config, it sets auth_type: "subscription" and subscription_vendor: "openai", but the OAuth access token lives in the credential store (~/.openhands/auth/openai_oauth.json), not in the serialized LLM config. Without create_subscription_llm_from_config, the LLM's is_subscription flag stays False and _subscription_credentials stays None, so litellm sends api_key=None to OpenAI.
The save path (to_persisted → from_persisted) correctly handles this, but the pre-flight validation path does not.
Expected Behavior
The pre-flight validation should resolve OAuth credentials from the credential store for subscription profiles, so the 1-token ping completion succeeds.
Actual Behavior
Reproduced with uv run python3 -c "..." against the agent-server started via uv tool uvx ... agent-server:
# Start the agent-server (software-agent-sdk main)
uv tool uvx --reinstall \
--from openhands-agent-server \
--with-editable openhands-sdk \
--with-editable openhands-tools \
--with-editable openhands-workspace \
agent-server --host 127.0.0.1 --port 18000
# After connecting ChatGPT subscription via OAuth, the pre-flight
# POST /api/profiles/{name}/validate sends api_key=None and fails:
# litellm.AuthenticationError: Incorrect API key provided: NoneThe pre-flight sends api_key=None and fails with AuthenticationError.
Steps to Reproduce
- Start the agent-server with
software-agent-sdkfrommain - Connect a ChatGPT subscription via the OpenHands UI (OAuth device-code flow)
- Try to save a new LLM profile with model
gpt-6-astraand auth type "subscription" - The pre-flight validation fails with the
Incorrect API key provided: Noneerror
Acceptance Criteria
- Pre-flight validation (
POST /api/profiles/{name}/validate) resolves OAuth credentials for subscription profiles - Saving a ChatGPT subscription profile succeeds without authentication errors
- Unit test covers the subscription pre-flight path
Activity
github-actions commentedon Sep 8, 2026
✅
ready-for-devlabel appliedThis issue meets the readiness criteria and is ready for contribution.
A contributor can now open a PR that links this issue (
Fixes #<number>).This is an automated check — no AI was used to generate this comment.