Skip to content

fix: third-party provider compat — update, metrics, and refusal message#1406

Open
oyi77 wants to merge 2 commits into
Gitlawb:mainfrom
oyi77:fix/api-metrics-and-refusal-model
Open

fix: third-party provider compat — update, metrics, and refusal message#1406
oyi77 wants to merge 2 commits into
Gitlawb:mainfrom
oyi77:fix/api-metrics-and-refusal-model

Conversation

@oyi77
Copy link
Copy Markdown

@oyi77 oyi77 commented May 27, 2026

Summary

Four fixes for third-party provider users:

1. openclaude update blocked for all 3P users

src/cli/update.ts — Changed gate from getAPIProvider() !== 'firstParty' to also check MACRO.PACKAGE_URL === '@anthropic-ai/claude-code'. OpenClaude builds (where PACKAGE_URL is @gitlawb/openclaude) can now self-update from npm.

src/utils/autoUpdater.ts — Same fix in assertMinVersion().

2. Metrics endpoint called by 3P providers

src/services/api/metricsOptOut.ts — Added firstParty gate to _fetchMetricsEnabled(). Previously, 3P users with API keys would hit api.anthropic.com/api/claude_code/organizations/metrics_enabled and get auth errors.

3. Stale hardcoded model in refusal message

src/services/api/errors.ts — Replaced hardcoded 'claude-sonnet-4-20250514' with getDefaultMainLoopModel() so the model suggestion is always current and provider-appropriate.

Testing

  • openclaude update should work for non-Anthropic builds
  • Metrics check should return { metrics_logging_enabled: false } for 3P without hitting Anthropic
  • Refusal message should suggest the correct default model for the current provider

…l message

Four fixes for third-party provider users:

1. cli/update.ts: Allow self-update for non-Anthropic builds by checking
   PACKAGE_URL instead of blocking all non-firstParty providers.

2. utils/autoUpdater.ts: Same fix for assertMinVersion() — allow version
   checks for builds with custom PACKAGE_URL.

3. api/metricsOptOut.ts: Gate Anthropic metrics endpoint behind firstParty
   check so 3P providers don't hit api.anthropic.com and get auth errors.

4. api/errors.ts: Replace hardcoded 'claude-sonnet-4-20250514' in refusal
   message with getDefaultMainLoopModel() for provider-appropriate suggestion.
Copy link
Copy Markdown
Contributor

@Meetpatel006 Meetpatel006 left a comment

Choose a reason for hiding this comment

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

look fine , lgtm

kevincodex1
kevincodex1 previously approved these changes May 28, 2026
Copy link
Copy Markdown
Collaborator

@jatmn jatmn left a comment

Choose a reason for hiding this comment

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

Thanks for the update. I took another pass through the changed paths and found one issue that still needs to be addressed before this is ready.

Findings

  • [P2] Apply the third-party metrics gate before reusing the disk cache
    src/services/api/metricsOptOut.ts:144
    The new provider check only runs inside _fetchMetricsEnabled(), but checkMetricsEnabled() returns metricsStatusCache first. If a user previously ran a first-party session where the Anthropic metrics API returned enabled: true, then switches the same OpenClaude install to OpenAI/Gemini/etc., this path will keep returning enabled: true from disk for up to 24 hours and never reach the new getAPIProvider() !== 'firstParty' short-circuit. That means the PR's "third-party providers should not use Anthropic metrics" behavior is not guaranteed for existing cached installs. Please short-circuit non-first-party sessions before reading the shared disk cache, or make the cache provider/account scoped so first-party state cannot be reused by third-party sessions.

Address review feedback: stale first-party metrics cache could leak
enabled:true to third-party sessions. Short-circuit non-firstParty
before reading the shared disk cache.
@oyi77
Copy link
Copy Markdown
Author

oyi77 commented May 29, 2026

Fixed. Added firstParty gate in checkMetricsEnabled() before disk cache read at line 135 — stale first-party enabled: true can no longer leak to third-party sessions.

Copy link
Copy Markdown
Collaborator

@jatmn jatmn left a comment

Choose a reason for hiding this comment

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

Thanks for the update. I rechecked the previously discussed paths and do not see any remaining actionable issues from my side.

@jatmn jatmn requested review from anandh8x and auriti May 29, 2026 15:37
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.

4 participants