feat: support configuring ANTHROPIC_BASE_URL in settings#8
feat: support configuring ANTHROPIC_BASE_URL in settings#8
Conversation
|
@codex review this. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ca6017311
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| // Load persisted ANTHROPIC_BASE_URL into process env. | ||
| if let Some(base_url) = load_persisted_anthropic_base_url(&app_dir) { | ||
| std::env::set_var(ANTHROPIC_BASE_URL_ENV, base_url); |
There was a problem hiding this comment.
Preserve env precedence when loading persisted base URL
run() unconditionally calls std::env::set_var(ANTHROPIC_BASE_URL_ENV, base_url) when anthropic_base_url.txt exists, which overwrites any ANTHROPIC_BASE_URL value provided by the launch environment. In the common override scenario (e.g., CI/dev shell sets a one-off endpoint while a previous UI-saved value exists), the app will silently use the stale persisted URL instead of the env override, despite get_anthropic_base_url() documenting env-first behavior.
Useful? React with 👍 / 👎.
| .ok() | ||
| .and_then(|s| s.parse().ok()) | ||
| .unwrap_or(if env_api_url().is_some() { 300 } else { 90 }) | ||
| .unwrap_or(if env_noah_api_url().is_some() { 300 } else { 90 }) |
There was a problem hiding this comment.
Apply extended timeout to custom Anthropic base URLs
request_timeout_secs() still only switches to the 300s timeout when NOAH_API_URL is set, so requests sent via the new ANTHROPIC_BASE_URL path keep the 90s default. For the local/proxied Anthropic-compatible endpoints this change is meant to support, slower responses can now time out prematurely unless users also discover and set NOAH_TIMEOUT manually.
Useful? React with 👍 / 👎.
|
Thanks for the PR! The URL normalization and persistence logic are solid work. I want to think about this holistically before merging — there are a few design considerations around how endpoint configuration fits into the overall UX (especially for non-technical users) and how it interacts with the existing I may address this with a different approach soon — possibly integrating it into the onboarding/connection flow rather than as a standalone settings section. Will keep this open for reference. Appreciate the contribution! |
Motivation
NOAH_API_URLenv var requires disabling authentication, which is not suitable for Anthropic-compatible endpoints that still need API key auth.Description
ANTHROPIC_BASE_URLenvironment variable support to override the default Anthropic API endpoint while preserving API key authentication.normalize_messages_url()helper function to handle various URL formats (host-only,/v1, or full/v1/messagespaths).get_anthropic_base_url()andset_anthropic_base_url()inapps/desktop/src-tauri/src/commands/settings.rs.anthropic_base_url.txtin the app data directory and load it on startup.apps/desktop/src/components/SettingsPanel.tsx) with:clear_auth_files()to also remove the base URL file when clearing authentication.normalize_messages_url()covering three URL format cases.stage0.test.tsto ensure camelCase parameter naming.Testing
npm test -- stage0.test.tsinapps/desktopand all 12 tests passed, including the newset_anthropic_base_url uses camelCase keytest.cargo test --lib agent::llm_client::tests::test_normalize_messages_urland all 3 tests passed:test_normalize_messages_url_from_host: Verifies host-only URLs get/v1/messagesappendedtest_normalize_messages_url_from_v1: Verifies/v1URLs get/messagesappendedtest_normalize_messages_url_already_messages: Verifies full URLs are unchangedllm_client.rs,settings.rs,lib.rsSettingsPanel.tsx,tauri-commands.ts,stage0.test.tsen.json,zh.json