Verify CosmosDict remains in root __init__.py per APIView feedback#9
Draft
Copilot wants to merge 1 commit into
Draft
Verify CosmosDict remains in root __init__.py per APIView feedback#9Copilot wants to merge 1 commit into
Copilot wants to merge 1 commit into
Conversation
Copilot
AI
changed the title
[WIP] Address APIView feedback for azure-cosmos
Verify CosmosDict remains in root __init__.py per APIView feedback
Feb 5, 2026
swathipil
pushed a commit
that referenced
this pull request
Apr 14, 2026
…zure#45894) * feat: scaffold azure-ai-agentserver-github package Initial package structure for the GitHub Copilot SDK adapter for Azure AI Agent Server. Follows the established pattern from azure-ai-agentserver-langgraph. Package exports: - GitHubCopilotAdapter: convenience class with skill discovery + history bootstrap - CopilotAdapter: core adapter (BYOK auth, n:n event mapping, Tool ACL, OTel) - ToolAcl: YAML-based tool permission system Validated: syntax check + import resolution against agentserver-core 1.0.0b14 and github-copilot-sdk 0.1.33rc4. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * tests: add integration test agent for end-to-end ADC validation Minimal test agent that imports GitHubCopilotAdapter from the package (not vendored code), deploys to ADC, and invokes. Proves the package works as a pip-installable dependency. - test_agent/main.py: 5-line entry point using from_project(".") - deploy.py: stages package source + agent, builds via ACR Tasks - invoke.py: REST invocation via az CLI Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: remove Starlette on_event (removed in 1.0), fix logs.py env path - Replace @self.app.on_event("startup") with direct filter registration (Starlette 1.0 removed on_event in favor of lifespan) - Fix logs.py PROJECT_ROOT to find .env at package root Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address PR review comments + sync with recent fixes Review comment fixes: - Remove unused imports (dataclasses, json, uuid, otel_context, trace, CopilotStreamingResponseConverter, ResponseError, Iterable) - Guard _load_conversation_history against missing base class methods - Fix PermissionRequestResult fallback for cross-platform SDK compat - Fix logs.py docstring (path + required session arg) Synced from foundry-declarative-agent repo: - Robust SDK imports (try copilot, fallback to copilot.types, then None) - Pin github-copilot-sdk==0.2.0 - Starlette 1.0 compat (on_event already removed in initial scaffold) - LOG_LEVEL env var support in test agent - Token caching for integration test scripts (_token_cache.py) - invoke.py switched from az rest to urllib (faster) - INSTRUCTIONS.md with full setup/testing/contributing guide Validated end-to-end: pkg-test-03 deployed and responding on ADC. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * tests: add unit tests for CopilotRequestConverter 14 tests covering prompt extraction and attachment materialization: - String, list, dict, and implicit message input shapes - Image URL annotations vs data URI handling - Base64 file and image materialization to temp files - Cleanup of temp files - Edge cases: empty input, file_id only, external URLs Addresses PR review comment requesting unit tests alongside the non-trivial conversion logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ci: register azure-ai-agentserver-github in agentserver pipeline Adds the new package to the CI Artifacts list so unit tests run as a gate on PRs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: self-consistency pass — remove dead code, fix docs, harden error handling - Remove dead CopilotStreamingResponseConverter (247 lines, never imported) - Update CHANGELOG to reflect actual shipped features - Add AZURE_AI_FOUNDRY_API_KEY + LOG_LEVEL to README env vars table - Fix ruff target-version to py310 (matches requires-python) - Fix PAT prefix in integration README (github_pat_ not ghp_) - Add SESSION_ERROR handling to non-streaming path - Fix datetime.now() to use UTC timezone - Register package in agentserver CI pipeline - Revert tool_acl logger to stdlib (avoid heavy agentserver-core import) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: add MCP OAuth consent flow handling Translates Copilot SDK MCP_OAUTH_REQUIRED events into RAPI oauth_consent_request output items. Enables Foundry playground and agent builder to show consent UI when MCP tools need OAuth. Streaming: consent items emitted as additional output_item events after the main text response. Non-streaming: consent items appended to response output list. Follows OAuthConsentRequestItemResource schema from agentserver-core. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: port Valerie's model discovery + auto-derive RESOURCE_URL - _foundry_model_discovery.py: Management API discovery, TPM-based selection - _model_cache.py: 24-hour cache for model selection - Auto-derive RESOURCE_URL from PROJECT_ENDPOINT - AZURE_AI_FOUNDRY_MODEL env var for manual override - _foundry_resource_url internal flag (filtered from create_session kwargs) Ported from coreai-microsoft/foundry-declarative-agent PR Azure#33. Model discovery and format-aware routing are available but not wired into GitHubCopilotAdapter startup yet — consumers can call discover_foundry_deployments() directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: wire model discovery into GitHubCopilotAdapter.initialize() Calls discover_foundry_deployments() at startup when no model is configured. Uses ModelCache (24hr TTL). Falls back gracefully if no credential or discovery fails. Usage: adapter = GitHubCopilotAdapter.from_project(".") await adapter.initialize() # discovers model adapter.run() Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: don't auto-derive BYOK URL when GITHUB_TOKEN is set * address PR review: README overhaul, credential kwarg, pyproject classifiers - Add Development Status :: 4 - Beta and Python 3.14 classifiers - Relax copilot SDK pin to >=0.2.0,<0.3.0 for patch updates - Accept optional `credential` kwarg in CopilotAdapter (don't hardcode DefaultAzureCredential — allows ManagedIdentityCredential etc.) - README: add all required sections (Prerequisites, Examples, Next steps), document AZURE_AI_FOUNDRY_MODEL env var, add CopilotAdapter vs GitHubCopilotAdapter guidance, expand Tool ACL docs with example + auto-approve note, inline key troubleshooting from FAQ, spell out BYOK - Fix from_project docstring (doesn't actually load .env) * docs: strengthen Tool ACL interim disclaimer * fix: resolve all ruff lint errors (line length, unused vars, == True) * pin azure-ai-agentserver-core>=1.0.0b14,<2 to preempt 2.0.0b1 breaking changes * fix: remove relative links in README Next steps (sphinx cross-ref failure) * fix: bump requires-python to >=3.11 (github-copilot-sdk 0.2.0 requires 3.11+) * feat: support FOUNDRY_PROJECT_ENDPOINT env var (container spec alignment) Per the incoming Hosted Agents Container Image Specification (foundrysdk_specs PR #9), the platform will inject FOUNDRY_PROJECT_ENDPOINT instead of AZURE_AI_PROJECT_ENDPOINT. Add _get_project_endpoint() helper that checks the new name first, falls back to the legacy name. Applied to _build_session_config() and _load_conversation_history(). No behavior change for existing deployments — both names work. * ci: remove langgraph from artifacts, set PythonVersionForAnalyze to 3.11 * fix: replace relative link in samples/README.md with absolute URL (link checker) * fix: rename integration test README to TESTING.md to avoid doc warden scan * fix: add github-copilot-sdk to shared_requirements.txt, lowercase pyyaml in pyproject.toml * fix: mypy errors — None guard on hostname, type ignore on Response constructor * fix: SSE streaming — yield before await, heartbeats, keyword-arg construction Root-caused and fixed SSE streaming truncation on ADC platform: 1. Yield envelope events (created, in_progress, output_item.added, content_part.added) BEFORE any await — the proxy requires data flowing immediately when the HTTP 200 is sent. 2. Emit 50ms empty text delta heartbeats during the Copilot SDK processing gap — SSE comments are stripped by the proxy, only real data events keep the connection alive. Heartbeats stop once real content deltas start flowing. 3. Use keyword-arg construction with model objects for all RAPI events — dict-based construction produces different as_dict() serialization that causes proxy truncation. 4. Enable streaming=True on all Copilot SDK sessions (including history bootstrap) so ASSISTANT_MESSAGE_DELTA events are emitted. Read delta_content field (not content) for streaming chunks. 5. Restore CopilotStreamingResponseConverter with keyword-arg construction and model objects for nested fields. Remaining: response.completed done events still truncated after text_done — loading spinner persists in Playground UI (workaround: click stop button). Functional streaming works end-to-end. Validated: stream-test-29 on NCUS ADC — incremental text streaming in both debug_stream.py and Foundry Playground. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: emit response.completed before text_done to survive ADC proxy The ADC proxy drops all SSE events after response.output_text.done. Workaround: emit response.completed BEFORE text_done so the Playground receives the completion signal. Violates RAPI event ordering spec but the Playground handles it correctly. See backlog B12 for follow-up. Also: stop heartbeat empty deltas once real content starts flowing (empty deltas caused Playground text rendering to reset). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: BYOK credential init accounts for auto-derived resource URL The credential check was only looking at the raw AZURE_AI_FOUNDRY_RESOURCE_URL env var, missing the case where the URL is auto-derived from AZURE_AI_PROJECT_ENDPOINT. Now checks the session config instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: use wire_api=completions for BYOK to avoid encrypted content error The Copilot SDK encrypts payloads when using wire_api="responses" against Azure OpenAI/Foundry endpoints. Switch to "completions" which works correctly with Foundry model deployments. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: rich event logging — tool details and content preview From Scott Vickers' investigation-agent branch. Logs tool name, call_id, and args (first 500 chars) for tool execution events. Shows content preview (first 300 chars) for message events. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: configurable idle timeout with heartbeat logging From Scott Vickers' investigation-agent branch. Idle timeout resets on each event (default 300s via COPILOT_IDLE_TIMEOUT). Heartbeat log every 30s (COPILOT_HEARTBEAT_INTERVAL) while waiting for events. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * add tool discovery * fix: pin agentserver-core <b18 — newer version has breaking Tool import * fix: robust Tool import in _tool_discovery — handle SDK version differences * fix: apply ACL to history bootstrap sessions + validate resource_name 1. History bootstrap was using _approve_all instead of the ACL-aware permission handler. Now uses the same ACL check as normal sessions. (Paul review comment) 2. Validate resource_name against [a-zA-Z0-9\-] regex before embedding in Kusto query to prevent injection via malicious URLs. (Paul review comment) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: add cspell words for agentserver-github package * fix: split concatenated entry in shared_requirements.txt — add github-copilot-sdk --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: root <root@CPC-cearl-W9ZSG.localdomain>
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.
APIView feedback requested verification that
CosmosDictremains in the root__init__.pysince its removal would be incorrect.Verification
APIView URL: https://spa.apiview.dev/review/c1c8a8095ae24413aa1bb1705a7c7b77?activeApiRevisionId=aa280dcff3c74b3cb2c3e0902c109359
Confirmed
CosmosDictis correctly present in/sdk/cosmos/azure-cosmos/azure/cosmos/__init__.py:._cosmos_responses(line 23)__all__(line 68)read_item,create_item,replace_item,upsert_item,patch_itemStatus
CosmosDictcorrectly present in root__init__.py. No changes needed - properly exposed in public API.No code changes required. SDK is manually maintained (not code-generated), ensuring stable public API.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.