Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Compaction routed to OpenRouter free models fails(somes, not all) with a 403(). OpenRouter
only serves its free endpoints to registered agentic harnesses, identified by
app-attribution headers (
HTTP-Referer,X-OpenRouter-Title,X-OpenRouter-Categories). Pi adds these headers to session requests via itsprovider-attribution module, but the exported
compact()path bypasses thatpipeline(so requests made by this extension never carried the attribution
and were rejected).
Fix
The extension now adds the same attribution headers Pi sends, with the same
gating semantics:
withOpenRouterAttribution()(src/index.ts) mergesHTTP-Referer: https://pi.dev,X-OpenRouter-Title: pi, andX-OpenRouter-Categories: cli-agentinto the compaction request headers,only for OpenRouter models (provider
openrouter, or a base URL onopenrouter.ai). Caller-provided auth headers take precedence, matchingPi's
mergeProviderAttributionHeadersmerge order.isInstallTelemetryEnabled()(src/config.ts) mirrors Pi's gate:attribution is only sent when install telemetry is enabled
(
enableInstallTelemetrysetting, overridable viaPI_TELEMETRYwith1/true/yes).createSettings()(src/config.ts) extractsSettingsManagercreation sothe hook builds one manager shared by config loading and the telemetry
check.
Tests
test/headers.test.ts(5 tests): attribution added for OpenRouter,baseUrl-based detection for custom providers, non-OpenRouter models
untouched, telemetry-disabled untouched, caller-header precedence.
test/config.test.ts(+3 tests): telemetry gate settings fallback andtruthy/falsy
PI_TELEMETRYvalues.bun run check(typecheck + full suite): 15/15 passing.Docs
the telemetry gate.
Notes
request; OpenRouter's free-tier check is the attribution headers.
bun.lockupdate (peerDependency range sync).