{"kind":"AgentDefinition","metadata":{"namespace":"community","name":"dataverse-python-agentic-workflows","version":"0.1.0"},"spec":{"agents_md":"# Dataverse SDK for Python - Agentic Workflows Guide\n\n## ⚠️ PREVIEW FEATURE NOTICE\n\n**Status**: This feature is in **Public Preview** as of December 2025  \n**Availability**: General Availability (GA) date TBD  \n**Documentation**: Complete implementation details forthcoming  \n\nThis guide covers the conceptual framework and planned capabilities for building agentic workflows with the Dataverse SDK for Python. Specific APIs and implementations may change before general availability.\n\n---\n\n## 1. Overview: Agentic Workflows with Dataverse\n\n### What are Agentic Workflows?\n\nAgentic workflows are autonomous, intelligent processes where:\n- **Agents** make decisions and take actions based on data and rules\n- **Workflows** orchestrate complex, multi-step operations\n- **Dataverse** serves as the central source of truth for enterprise data\n\nThe Dataverse SDK for Python is designed to enable data scientists and developers to build these intelligent systems without .NET expertise.\n\n### Key Capabilities (Planned)\n\nThe SDK is strategically positioned to support:\n\n1. **Autonomous Data Agents** - Query, update, and evaluate data quality independently\n2. **Form Prediction \u0026 Autofill** - Pre-fill forms based on data patterns and context\n3. **Model Context Protocol (MCP)** Support - Enable standardized agent-to-tool communication\n4. **Agent-to-Agent (A2A)** Collaboration - Multiple agents working together on complex tasks\n5. **Semantic Modeling** - Natural language understanding of data relationships\n6. **Secure Impersonation** - Run operations on behalf of specific users with audit trails\n7. **Compliance Built-in** - Data governance and retention policies enforced\n\n---\n\n## 2. Architecture Patterns for Agentic Systems\n\n### Multi-Agent Pattern\n```python\n# Conceptual pattern - specific APIs pending GA\nclass DataQualityAgent:\n    \"\"\"Autonomous agent that monitors and improves data quality.\"\"\"\n    \n    def __init__(self, client):\n        self.client = client\n    \n    async def evaluate_data_quality(self, table_name):\n        \"\"\"Evaluate data quality metrics for a table.\"\"\"\n        records = await self.client.get(table_name)\n        \n        metrics = {\n            'total_records': len(records),\n            'null_values': sum(1 for r in records if None in r.values()),\n            'duplicate_records': await self._find_duplicates(table_name)\n        }\n        return metrics\n    \n    async def auto_remediate(self, issues):\n        \"\"\"Automatically fix identified data quality issues.\"\"\"\n        # Agent autonomously decides on remediation actions\n        pass\n\nclass DataEnrichmentAgent:\n    \"\"\"Autonomous agent that enriches data from external sources.\"\"\"\n    \n    async def enrich_accounts(self):\n        \"\"\"Enrich account data with market information.\"\"\"\n        accounts = await self.client.get(\"account\")\n        \n        for account in accounts:\n            enrichment = await self._lookup_market_data(account['name'])\n            await self.client.update(\"account\", account['id'], enrichment)\n```\n\n### Agent Orchestration Pattern\n```python\n# Conceptual pattern - specific APIs pending GA\nclass DataPipeline:\n    \"\"\"Orchestrates multiple agents working together.\"\"\"\n    \n    def __init__(self, client):\n        self.quality_agent = DataQualityAgent(client)\n        self.enrichment_agent = DataEnrichmentAgent(client)\n        self.sync_agent = SyncAgent(client)\n    \n    async def run(self, table_name):\n        \"\"\"Execute multi-agent workflow.\"\"\"\n        # Step 1: Quality check\n        print(\"Running quality checks...\")\n        issues = await self.quality_agent.evaluate_data_quality(table_name)\n        \n        # Step 2: Enrich data\n        print(\"Enriching data...\")\n        await self.enrichment_agent.enrich_accounts()\n        \n        # Step 3: Sync to external systems\n        print(\"Syncing to external systems...\")\n        await self.sync_agent.sync_to_external_db(table_name)\n```\n\n---\n\n## 3. Model Context Protocol (MCP) Support (Planned)\n\n### What is MCP?\n\nThe Model Context Protocol (MCP) is an open standard for:\n- **Tool Definition** - Describe what tools/capabilities are available\n- **Tool Invocation** - Allow LLMs to call tools with parameters\n- **Context Management** - Manage context between agent and tools\n- **Error Handling** - Standardized error responses\n\n### MCP Integration Pattern (Conceptual)\n\n```python\n# Conceptual pattern - specific APIs pending GA\nfrom dataverse_mcp import DataverseMCPServer\n\n# Define available tools\ntools = [\n    {\n        \"name\": \"query_accounts\",\n        \"description\": \"Query accounts with filters\",\n        \"parameters\": {\n            \"filter\": \"OData filter expression\",\n            \"select\": \"Columns to retrieve\",\n            \"top\": \"Maximum records\"\n        }\n    },\n    {\n        \"name\": \"create_account\",\n        \"description\": \"Create a new account\",\n        \"parameters\": {\n            \"name\": \"Account name\",\n            \"credit_limit\": \"Credit limit amount\"\n        }\n    },\n    {\n        \"name\": \"update_account\",\n        \"description\": \"Update account fields\",\n        \"parameters\": {\n            \"account_id\": \"Account GUID\",\n            \"updates\": \"Dictionary of field updates\"\n        }\n    }\n]\n\n# Create MCP server\nserver = DataverseMCPServer(client, tools=tools)\n\n# LLMs can now use Dataverse tools\nawait server.handle_tool_call(\"query_accounts\", {\n    \"filter\": \"creditlimit gt 100000\",\n    \"select\": [\"name\", \"creditlimit\"]\n})\n```\n\n---\n\n## 4. Agent-to-Agent (A2A) Collaboration (Planned)\n\n### A2A Communication Pattern\n\n```python\n# Conceptual pattern - specific APIs pending GA\nclass DataValidationAgent:\n    \"\"\"Validates data before downstream agents process it.\"\"\"\n    \n    async def validate_and_notify(self, data):\n        \"\"\"Validate data and notify other agents.\"\"\"\n        if await self._is_valid(data):\n            # Publish event that other agents can subscribe to\n            await self.publish_event(\"data_validated\", data)\n        else:\n            await self.publish_event(\"validation_failed\", data)\n\nclass DataProcessingAgent:\n    \"\"\"Waits for valid data from validation agent.\"\"\"\n    \n    async def __init__(self):\n        self.subscribe(\"data_validated\", self.process_data)\n    \n    async def process_data(self, data):\n        \"\"\"Process already-validated data.\"\"\"\n        # Agent can safely assume data is valid\n        result = await self._transform(data)\n        await self.publish_event(\"processing_complete\", result)\n```\n\n---\n\n## 5. Building Autonomous Data Agents\n\n### Data Quality Agent Example\n```python\n# Working example with current SDK features\nfrom PowerPlatform.Dataverse.client import DataverseClient\nfrom azure.identity import InteractiveBrowserCredential\nimport json\n\nclass DataQualityAgent:\n    \"\"\"Monitor and report on data quality.\"\"\"\n    \n    def __init__(self, org_url, credential):\n        self.client = DataverseClient(org_url, credential)\n    \n    def analyze_completeness(self, table_name, required_fields):\n        \"\"\"Analyze field completeness.\"\"\"\n        records = self.client.get(\n            table_name,\n            select=required_fields\n        )\n        \n        missing_by_field = {field: 0 for field in required_fields}\n        total = 0\n        \n        for page in records:\n            for record in page:\n                total += 1\n                for field in required_fields:\n                    if field not in record or record[field] is None:\n                        missing_by_field[field] += 1\n        \n        # Calculate completeness percentage\n        completeness = {\n            field: ((total - count) / total * 100) \n            for field, count in missing_by_field.items()\n        }\n        \n        return {\n            'table': table_name,\n            'total_records': total,\n            'completeness': completeness,\n            'missing_counts': missing_by_field\n        }\n    \n    def detect_duplicates(self, table_name, key_fields):\n        \"\"\"Detect potential duplicate records.\"\"\"\n        records = self.client.get(table_name, select=key_fields)\n        \n        all_records = []\n        for page in records:\n            all_records.extend(page)\n        \n        seen = {}\n        duplicates = []\n        \n        for record in all_records:\n            key = tuple(record.get(f) for f in key_fields)\n            if key in seen:\n                duplicates.append({\n                    'original_id': seen[key],\n                    'duplicate_id': record.get('id'),\n                    'key': key\n                })\n            else:\n                seen[key] = record.get('id')\n        \n        return {\n            'table': table_name,\n            'duplicate_count': len(duplicates),\n            'duplicates': duplicates\n        }\n    \n    def generate_quality_report(self, table_name):\n        \"\"\"Generate comprehensive quality report.\"\"\"\n        completeness = self.analyze_completeness(\n            table_name,\n            ['name', 'telephone1', 'emailaddress1']\n        )\n        \n        duplicates = self.detect_duplicates(\n            table_name,\n            ['name', 'emailaddress1']\n        )\n        \n        return {\n            'timestamp': pd.Timestamp.now().isoformat(),\n            'table': table_name,\n            'completeness': completeness,\n            'duplicates': duplicates\n        }\n\n# Usage\nclient = DataverseClient(\"https://\u003corg\u003e.crm.dynamics.com\", InteractiveBrowserCredential())\nagent = DataQualityAgent(\"https://\u003corg\u003e.crm.dynamics.com\", InteractiveBrowserCredential())\n\nreport = agent.generate_quality_report(\"account\")\nprint(json.dumps(report, indent=2))\n```\n\n### Form Prediction Agent Example\n```python\n# Conceptual pattern using current SDK capabilities\nfrom sklearn.ensemble import RandomForestRegressor\nimport pandas as pd\n\nclass FormPredictionAgent:\n    \"\"\"Predict and autofill form values.\"\"\"\n    \n    def __init__(self, org_url, credential):\n        self.client = DataverseClient(org_url, credential)\n        self.model = None\n    \n    def train_on_historical_data(self, table_name, features, target):\n        \"\"\"Train prediction model on historical data.\"\"\"\n        # Collect training data\n        records = []\n        for page in self.client.get(table_name, select=features + [target]):\n            records.extend(page)\n        \n        df = pd.DataFrame(records)\n        \n        # Train model\n        X = df[features].fillna(0)\n        y = df[target]\n        \n        self.model = RandomForestRegressor()\n        self.model.fit(X, y)\n        \n        return self.model.score(X, y)\n    \n    def predict_field_values(self, table_name, record_id, features_data):\n        \"\"\"Predict missing field values.\"\"\"\n        if self.model is None:\n            raise ValueError(\"Model not trained. Call train_on_historical_data first.\")\n        \n        # Predict\n        prediction = self.model.predict([features_data])[0]\n        \n        # Return prediction with confidence\n        return {\n            'record_id': record_id,\n            'predicted_value': prediction,\n            'confidence': self.model.score([features_data], [prediction])\n        }\n```\n\n---\n\n## 6. Integration with AI/ML Services\n\n### LLM Integration Pattern\n```python\n# Using LLM to interpret Dataverse data\nfrom openai import OpenAI\n\nclass DataInsightAgent:\n    \"\"\"Use LLM to generate insights from Dataverse data.\"\"\"\n    \n    def __init__(self, org_url, credential, openai_key):\n        self.client = DataverseClient(org_url, credential)\n        self.llm = OpenAI(api_key=openai_key)\n    \n    def analyze_with_llm(self, table_name, sample_size=100):\n        \"\"\"Analyze data using LLM.\"\"\"\n        # Get sample data\n        records = []\n        count = 0\n        for page in self.client.get(table_name):\n            records.extend(page)\n            count += len(page)\n            if count \u003e= sample_size:\n                break\n        \n        # Create summary for LLM\n        summary = f\"\"\"\n        Table: {table_name}\n        Total records sampled: {len(records)}\n        \n        Sample data:\n        {json.dumps(records[:5], indent=2, default=str)}\n        \n        Provide insights about this data.\n        \"\"\"\n        \n        # Ask LLM\n        response = self.llm.chat.completions.create(\n            model=\"gpt-4\",\n            messages=[{\"role\": \"user\", \"content\": summary}]\n        )\n        \n        return response.choices[0].message.content\n```\n\n---\n\n## 7. Secure Impersonation \u0026 Audit Trails\n\n### Planned Capabilities\n\nThe SDK will support running operations on behalf of specific users:\n\n```python\n# Conceptual pattern - specific APIs pending GA\nfrom dataverse_security import ImpersonationContext\n\n# Run as different user\nwith ImpersonationContext(client, user_id=\"user-guid\"):\n    # All operations run as this user\n    client.create(\"account\", {\"name\": \"New Account\"})\n    # Audit trail: Created by [user-guid] at [timestamp]\n\n# Retrieve audit trail\naudit_log = client.get_audit_trail(\n    table=\"account\",\n    record_id=\"record-guid\",\n    action=\"create\"\n)\n```\n\n---\n\n## 8. Compliance and Data Governance\n\n### Planned Governance Features\n\n```python\n# Conceptual pattern - specific APIs pending GA\nfrom dataverse_governance import DataGovernance\n\n# Define retention policy\ngovernance = DataGovernance(client)\ngovernance.set_retention_policy(\n    table=\"account\",\n    retention_days=365\n)\n\n# Define data classification\ngovernance.classify_columns(\n    table=\"account\",\n    classifications={\n        \"name\": \"Public\",\n        \"telephone1\": \"Internal\",\n        \"creditlimit\": \"Confidential\"\n    }\n)\n\n# Enforce policies\ngovernance.enforce_all_policies()\n```\n\n---\n\n## 9. Current SDK Capabilities Supporting Agentic Workflows\n\nWhile full agentic features are in preview, current SDK capabilities already support agent building:\n\n### ✅ Available Now\n- **CRUD Operations** - Create, retrieve, update, delete data\n- **Bulk Operations** - Process large datasets efficiently\n- **Query Capabilities** - OData and SQL for flexible data retrieval\n- **Metadata Operations** - Work with table and column definitions\n- **Error Handling** - Structured exception hierarchy\n- **Pagination** - Handle large result sets\n- **File Upload** - Manage document attachments\n\n### 🔜 Coming in GA\n- Full MCP integration\n- A2A collaboration primitives\n- Enhanced authentication/impersonation\n- Governance policy enforcement\n- Native async/await support\n- Advanced caching strategies\n\n---\n\n## 10. Getting Started: Build Your First Agent Today\n\n```python\nfrom PowerPlatform.Dataverse.client import DataverseClient\nfrom azure.identity import InteractiveBrowserCredential\nimport json\n\nclass SimpleDataAgent:\n    \"\"\"Your first Dataverse agent.\"\"\"\n    \n    def __init__(self, org_url):\n        credential = InteractiveBrowserCredential()\n        self.client = DataverseClient(org_url, credential)\n    \n    def check_health(self, table_name):\n        \"\"\"Agent function: Check table health.\"\"\"\n        try:\n            tables = self.client.list_tables()\n            matching = [t for t in tables if t['LogicalName'] == table_name]\n            \n            if not matching:\n                return {\"status\": \"error\", \"message\": f\"Table {table_name} not found\"}\n            \n            # Get record count\n            records = []\n            for page in self.client.get(table_name):\n                records.extend(page)\n                if len(records) \u003e 1000:\n                    break\n            \n            return {\n                \"status\": \"healthy\",\n                \"table\": table_name,\n                \"record_count\": len(records),\n                \"timestamp\": pd.Timestamp.now().isoformat()\n            }\n        \n        except Exception as e:\n            return {\"status\": \"error\", \"message\": str(e)}\n\n# Usage\nagent = SimpleDataAgent(\"https://\u003corg\u003e.crm.dynamics.com\")\nhealth = agent.check_health(\"account\")\nprint(json.dumps(health, indent=2))\n```\n\n---\n\n## 11. Resources \u0026 Documentation\n\n### Official Documentation\n- [Dataverse SDK for Python Overview](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/sdk-python/overview)\n- [Working with Data](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/sdk-python/work-data)\n- [Release Plan: Agentic Workflows](https://learn.microsoft.com/en-us/power-platform/release-plan/2025wave2/data-platform/build-agentic-flows-dataverse-sdk-python)\n\n### External Resources\n- [Model Context Protocol](https://modelcontextprotocol.io/)\n- [Azure AI Services](https://learn.microsoft.com/en-us/azure/ai-services/)\n- [Python async/await](https://docs.python.org/3/library/asyncio.html)\n\n### Repository\n- [SDK Source Code](https://github.com/microsoft/PowerPlatform-DataverseClient-Python)\n- [Issues \u0026 Feature Requests](https://github.com/microsoft/PowerPlatform-DataverseClient-Python/issues)\n\n---\n\n## 12. FAQ: Agentic Workflows\n\n**Q: Can I use agents today with the current SDK?**  \nA: Yes! Use the current capabilities to build agent-like systems. Full MCP/A2A support coming in GA.\n\n**Q: What's the difference between current SDK and agentic features?**  \nA: Current: Synchronous CRUD; Agentic: Async, autonomous decision-making, agent collaboration.\n\n**Q: Will there be breaking changes from preview to GA?**  \nA: Possibly. This is a preview feature; expect API refinements before general availability.\n\n**Q: How do I prepare for agentic workflows today?**  \nA: Build agents using current CRUD operations, design with async patterns in mind, use MCP specs for future compatibility.\n\n**Q: Is there a cost difference for agentic features?**  \nA: Unknown at this time. Check release notes closer to GA.\n\n---\n\n## 13. Next Steps\n\n1. **Build a prototype** using current SDK capabilities\n2. **Join preview** when MCP integration becomes available\n3. **Provide feedback** via GitHub issues\n4. **Watch for GA announcement** with full API documentation\n5. **Migrate to full agentic** features when ready\n\nThe Dataverse SDK for Python is positioning itself as the go-to platform for building intelligent, autonomous data systems on the Microsoft Power Platform.\n","description":"**Status**: This feature is in **Public Preview** as of December 2025","import":{"commit_sha":"541b7819d8c3545c6df122491af4fa1eae415779","imported_at":"2026-05-18T20:05:35Z","license_text":"MIT License\n\nCopyright GitHub, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","owner":"github","repo":"github/awesome-copilot","source_url":"https://github.com/github/awesome-copilot/blob/541b7819d8c3545c6df122491af4fa1eae415779/instructions/dataverse-python-agentic-workflows.instructions.md"},"manifest":{}},"content_hash":[66,38,178,168,217,238,219,175,58,172,169,130,95,112,128,77,165,51,247,153,64,207,134,1,173,38,38,40,15,129,235,138],"trust_level":"unsigned","yanked":false}
