Add GitHub Copilot agent provider - #346
Conversation
Add a GitHub Copilot-backed agent provider using the official Copilot SDK, including session creation and resume, streaming and non-streaming event projection, tool declarations and results, data attachments, and session error handling. Add RawContent support with jsonx fallback unmarshalling for unknown or missing content types, plus a GitHub Copilot sample and blackbox provider tests.
There was a problem hiding this comment.
Pull request overview
This PR adds a new GitHub Copilot-backed provider implementation for the agent framework, along with message/content model extensions to safely round-trip provider-specific or forward-compatible content without failing JSON decoding.
Changes:
- Added
agent/provider/copilotagentprovider that creates/resumes Copilot SDK sessions, streams events into frameworkResponseUpdates, maps framework tools to Copilot tools, and sendsDataContentas file attachments. - Added
message.RawContentand updatedmessage.ContentsJSON unmarshalling to fall back to raw content whenTypeis missing or unknown. - Extended
internal/jsonxwithUnmarshalDiscriminatedUnionSliceWithFallbackand added tests for fallback behavior.
Show a summary per file
| File | Description |
|---|---|
message/content.go |
Adds RawContent and uses fallback-aware union unmarshalling for Contents. |
message/content_test.go |
Adds coverage for missing/unknown Type decoding to RawContent and round-tripping. |
internal/jsonx/jsonx.go |
Adds UnmarshalDiscriminatedUnionSliceWithFallback and refactors existing helper to use it. |
internal/jsonx/jsonx_test.go |
Adds tests for fallback behavior and unsupported-type rejection. |
agent/provider/copilotagent/copilot.go |
Implements the Copilot provider: session lifecycle, event projection, tool mapping, and attachments. |
agent/provider/copilotagent/copilot_test.go |
Adds blackbox-style tests using a fake JSON-RPC runtime for session + event mapping behaviors. |
examples/02-agents/providers/github-copilot/main.go |
Adds a runnable Copilot provider example with permission prompting. |
go.mod |
Adds the Copilot SDK dependency (and websocket indirect). |
go.sum |
Adds checksums for the new dependencies. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 8/9 changed files
- Comments generated: 4
This comment has been minimized.
This comment has been minimized.
Fix golangci-lint findings, make Copilot session event delivery non-blocking while preserving event order, avoid duplicate attachment temp paths, and distinguish missing discriminators from zero-value discriminators in jsonx fallback unmarshalling.
Cross-Repo Parity Review — GitHub Copilot Agent ProviderCompared against SummaryThis PR is well-aligned with the upstream .NET and Python implementations. The core behavioral contract matches across all three SDKs and no blocking cross-repo divergences were found. What was reviewed
Notes
|
Summary
Adds a GitHub Copilot-backed agent provider for Go using the official
github.com/github/copilot-sdk/goSDK.This includes session creation and resume support, streaming and non-streaming response projection, tool declaration and execution result handling, attachment support for
DataContent, session error handling, and a runnable GitHub Copilot provider sample.The change also adds
RawContentsupport for provider-specific content and extendsinternal/jsonxwith fallback-aware discriminated union unmarshalling so unknown or missing content types can round-trip as raw content instead of failing.Details
agent/provider/copilotagentDataContentas temporary file attachmentsexamples/02-agents/providers/github-copilotmessage.RawContentjsonx.UnmarshalDiscriminatedUnionSliceWithFallbackmessage.Contentswhen contentTypeis missing or unknownValidation