Skip to content

feat(sdk)!: upgrade to SDK v0.2.0 with breaking API changes#32

Open
mowree wants to merge 6 commits intomicrosoft:mainfrom
HDMowri:v2.0.0-copilot-sdk-upgrade
Open

feat(sdk)!: upgrade to SDK v0.2.0 with breaking API changes#32
mowree wants to merge 6 commits intomicrosoft:mainfrom
HDMowri:v2.0.0-copilot-sdk-upgrade

Conversation

@mowree
Copy link
Collaborator

@mowree mowree commented Mar 23, 2026

BREAKING CHANGE: Requires github-copilot-sdk>=0.2.0,<0.3.0
BREAKING CHANGE: CopilotClient now uses SubprocessConfig
BREAKING CHANGE: session.send() signature changed to send(prompt, attachments=...)

SDK v0.2.0 Upgrade:

  • SubprocessConfig replaces raw dict for client initialization
  • send(prompt, attachments=...) replaces send({"prompt": ...})
  • Vision support: ImageBlock → BlobAttachment passthrough

New Architecture:

  • sdk_adapter/ quarantine isolates SDK imports
  • config/ YAML files for policy values (Three-Medium)
  • contracts/ behavioral specifications

Test Results:

  • Windows: 858 passed, 2 skipped (Unix tests), 90.22% coverage
  • WSL/Linux: 859 passed, 1 skipped (Windows test), 90.38% coverage

BREAKING CHANGE: Requires github-copilot-sdk>=0.2.0,<0.3.0
BREAKING CHANGE: CopilotClient now uses SubprocessConfig
BREAKING CHANGE: session.send() signature changed to send(prompt, attachments=...)

SDK v0.2.0 Upgrade:
- SubprocessConfig replaces raw dict for client initialization
- send(prompt, attachments=...) replaces send({"prompt": ...})
- Vision support: ImageBlock → BlobAttachment passthrough

New Architecture:
- sdk_adapter/ quarantine isolates SDK imports
- config/ YAML files for policy values (Three-Medium)
- contracts/ behavioral specifications

Test Results:
- Windows: 858 passed, 2 skipped (Unix tests), 90.22% coverage
- WSL/Linux: 859 passed, 1 skipped (Windows test), 90.38% coverage
@mowree mowree requested a review from Copilot March 23, 2026 04:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Upgrades the provider to github-copilot-sdk v0.2.0 (breaking API changes) and introduces a “Three‑Medium” architecture with SDK isolation, YAML-driven policy, and contract docs.

Changes:

  • Replace direct SDK usage with an sdk_adapter/ membrane (quarantined imports, session lifecycle, event/tool extraction).
  • Introduce YAML configuration + markdown contracts to define provider behavior (streaming, errors, deny/destroy, SDK protection, observability).
  • Restructure tests/fixtures to match updated SDK response shapes and new session creation semantics.

Reviewed changes

Copilot reviewed 69 out of 165 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tests/sdk_assumptions/test_deny_hook.py Removes SDK behavioral assumption tests for deny-hook/tool execution.
tests/sdk_assumptions/conftest.py Removes custom mocked SDK/session harness used by assumption tests.
tests/sdk_assumptions/init.py Removes package docs for assumption test suite.
tests/sdk_assumptions/README.md Removes assumption-suite upgrade workflow documentation.
tests/integration/init.py Removes integration test package marker docstring.
tests/fixtures/sdk_responses.py Adds realistic SDK response shape fixtures (Data wrapper, etc.).
tests/fixtures/config_capture.py Adds strict mock client to capture create_session(**kwargs) config for SDK v0.2.0.
tests/fixtures/init.py Exports new fixture/mocks surface for tests.
tests/init.py Updates tests package/module docstring.
pyproject.toml Bumps package to 2.0.0, upgrades SDK dependency to v0.2.x, adds pyright/ruff config, adjusts pytest config.
docs/ARCHITECTURE.md Adds architecture overview documenting module structure and design decisions.
contracts/streaming-contract.md Adds streaming behavior specification + anchors.
contracts/sdk-response.md Adds SDK response extraction contract + anchors.
contracts/sdk-protection.md Adds defensive invariants for tool capture + session management.
contracts/provider-protocol.md Adds provider protocol specification + hooks/quality gates anchors.
contracts/observability.md Adds observability spec and notes partial implementation.
contracts/event-vocabulary.md Adds SDK→domain event vocabulary and config schema contract.
contracts/error-hierarchy.md Adds SDK→kernel error translation contract and config schema.
contracts/deny-destroy.md Adds deny+destroy non-negotiable pattern contract.
contracts/behaviors.md Adds config-driven policy contract (retry/streaming/model selection, etc.).
amplifier_module_provider_github_copilot/tool_parsing.py Adds tool call parsing to kernel ToolCall objects.
amplifier_module_provider_github_copilot/tool_capture.py Removes legacy tool bridge/deny-hook creation module.
amplifier_module_provider_github_copilot/security_redaction.py Adds secret redaction helpers for log hygiene.
amplifier_module_provider_github_copilot/sdk_adapter/types.py Adds SDK boundary types + tool/image passthrough helpers.
amplifier_module_provider_github_copilot/sdk_adapter/tool_capture.py Adds first-turn-only + deduplicated tool capture handler.
amplifier_module_provider_github_copilot/sdk_adapter/extract.py Adds unified SDK event field extraction helper.
amplifier_module_provider_github_copilot/sdk_adapter/event_helpers.py Adds SDK event type helpers + tool_request extraction.
amplifier_module_provider_github_copilot/sdk_adapter/client.py Adds Copilot client wrapper using SubprocessConfig + v0.2 session config/hook model.
amplifier_module_provider_github_copilot/sdk_adapter/_spec_utils.py Adds SDK-spec discovery via importlib.util.find_spec without importing SDK.
amplifier_module_provider_github_copilot/sdk_adapter/_imports.py Adds SDK import quarantine module for SDK v0.2 concepts.
amplifier_module_provider_github_copilot/sdk_adapter/init.py Exposes adapter “membrane” public surface.
amplifier_module_provider_github_copilot/request_adapter.py Adds ChatRequest→CompletionRequest prompt/attachment adaptation.
amplifier_module_provider_github_copilot/observability.py Adds YAML-driven observability event emission helpers + lifecycle context.
amplifier_module_provider_github_copilot/model_naming.py Removes legacy model naming parsing/validation heuristics.
amplifier_module_provider_github_copilot/fake_tool_detection.py Adds YAML-driven fake tool-call detection + retry logging helpers.
amplifier_module_provider_github_copilot/exceptions.py Removes custom exception hierarchy in favor of kernel error types.
amplifier_module_provider_github_copilot/converters.py Removes legacy message/response conversion utilities.
amplifier_module_provider_github_copilot/config/sdk_protection.yaml Adds SDK protection policy for tool capture + session behavior.
amplifier_module_provider_github_copilot/config/retry.yaml Adds retry + streaming timing policy values.
amplifier_module_provider_github_copilot/config/observability.yaml Adds observability policy (event names, status, flags).
amplifier_module_provider_github_copilot/config/models.yaml Adds provider identity + model catalog/defaults policy.
amplifier_module_provider_github_copilot/config/model_cache.yaml Adds model cache policy.
amplifier_module_provider_github_copilot/config/fake-tool-detection.yaml Adds fake tool-call detection policy.
amplifier_module_provider_github_copilot/config/events.yaml Adds event classification policy mapping SDK event types to domain events.
amplifier_module_provider_github_copilot/config/errors.yaml Adds error translation policy mappings.
amplifier_module_provider_github_copilot/config/init.py Adds config package marker for importlib.resources.
amplifier_module_provider_github_copilot/completion.py Adds new completion lifecycle implementation using v0.2 send/on + tool capture/abort.
amplifier_module_provider_github_copilot/_platform.py Refactors binary discovery to use membrane spec discovery, caches platform facts.
amplifier_module_provider_github_copilot/_permissions.py Updates execute-bit repair logic for SDK-bundled binaries (no world-exec).
README.md Replaces token examples with placeholders.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

HDMowri and others added 5 commits March 22, 2026 22:30
- Fix SDK version docstring: 0.1.32+ → 0.2.0+ (sdk_responses.py)
- Fix assert_hook_registered docstring: clarify it checks session.on()
- Fix unbounded event queue: use streaming.event_queue_size from YAML
- Fix event handler race: always check idle event before dropping
- Add live tests opt-in: '-m not live' default for CI (pyproject.toml)
- Use default_factory=list: cleaner than lambda (types.py)
- Use importlib.resources: consistent config loading (observability.py)
- Align DENY_ALL with minimal reason strategy: 'Processing' + suppressOutput
- Update tests to match new DENY_ALL structure

Test results: Windows 858 passed, 2 skipped (Unix), 90.02% coverage
Add StreamingChatResponse class that extends ChatResponse with content_blocks
for streaming UI compatibility. The loop-streaming orchestrator uses this to
emit CONTENT_BLOCK_START/END events for real-time updates.

Contract: streaming-contract:StreamingResponse:MUST:1-4

Changes:
- Add StreamingChatResponse class with content_blocks and text fields
- Update to_chat_response() to build both content (Pydantic) and
  content_blocks (dataclass) for dual-type system compliance
- Add 8 TDD tests for StreamingChatResponse behavior
- Update streaming-contract.md with new MUST constraints

Test Results:
- Windows: 866 passed, 2 skipped, 6 deselected | pyright: 0 errors
- WSL: 873 passed, 1 skipped | Coverage: 90% (statement + branch)
- Live tests: 6 passed (both platforms)
Add 25 integration tests to improve provider.py coverage from 74% to 95%.
Tests exercise production code paths through MockCopilotClientWrapper.

Coverage improvements:
- Retry paths (success after failure, exception translation)
- Fake tool detection (pattern match → correction retry)
- TTFT warning (slow first token tracking)
- Progressive streaming (text/thinking content emission)
- Error events (dict, object, None data formats)
- Tool capture + abort (timeout/exception handling)
- Emit helpers (coordinator guard, task exception callback)
- Close cleanup (pending emit task cancellation)
- Queue full (bounded queue overflow handling)

Add typings/ stubs for pyright compliance:
- copilot SDK client stubs (CopilotClient, CopilotSession)
- amplifier_core stubs (ModelInfo, ChatResponse, errors)

Contract References:
- behaviors:Retry:MUST:1-5
- streaming-contract:ProgressiveStreaming:SHOULD:1
- sdk-protection:Session:MUST:3,4
- MUST-FIX #1-4: SDK version, bounded queue, Makefile, docstring
- SHOULD-FIX microsoft#5,7,8: event predicates, membrane bypass, empty args
- NITS N1-N9: cleanup and doc corrections
- Delete completion.py (duplicate streaming impl)
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.

3 participants