Skip to content

feat(python): add Devin AI sample agent with A365 SDK integration#316

Open
Yogeshp-MSFT wants to merge 3 commits into
microsoft:mainfrom
Yogeshp-MSFT:Devin-Sample-Python
Open

feat(python): add Devin AI sample agent with A365 SDK integration#316
Yogeshp-MSFT wants to merge 3 commits into
microsoft:mainfrom
Yogeshp-MSFT:Devin-Sample-Python

Conversation

@Yogeshp-MSFT

Copy link
Copy Markdown

Summary

Adds a Python sample agent that integrates Devin AI with the Microsoft Agent 365 (A365) SDK. This sample is the Python equivalent of the existing Node.js Devin sample and uses the official devinai Python SDK.

Changes Included

New Sample

Added a new sample under:

python/devin/sample-agent

Key Components

File Description
main.py A365 hosting entry point with authentication, observability, handler registration, and typing indicator support
agent.py Agent implementation responsible for message routing and notification handling
client.py Wrapper around the official Devin SDK (AsyncDevinSDK) for session management and message processing
pyproject.toml Python dependencies and project configuration
.env.template Environment variable template
README.md Setup, configuration, deployment, and troubleshooting documentation
manifest/ Teams application manifest and assets
ToolingManifest.json Empty tooling manifest (no MCP tools required)
.vscode/ VS Code launch, task, and debugging configuration
env/ Playground environment configuration
m365agents.yml / m365agents.playground.yml Agents Toolkit configuration files
a365.config.json A365 configuration template

Features Demonstrated

  • A365 Agent Hosting
  • Agentic Authentication
  • Teams Messaging
  • Installation and Uninstallation Events
  • Email Notifications
  • User Identity Handling
  • Typing Indicators
  • OpenTelemetry-based Observability
  • Agents Playground Integration

Architecture

main.py
 └── agent.py
      └── client.py

The sample follows the same structure and conventions used by the existing Python samples in the repository.

Documentation

  • Added a comprehensive README.md
  • Included setup instructions
  • Added local testing guidance
  • Added deployment instructions
  • Added troubleshooting information

Validation Performed

  • ✅ Teams messaging flow tested
  • ✅ Agentic authentication validated
  • ✅ Observability events successfully exported
  • ✅ Health endpoint verified
  • ✅ Agents Playground compatibility verified

Dependencies

  • devinai (official Devin Python SDK)
  • microsoft-opentelemetry
  • Microsoft Agent 365 SDK packages

Sample Structure

python/devin/sample-agent/
├── .env.template
├── .gitignore
├── .vscode/
├── a365.config.json
├── agent.py
├── client.py
├── env/
├── m365agents.playground.yml
├── m365agents.yml
├── main.py
├── manifest/
├── pyproject.toml
├── README.md
└── ToolingManifest.json

@Yogeshp-MSFT Yogeshp-MSFT requested a review from a team as a code owner June 2, 2026 05:17
Copilot AI review requested due to automatic review settings June 2, 2026 05:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new Python “Devin Sample Agent” that hosts an Agent 365-compatible aiohttp service integrating the Devin AI SDK, with notifications support and optional Agent 365 observability.

Changes:

  • Introduces a runnable aiohttp server (main.py) that wires up Agent 365 hosting, auth, notifications, health endpoint, and observability context.
  • Implements a Devin client wrapper (client.py) and a minimal agent implementation (agent.py) that forwards user messages / email notifications to Devin.
  • Adds project/tooling scaffolding (pyproject, env template, Teams/Agents Playground YAML, tooling manifest, docs, gitignore).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
python/devin/sample-agent/pyproject.toml Defines packaging + dependencies for the sample agent project
python/devin/sample-agent/main.py Server entry point: hosting, middleware, handlers, health, observability
python/devin/sample-agent/client.py Devin SDK wrapper + polling + inference-scope telemetry
python/devin/sample-agent/agent.py Agent implementation that delegates to Devin client
python/devin/sample-agent/README.md End-to-end usage docs: local dev, Playground, deployment, troubleshooting
python/devin/sample-agent/.env.template Environment variable template for running locally or in production
python/devin/sample-agent/.gitignore Ignores local state, env files, build artifacts
python/devin/sample-agent/m365agents.yml Agents Toolkit config stub
python/devin/sample-agent/m365agents.playground.yml Playground deployment actions + env file creation
python/devin/sample-agent/ToolingManifest.json Declares MCP server tool metadata

Comment thread python/devin/sample-agent/pyproject.toml
Comment thread python/devin/sample-agent/client.py Outdated
Comment thread python/devin/sample-agent/client.py Outdated
Comment thread python/devin/sample-agent/client.py
Comment thread python/devin/sample-agent/client.py Outdated
Comment thread python/devin/sample-agent/agent.py Outdated
Comment thread python/devin/sample-agent/agent.py
Comment thread python/devin/sample-agent/agent.py
Comment thread python/devin/sample-agent/.env.template Outdated
Comment thread python/devin/sample-agent/client.py
@Yogeshp-MSFT

Copy link
Copy Markdown
Author

Hi @biswapm can you review this ?

@Yogeshp-MSFT Yogeshp-MSFT force-pushed the Devin-Sample-Python branch from 8d5e40c to c3b7c7a Compare June 10, 2026 05:52
- client.py: key Devin session state by Agent 365 conversation.id so
  multi-user / multi-turn flows do not leak context between users
- client.py: persist seen_event_ids per session so follow-up turns return
  only the new reply instead of the full history
- client.py: parse POLLING_INTERVAL_SECONDS defensively; fall back to
  the default with a warning on invalid input
- client.py: add comment explaining 'devinai' (PyPI) vs 'devin_sdk' (import)
- agent.py: return a generic error message instead of exposing the raw
  exception text; document why auth / auth_handler_name are accepted but
  not used for the Devin SDK
- main.py: same generic-error-message change in the message and
  notification handlers
- .env.template: default AUTH_HANDLER_NAME to empty to match the comment
  and README guidance for Agents Playground / local dev
@Yogeshp-MSFT Yogeshp-MSFT requested a review from Copilot June 10, 2026 06:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Comment thread python/devin/sample-agent/pyproject.toml
Comment thread python/devin/sample-agent/pyproject.toml Outdated
Comment thread python/devin/sample-agent/m365agents.playground.yml
Comment thread python/devin/sample-agent/client.py
Comment thread python/devin/sample-agent/client.py
- client.py: replace unbounded session dict with an OrderedDict-based LRU
  cache (default 1000, override with DEVIN_MAX_SESSIONS). Long-running
  processes that handle many distinct conversations no longer leak memory.
- client.py: drop the per-conversation session state once the Devin
  session reaches a terminal status so finished conversations stop
  consuming cache space.
- client.py: use uuid.uuid4() instead of a millisecond timestamp for the
  fallback conversation_id so concurrent requests can't collide and
  accidentally share session state.
- pyproject.toml: drop spaces around version operators in dependency
  specifiers (PEP 508 canonical form).
- m365agents.playground.yml: write AUTH_HANDLER_NAME (the variable the
  server actually reads) instead of USE_AGENTIC_AUTH, and document what
  the two valid values mean for Playground / production.
@Yogeshp-MSFT Yogeshp-MSFT requested a review from Copilot June 10, 2026 06:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment thread python/devin/sample-agent/pyproject.toml
Comment thread python/devin/sample-agent/client.py
Comment thread python/devin/sample-agent/agent.py
Comment thread python/devin/sample-agent/agent.py
@Yogeshp-MSFT

Copy link
Copy Markdown
Author

Hi @biswapm @microsoft/agent365-approvers please review this pr?

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.

2 participants