Open
Conversation
- Add CopilotSdkProvider supporting completion and model listing via the github-copilot-sdk package (JSON-RPC to bundled Copilot CLI) - Support three auth modes: explicit token, env vars (COPILOT_GITHUB_TOKEN / GITHUB_TOKEN / GH_TOKEN), or gh CLI session - Add asyncio.Lock double-checked locking to prevent concurrent CLI process spawning on first use - Register copilot_sdk in LLMProvider enum, pyproject.toml optional dependencies, and provider docs table (alphabetical order) - Add 20 unit tests covering auth resolution, client reuse, completion, model listing, and edge cases (empty messages, cli_url path, errors) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Raise RuntimeError when SESSION_ERROR fires during streaming instead of silently completing the stream with no error - Call mimetypes.init() at module load to ensure guess_extension() is thread-safe from the first invocation - Add tests for SESSION_ERROR raises, image attachment forwarding, and update provider capability docs (streaming/reasoning/image now ✅) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add Copilot_sdkProvider alias to __init__.py so AnyLLM._create_provider() can find the class (factory uses provider_key.capitalize() → "Copilot_sdk") - Add "Provider Notes" section to providers.md with installation guide, authentication modes, configuration env vars, and usage examples - Regenerate provider table via generate_provider_table.py; copilot_sdk row now shows correct COPILOT_CLI_URL in the Base column Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
Thank you for the contribution! Here is the review from my agent: |
njbrake
requested changes
Mar 17, 2026
Contributor
njbrake
left a comment
There was a problem hiding this comment.
Needs a few updates, see previous comments 🙏
Contributor
|
This PR is stale because it has been open 7 days with no activity. Remove stale label or comment or this will be closed in 3 days. |
Author
|
I will fix these issues. |
- rename provider key and enum from copilot_sdk to copilotsdk across code, tests, docs, and extras - remove alias/banners and keep implementation style aligned with project conventions - add optional SDK test guard and retain defensive event-field handling comments - drop unrelated .github/copilot-instructions.md from this PR
Author
|
Addressed review feedback in commit c20339f. Summary of changes:
Validation run:
If you want, I can also split out any follow-up hardening (e.g., permission policy configurability) into a separate PR. |
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.
Description
Adds
copilot_sdk— a new provider that communicates with GitHub Copilot models viathe
github-copilot-sdkPython package,which bundles the Copilot CLI binary for your platform and speaks to it over JSON-RPC.
The primary motivation is reasoning support: the Copilot CLI session protocol exposes
reasoning_effort(low/medium/high/xhigh) and streams reasoning deltas asa distinct event type, which is not available through the GitHub Models OpenAI-compatible
REST endpoint and therefore cannot be surfaced by the existing
openaiprovider.A secondary benefit is tokenless auth: if the user is already logged in via
gh auth login, no API key or environment variable is needed — the provider falls back tothe CLI's own credentials automatically.
What's included
src/any_llm/providers/copilot_sdk/copilot_sdk.py(new, 463 lines)src/any_llm/providers/copilot_sdk/__init__.py(new)src/any_llm/constants.py(+1 line)pyproject.toml([copilot_sdk]extras)tests/unit/providers/test_copilot_sdk_provider.py(new, 714 lines)tests/conftest.py,tests/unit/test_provider.py(+minimal hooks)docs/src/content/docs/providers.md(table row + Provider Notes section)Supported features
reasoning_effort)data:URIs)Authentication
Two modes, checked in order:
COPILOT_GITHUB_TOKEN,GITHUB_TOKEN, orGH_TOKEN(orapi_keyargument).gh auth logincredentials; no environment variable required.Notable implementation details
asyncio.Lockdouble-checked locking to prevent concurrent coroutines from each spawning a separate CLI process on first use.SESSION_ERRORraisesRuntimeErrorrather than silently completing the stream with no content.mimetypes.init()at module load to ensureguess_extension()is thread-safe from the first invocation (Python's lazy MIME-type initialisation is not thread-safe).data:URIs to temporary files on disk, passed to the CLI asFileAttachmentobjects, and cleaned up after each request. HTTP image URLs are not fetched (skipped with a comment).Copilot_sdkProvideralias in__init__.pyis required soAnyLLM._create_provider()can find the class — the factory capitalises the provider key (copilot_sdk→Copilot_sdk).Installation
Quick usage example
PR Type
Relevant issues
Checklist
AI Usage Information
AI Model used: Claude Sonnet 4.6
AI Developer Tool used: GitHub Copilot (VS Code) and Claude Code (VS Code plugin)
Any other info: The provider connects to the GitHub Copilot CLI via JSON-RPC, so using Copilot to write a Copilot provider felt appropriate. All logic was reviewed and verified manually; tests were executed locally against a real Copilot CLI session.
I am an AI Agent filling out this form (check box if true)