Skip to content

refactor(ai-gateway): share tracking field removal for direct BYOK providers - #7283

Closed
chrarnoldus wants to merge 2 commits into
mainfrom
kilo/shared-remove-tracking-ids
Closed

chrarnoldus wants to merge 2 commits into
mainfrom
kilo/shared-remove-tracking-ids

Conversation

@chrarnoldus

Copy link
Copy Markdown
Contributor

Stacked on #7282. Merge that PR first; GitHub will then retarget this PR to main.

Summary

Adds removeTrackingIds next to applyTrackingIds in providerHash.ts. It removes the Chat Completions fields that applyTrackingIds adds (prompt_cache_key, safety_identifier, user). OpenCode Go and NVIDIA direct BYOK now use it instead of their own delete lists.

Behavior change

NVIDIA previously removed only safety_identifier and prompt_cache_key. It now also removes user. That field is the same hashed user ID as safety_identifier, and the request already uses the user's own NVIDIA key, so nothing upstream needs it. #4803 said NVIDIA rejects gateway attribution fields and listed user among them. Only safety_identifier was reported as rejected, so this should not change NVIDIA's responses.

Verification

  • jest on providerHash.test.ts and all suites in providers/direct-byok/: 7 suites, 56 tests passed. The run used the web Jest config without the PostgreSQL worker setup, because Docker/PostgreSQL is not available in this environment. These suites do not use the database.
  • pnpm --filter @kilocode/web-shared typecheck: passed.
  • oxlint and oxfmt on the changed files: clean.

@chrarnoldus chrarnoldus self-assigned this Oct 8, 2026
@kilo-code-bot

kilo-code-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The refactor that extracts removeTrackingIds and reuses it in the OpenCode Go and NVIDIA direct BYOK providers preserves the prior field-removal behavior; no bugs, security issues, or regressions found in the changed code.

Files Reviewed (4 files)
  • packages/web-shared/src/lib/ai-gateway/providerHash.ts
  • packages/web-shared/src/lib/ai-gateway/providerHash.test.ts
  • packages/web-shared/src/lib/ai-gateway/providers/direct-byok/nvidia-byok.ts
  • packages/web-shared/src/lib/ai-gateway/providers/direct-byok/opencode-go.ts

Notes

  • removeTrackingIds deletes exactly the three Chat Completions fields applyTrackingIds adds (prompt_cache_key, safety_identifier, user), and the new test asserts strict equality after removal.
  • The NVIDIA behavior change (now also removing user) is intentional and documented in the PR; user is an optional OpenAI-compatible field, so this is not a functional regression.
  • No memory-leak concerns introduced; the helper mutates the request body in place with no retained references.

Reviewed by deepseek-v4.1-flash · Input: 47.9K · Output: 5.8K · Cached: 391.6K

Review guidance: REVIEW.md from base branch kilo/woodsy-fern-0cm

Base automatically changed from kilo/woodsy-fern-0cm to main October 8, 2026 12:21
@chrarnoldus chrarnoldus closed this Oct 8, 2026
@chrarnoldus
chrarnoldus deleted the kilo/shared-remove-tracking-ids branch October 8, 2026 14:04
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.

1 participant