fix(core): convert boot guard ValueError to warning for OAuth-native support - #438
fix(core): convert boot guard ValueError to warning for OAuth-native support#438tamld wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
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.
|
|
||
| # Require at least one valid provider | ||
| # Check if OAuth-native mode is enabled or warn instead of blocking | ||
| if not valid_providers: |
There was a problem hiding this comment.
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.
| logger.warning( | ||
| "No API configurations found. Tools requiring an API model will fail. " | ||
| "However, OAuth-native local tools (like clink) will still function." | ||
| ) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
💡 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".
| 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." | ||
| ) |
There was a problem hiding this comment.
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 👍 / 👎.
Description
This PR modifies the
configure_providers"Boot Guard" constraint inserver.pyto allow the PAL MCP Server to run even when no API keys or configuration URLs are present. It changes theValueErrorexception into a non-blockinglogger.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,claudeCLIs). Sinceclinkbypasses 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:
clinkagents.@guidedways / @fahad - Please review this change as a PoC for "No-API" orchestration enablement. Thank you!