feat(github-copilot): add embedding provider for memory search#61718
Conversation
6674508 to
b2f07b6
Compare
Greptile SummaryThis PR adds a
Confidence Score: 4/5Safe to merge; both flagged items are minor UX and performance suggestions with no security regression or data-loss risk. Core logic is correct and well-tested. Token lifecycle, SSRF scoping, and boundary rules are all handled properly. The two style-level notes (unnecessary discovery call for explicit model overrides, missing user-model validation) are low-risk and can be addressed in a follow-up.
Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/github-copilot/embeddings.ts
Line: 107-125
Comment:
**`pickBestModel` silently accepts invalid user-provided models**
When the caller supplies a model name, `pickBestModel` returns it verbatim without checking whether it appears in `available`. A model that exists in the Copilot catalog but does not support the embeddings endpoint (e.g. `gpt-4o`) will only fail later at embedding time with a cryptic HTTP error rather than a clear message at `create()` time. Consider validating the stripped name against the discovered list when it is non-empty:
```suggestion
function pickBestModel(available: string[], userModel?: string): string {
if (userModel) {
const normalized = userModel.trim();
// Strip the provider prefix if users set "github-copilot/model-name".
const stripped = normalized.startsWith(`${COPILOT_EMBEDDING_PROVIDER_ID}/`)
? normalized.slice(`${COPILOT_EMBEDDING_PROVIDER_ID}/`.length)
: normalized;
if (available.length > 0 && !available.includes(stripped)) {
throw new Error(
`GitHub Copilot embedding model "${stripped}" is not available. Available: ${available.join(", ")}`,
);
}
return stripped;
}
for (const preferred of PREFERRED_MODELS) {
if (available.includes(preferred)) {
return preferred;
}
}
if (available.length > 0) {
return available[0]!;
}
throw new Error("No embedding models available from GitHub Copilot");
}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/github-copilot/embeddings.ts
Line: 215-222
Comment:
**Model discovery always runs even when user pins a model**
`discoverEmbeddingModels` is called unconditionally, so every `create()` call makes an extra `GET /models` round-trip even when `options.model` is already set. The result of that call is then discarded by `pickBestModel`. If the intent is to use discovery as an implicit auth/connectivity check, a brief comment to that effect would make the decision clear to future maintainers. Otherwise, consider short-circuiting for explicit model overrides:
```suggestion
const userModel = options.model?.trim() || undefined;
// Always discover models: this also serves as an auth/connectivity check
// for the Copilot token before we attempt any embedding requests.
const availableModels = await discoverEmbeddingModels({
baseUrl,
copilotToken,
ssrfPolicy,
});
const model = pickBestModel(availableModels, userModel);
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "feat(github-copilot): add embedding prov..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6674508393
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
b751245 to
5541db7
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5541db7b31
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
5541db7 to
c3ee4f0
Compare
|
cc @steipete @vincentkoc — would appreciate a review when you get a chance. This adds GitHub Copilot as a memory search embedding provider, reusing the existing token infrastructure from the github-copilot plugin. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3ee4f079d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
c3ee4f0 to
4f8219b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f8219b4ea
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
9164c95 to
c03291a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c03291a6af
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
c03291a to
aef3ab1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aef3ab1439
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
f4dc825 to
162ac0e
Compare
|
Friendly bump. @steipete @vincentkoc CI is green now, would appreciate a review when you have a moment. |
162ac0e to
ad0de7c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad0de7cd19
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dcee5cbe4e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
dcee5cb to
0945c2c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0945c2cc4d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
0945c2c to
da1dcc9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da1dcc96b7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
2c2b606 to
fb54919
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb5491965f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
fb54919 to
1bc3f17
Compare
|
Rebased onto main to resolve a conflict in docs/providers/github-copilot.md (upstream added an env-var priority table in the same region). |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1bc3f174a7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@vignesh07 Would appreciate a review on this? It adds embedding support to the github-copilot provider for memory search. |
Add GitHub Copilot as a memory search embedding provider so users with Copilot subscriptions can use embeddings without a separate API key. - Extract resolveFirstGithubToken to shared auth.ts for reuse - Add MemoryEmbeddingProviderAdapter with dynamic model discovery via the Copilot /models endpoint, auto-selecting the best available embedding model (prefers text-embedding-3-small) - Register the provider at auto-selection priority 15 (between local and OpenAI) and declare the memoryEmbeddingProviders contract in the plugin manifest - Match models by ID pattern when supported_endpoints is empty, as the Copilot API lists embedding models without declaring their endpoint - Add docs for memory search provider tables, config reference, and the GitHub Copilot provider page
1bc3f17 to
05a78ce
Compare
|
Merged via squash.
Thanks @feiskyer! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05a78ce7f2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Great! Thanks @vincentkoc! |
…law#61718) Merged via squash. Prepared head SHA: 05a78ce Co-authored-by: feiskyer <676637+feiskyer@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Reviewed-by: @vincentkoc
…law#61718) Merged via squash. Prepared head SHA: 05a78ce Co-authored-by: feiskyer <676637+feiskyer@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Reviewed-by: @vincentkoc
…law#61718) Merged via squash. Prepared head SHA: 05a78ce Co-authored-by: feiskyer <676637+feiskyer@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Reviewed-by: @vincentkoc
…law#61718) Merged via squash. Prepared head SHA: 05a78ce Co-authored-by: feiskyer <676637+feiskyer@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Reviewed-by: @vincentkoc
…law#61718) Merged via squash. Prepared head SHA: 05a78ce Co-authored-by: feiskyer <676637+feiskyer@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Reviewed-by: @vincentkoc
…law#61718) Merged via squash. Prepared head SHA: 05a78ce Co-authored-by: feiskyer <676637+feiskyer@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Reviewed-by: @vincentkoc
…law#61718) Merged via squash. Prepared head SHA: 05a78ce Co-authored-by: feiskyer <676637+feiskyer@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Reviewed-by: @vincentkoc
…law#61718) Merged via squash. Prepared head SHA: 05a78ce Co-authored-by: feiskyer <676637+feiskyer@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Reviewed-by: @vincentkoc
Summary
MemoryEmbeddingProviderAdapterto thegithub-copilotplugin that discovers embedding models via the Copilot API and registers at auto-selection priority 15.createRemoteEmbeddingProviderpattern is not reused because it is not exported through the plugin SDK; the adapter builds its own HTTP client following the Ollama extension pattern.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
N/A — new feature.
Regression Test Plan (if applicable)
N/A — new feature, but comprehensive test coverage added.
extensions/github-copilot/embeddings.test.ts(22 tests)extensions/github-copilot/index.test.tsupdated with registration testUser-visible / Behavior Changes
github-copilotavailable foragents.defaults.memorySearch.providerprovider: "auto", GitHub Copilot is tried at priority 15 (after local, before OpenAI) if a GitHub token is available/modelsendpoint (preferstext-embedding-3-small)openclaw models auth login-github-copilot)Diagram (if applicable)
Security Impact (required)
/embeddingsand/modelsendpointsfetchWithSsrFGuardwith SSRF policy scoped to the resolved Copilot API hostname. Tokens are sent only viaAuthorizationheader and never logged.Repro + Verification
Environment
openclaw-e2e-copilot-embedimageagents.defaults.memorySearch.provider: "github-copilot"Steps
openclaw models auth login-github-copilotor setGH_TOKEN)agents.defaults.memorySearch.provider: "github-copilot"inopenclaw.jsonopenclaw memory index --forceopenclaw memory search "query"Expected
Provider: github-copilot,Model: text-embedding-3-small,Vector: readyActual
Evidence
Unit tests: 22 passing in
embeddings.test.ts, 46 total acrossextensions/github-copilot/Docker E2E output:
Human Verification (required)
supported_endpoints(Copilot API quirk — models matched by ID pattern), missing GitHub token (graceful fallthrough), model discovery HTTP error, malformed responseopenclaw message sendin Docker (pre-existing Node 24 ESM bug on v2026.4.5 tag, unrelated to this PR)Review Conversations
Compatibility / Migration
Risks and Mitigations