Skip to content

fix(core): convert boot guard ValueError to warning for OAuth-native support - #438

Open
tamld wants to merge 3 commits into
BeehiveInnovations:mainfrom
tamld:fix/oauth-native-boot-guard
Open

fix(core): convert boot guard ValueError to warning for OAuth-native support#438
tamld wants to merge 3 commits into
BeehiveInnovations:mainfrom
tamld:fix/oauth-native-boot-guard

Conversation

@tamld

@tamld tamld commented Apr 29, 2026

Copy link
Copy Markdown

Description

This PR modifies the configure_providers "Boot Guard" constraint in server.py to allow the PAL MCP Server to run even when no API keys or configuration URLs are present. It changes the ValueError exception into a non-blocking logger.warning.

Why is this important?

In zero-cost "OAuth-native" orchestration setups (like our architecture at Mandalay Jewelry / AAOS), the primary interaction method is via CLinkTool, which leverages local OS-authenticated CLI sessions (e.g. gemini, codex, claude CLIs). Since clink bypasses the model resolution requirements (requires_model=False), it is fully capable of operating without any API keys configured.

Previously, PAL required a dummy local configuration (e.g., CUSTOM_API_URL=http://localhost:11434) just to bypass the boot guard. This PR removes that friction, allowing a true API-free, local OAUTH experience by default.

Key Benefits:

  • Zero-Cost Operation: Prioritizes local, already-authenticated CLI agent sessions.
  • Enhanced User Experience: Prevents the server from crashing immediately if the user only wants to use native clink agents.
  • Backwards Compatible: Tools that genuinely require an API model will still fail gracefully at runtime if no model is available, but the server itself remains up.

@guidedways / @fahad - Please review this change as a PoC for "No-API" orchestration enablement. Thank you!

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request modifies the server initialization logic to allow the application to start even when no API providers are configured, replacing a hard ValueError with a warning. However, the review highlights that this change is currently incomplete, as subsequent checks in the model registry and thread context reconstruction logic will still trigger errors, effectively preventing a fully functional 'No-API' mode for multi-turn interactions.

Comment thread server.py

# Require at least one valid provider
# Check if OAuth-native mode is enabled or warn instead of blocking
if not valid_providers:

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.

high

While this change converts the initial provider check to a warning, the server will still fail to boot in the default configuration because of the IS_AUTO_MODE check at line 612. If no providers are found, ModelProviderRegistry.get_available_models() returns an empty dictionary, which triggers a ValueError at line 619. To support a true 'No-API' boot as intended by this PR, the validation logic for IS_AUTO_MODE (lines 612-622) also needs to be relaxed or bypassed when no providers are available.

Comment thread server.py
Comment on lines +545 to 548
logger.warning(
"No API configurations found. Tools requiring an API model will fail. "
"However, OAuth-native local tools (like clink) will still function."
)

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.

medium

The warning message indicates that tools like clink will still function. However, multi-turn conversations (using continuation_id) will currently fail for these tools if no API providers are configured. The reconstruct_thread_context function (specifically at line 1189) raises a ValueError when no models are available for context reconstruction, even for tools that don't require a model themselves. This effectively limits the 'OAuth-native' mode to single-turn interactions unless at least one dummy provider is configured.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cdba015da7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread server.py
Comment on lines 544 to 548
if not valid_providers:
raise ValueError(
"At least one API configuration is required. Please set either:\n"
"- GEMINI_API_KEY for Gemini models\n"
"- OPENAI_API_KEY for OpenAI models\n"
"- XAI_API_KEY for X.AI GROK models\n"
"- DIAL_API_KEY for DIAL models\n"
"- OPENROUTER_API_KEY for OpenRouter (multiple models)\n"
"- CUSTOM_API_URL for local models (Ollama, vLLM, etc.)"
logger.warning(
"No API configurations found. Tools requiring an API model will fail. "
"However, OAuth-native local tools (like clink) will still function."
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep no-provider startup blocking when auto mode is default

Downgrading this guard to a warning does not actually enable no-API startup in the default configuration: DEFAULT_MODEL is "auto" by default (config.py), so execution continues to the later auto-mode validation (configure_providers lines 612-622) and still raises ValueError when no models exist. In practice, users with no API keys still fail at boot, but now with a misleading "restrictions" error instead of the explicit provider-missing message, which breaks the intended OAuth-native flow.

Useful? React with 👍 / 👎.

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