feat(agent): send X-Client version header to our proxy for log attribution (#254) - #308
Merged
Conversation
…ution (#254) Adds X-Client: geo-agent/<ref> so proxy logs can attribute a session to the exact build. The version comes from import.meta.url (the pinned jsDelivr ref the app loaded, e.g. geo-agent@v3.13.1) — there is no build step and package.json is stale, so the module URL is the only accurate source. Falls back to 'dev' for local/headless (file:// URL). Gated to trusted proxy hosts (default suffix nrp-nautilus.io; override via client_header_hosts). geo-agent runs in the browser, so a custom request header extends the CORS preflight — a bring-your-own endpoint that doesn't allowlist X-Client would have the browser block *every* request to it. Only our proxy allowlists it (ingress cors-allow-headers) and only our logs use it, so it's never sent to external BYO endpoints. Proxy side is already wired (llm_proxy.py reads x-client → logs 'client'; ingress CORS allows it) — this is the client half. Closes #254
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
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.
What
Sends
X-Client: geo-agent/<ref>on requests to our proxy so its logs can attribute a session to the exact build (theclientcolumn, currently alwaysnull).import.meta.url— the pinned jsDelivr ref the app actually loaded (geo-agent@v3.13.1, or a commit SHA). There's no build step andpackage.jsonis stale (1.0.0), so the module URL is the only accurate source. Falls back todevon afile://URL (local/headless).The BYO-endpoint risk this avoids (gating)
geo-agent runs in the browser, so a custom request header extends the CORS preflight. A bring-your-own endpoint whose
Access-Control-Allow-Headersis an explicit list withoutX-Clientwould have the browser block every request to it — a hard break, not just missing attribution. (The server ignoring an unknown header is harmless; CORS is the actual failure mode.)So the header is gated: sent only to hosts matching
client_header_hosts(default suffixnrp-nautilus.io— the same origin the proxy's own CORS regex trusts), never to external BYO endpoints. Attribution only matters in our logs anyway, so gating costs nothing.Proxy side is already done
Verified in
open-llm-proxy:llm_proxy.py:490readsx-client→ logs it asclient; the HAProxy ingresscors-allow-headersalready listsX-Client(ingress.yaml:21, with a comment noting it was pre-added for this). So this is purely the client half — no proxy change needed.Tests
test/agent-client-header.test.js(4 cases): header sent to our proxy, not sent to an external BYO endpoint (auth/content-type unaffected), suffix matching (incl. bare apex, rejectsevil-nrp-nautilus.iosubstring attack and non-URLs), and theclient_header_hostsoverride. Full suite: 489 passing.Closes #254