Skip to content

[AIENG-601] Client-Side Embedding generation poc implementation - #1362

Draft
sandeepbarnwal wants to merge 1 commit into
mainfrom
AIENG-601
Draft

[AIENG-601] Client-Side Embedding generation poc implementation#1362
sandeepbarnwal wants to merge 1 commit into
mainfrom
AIENG-601

Conversation

@sandeepbarnwal

@sandeepbarnwal sandeepbarnwal commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Caution

This is only a POC implementation and should not be merged.

AIENG-601: BYOLLM — Client-Side Embeddings via Customer's LLM Endpoint

Summary

Implements the CLI side of the Bring Your Own LLM (BYOLLM) feature. When a workspace is configured for embeddingMode=client, the CLI fetches embedding configuration
from the server options response, calls the customer's OpenAI-compatible LLM endpoint to generate file embeddings, and uploads the resulting vectors to the
Launchable server. Both record commit and record build support this path.


Python CLI

  • commands/record/commit.py — reads embeddingMode, embeddingEndpoint, embeddingModel, embeddingDimensions, embeddingAugmentation, and embeddingProvider from the
    commits/collect/options response. Env vars (SMART_TESTS_EMBEDDING_ENDPOINT, SMART_TESTS_EMBEDDING_MODEL) override server-provided values. Validates endpoint and API
    key before enabling embeddings; degrades gracefully with a warning if either is missing. record build inherits this path automatically via commit.callback().
  • utils/env_keys.py — added SMART_TESTS_EMBEDDING_ENDPOINT, SMART_TESTS_EMBEDDING_API_KEY, SMART_TESTS_EMBEDDING_MODEL constants.

Java — new embedding/ package

  • RemoteEmbeddingStrategy — calls OpenAI-compatible endpoint; batches up to 1900 files / 210K tokens; rate-limits; retries on 429/5xx with exponential backoff;
    L2-normalizes vectors; skips blank files.
  • AugmentedEmbeddingStrategy — prepends server-generated file summaries to content before embedding.
  • EmbeddingStrategyFactory — builds the right strategy; takes two separate CloseableHttpClient instances — one plain (LLM endpoint), one Launchable-auth-configured
    (summaries endpoint) — to prevent auth header leakage.
  • TokenizerFactory — selects tokenizer from server-provided provider (openai/azure_openai → Cl100kTokenizer, custom → NoopTokenizer); falls back to URL-host sniffing
    when provider is null.
  • Supporting types: EmbeddingStrategy (interface), Cl100kTokenizer, NoopTokenizer, ServerRepoContextProvider, FileToEmbed, FileEmbeddingResult, Summaries.

Java — modified

  • commits/Main.java — added CLI options -embedding-endpoint, -embedding-model, -embedding-dimensions, -embedding-augmentation, -embedding-provider. Builds two
    separate HTTP clients. API key is read via System.getenv() only — never passed as a CLI arg to avoid ps aux exposure.
  • commits/CommitGraphCollector.java — setEmbeddingStrategy(), transferWithEmbeddings(), file consumer integration.

Tests

  • AugmentedEmbeddingStrategyTest — prepend format, empty summary, metadata preservation, delegate modelName/dimensions
  • ServerRepoContextProviderTest — MockServer: returns summaries, correct request body, non-2xx throws IOException
  • EmbeddingStrategyFactoryTest — no-augmentation, augmentation wrapping, end-to-end embed, provider-based tokenizer selection
  • RemoteEmbeddingStrategyTest — added provider-based tokenizer tests (openai, azure_openai, custom, null fallback to URL sniffing)
  • EmbeddingAllTests — JUnit4 suite covering all embedding tests under one Bazel target

Security

  • SMART_TESTS_EMBEDDING_API_KEY is read via System.getenv() in the JVM only, never passed as a CLI argument — prevents exposure via ps aux.
  • Two separate HTTP clients ensure the Launchable workspace token is never sent to the customer's LLM endpoint and vice versa.

Test Plan

  • bazelisk test //src/test/java/com/launchableinc/ingest/embedding:EmbeddingTests — 24 tests pass
  • record commit --source . end-to-end — 22 files embedded via OpenAI, tokenizer selected from provider=openai without any env var override
  • record build --build --source . end-to-end — same embedding path, build recorded successfully
  • Missing endpoint → graceful warning, embeddings skipped, commit/build still recorded
  • Missing API key → graceful warning, embeddings skipped, commit/build still recorded

@sandeepbarnwal sandeepbarnwal added the donotmerge reserved for poc and should not be merged. label Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

donotmerge reserved for poc and should not be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant