Skip to content

Add agent framework example (and remove sample for chatprompt and mcp client) #386

Merged
MehakBindra merged 14 commits into
mainfrom
mehak/msft-ai-samples
Apr 21, 2026
Merged

Add agent framework example (and remove sample for chatprompt and mcp client) #386
MehakBindra merged 14 commits into
mainfrom
mehak/msft-ai-samples

Conversation

@MehakBindra

@MehakBindra MehakBindra commented Apr 13, 2026

Copy link
Copy Markdown
Member

This pull request introduces a new example app, ai-agentframework, which demonstrates building a Microsoft Teams bot using the agent-framework library and Azure OpenAI. The new sample includes streaming responses, inline citations, per-conversation memory, and integration with Microsoft Graph and remote MCP servers. Additionally, the old ai-test sample and its configuration have been removed. The most important changes are summarized below:

New Teams AI Agent Example:

  • Added a new ai-agentframework example under examples/ with a comprehensive README describing setup, features, and architecture.
  • Implemented core bot files:
    • src/main.py: Teams App entry point, message handling, streaming, citations, and feedback collection.
    • src/agent.py: Agent and middleware setup, OpenAI client configuration, and tool registration.
    • src/local_tools.py: Microsoft Graph-backed local tools for org directory, org hierarchy, team membership, and presence.
    • src/mcp_tools.py: Declaration of remote MCP tool servers (e.g., Microsoft Learn search).
  • Added a pyproject.toml for the new example, specifying dependencies and project metadata.

Removal of Old AI Test Example:

  • Removed the ai-test example's README and pyproject.toml, effectively deprecating the previous sample in favor of the new ai-agentframework example. [1] [2]

Copilot AI review requested due to automatic review settings April 13, 2026 21:49
@MehakBindra
MehakBindra marked this pull request as draft April 13, 2026 21:49

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

This PR updates the repository’s example apps by replacing older AI/MCP samples with a new agent-framework-based Teams bot sample, and refreshes the workspace lockfile accordingly.

Changes:

  • Add a new examples/ai-agentframework sample that uses agent-framework + Azure AI Foundry, with streaming, tools, and citations.
  • Remove the legacy examples/ai-test and examples/mcp-client samples.
  • Update uv.lock to reflect new/removed example dependencies (including significant dependency graph changes).

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
uv.lock Updates workspace resolution for new example dependencies and removes old example entries.
examples/mcp-client/src/main.py Removes the MCP client sample implementation.
examples/mcp-client/pyproject.toml Removes the MCP client sample project metadata/deps.
examples/mcp-client/README.md Removes MCP client sample documentation.
examples/ai-test/src/main.py Removes the legacy AI test sample entrypoint.
examples/ai-test/src/handlers/plugins.py Removes legacy AI plugin example code.
examples/ai-test/src/handlers/memory_management.py Removes legacy memory management helper code.
examples/ai-test/src/handlers/function_calling.py Removes legacy function calling example code.
examples/ai-test/src/handlers/feedback_management.py Removes legacy feedback storage/handling example code.
examples/ai-test/src/handlers/citations.py Removes legacy citations demo code.
examples/ai-test/src/handlers/init.py Removes legacy handler package exports.
examples/ai-test/pyproject.toml Removes AI test sample project metadata/deps.
examples/ai-test/README.md Removes AI test sample documentation.
examples/ai-agentframework/src/mcp_tools.py Adds MCP tool configuration for the new agent-framework sample.
examples/ai-agentframework/src/main.py Adds the new sample’s Teams bot entrypoint with streaming + feedback + citation attachment.
examples/ai-agentframework/src/local_tools.py Adds local deterministic tools (datetime/math/random/exchange-rate).
examples/ai-agentframework/src/instructions.txt Adds system instructions for citation behavior and response formatting.
examples/ai-agentframework/src/agent.py Adds agent setup (Foundry client, tools, middleware, citation extraction).
examples/ai-agentframework/pyproject.toml Adds project metadata and dependencies for the new sample.
examples/ai-agentframework/README.md Adds setup/run docs for the new agent-framework sample.

Comment thread examples/ai-agentframework/src/local_tools.py Outdated
Comment thread examples/ai-agentframework/src/main.py Outdated
Comment thread examples/ai-agentframework/src/main.py Outdated
Comment thread examples/ai-agentframework/src/agent.py Outdated
Comment thread examples/ai-agentframework/src/agent.py Outdated
Comment thread examples/ai-agentframework/src/local_tools.py Outdated
@MehakBindra MehakBindra changed the title agent framework sample Add AI Add agent framework example (and remove sample for chatprompt and mcp client) Apr 13, 2026
@MehakBindra MehakBindra changed the title Add AI Add agent framework example (and remove sample for chatprompt and mcp client) Add agent framework example (and remove sample for chatprompt and mcp client) Apr 13, 2026
@MehakBindra
MehakBindra marked this pull request as ready for review April 14, 2026 00:23
Comment thread examples/ai-agentframework/README.md Outdated
Comment thread examples/ai-agentframework/src/agent.py Outdated
Comment thread examples/ai-agentframework/src/main.py
Comment thread examples/ai-agentframework/README.md Outdated
Comment thread examples/ai-agentframework/README.md Outdated
Comment thread examples/ai-agentframework/README.md Outdated
Comment thread examples/ai-agentframework/README.md Outdated
Comment thread examples/ai-agentframework/README.md
Comment thread examples/ai-agentframework/src/main.py
Comment thread examples/ai-agentframework/src/main.py Outdated
Comment thread examples/ai-agentframework/src/agent.py Outdated
Comment thread examples/ai-agentframework/src/main.py Outdated
Comment thread examples/ai-agentframework/README.md
Comment thread examples/ai-agentframework/README.md Outdated

@heyitsaamir heyitsaamir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A few questions, but it's starting to look good!

Comment thread examples/ai-agentframework/src/agent.py Outdated
Comment thread examples/ai-agentframework/src/agent.py Outdated
Comment thread examples/ai-agentframework/src/instructions.txt Outdated
Comment thread examples/ai-agentframework/src/local_tools.py Outdated
Comment thread examples/ai-agentframework/src/local_tools.py Outdated
Comment thread examples/ai-agentframework/src/instructions.txt Outdated
@MehakBindra
MehakBindra merged commit 67c55b2 into main Apr 21, 2026
4 checks passed
@MehakBindra
MehakBindra deleted the mehak/msft-ai-samples branch April 21, 2026 23:13
E-G-C pushed a commit to E-G-C/teams.py that referenced this pull request Apr 25, 2026
## Plan: Add OAuth Support for Regional Bots ✅ COMPLETE

This PR implements OAuth support for regional bots in Python, mirroring
the TypeScript implementation.

### Summary of Changes

#### API Layer (`packages/api`)
- **`ApiClientSettings`**: New dataclass for OAuth endpoint
configuration
  - Defaults to `https://token.botframework.com`
- Supports regional endpoints (e.g.,
`https://europe.token.botframework.com`)
  - Reads from `OAUTH_URL` environment variable
- **`BaseClient`**: Now handles `api_client_settings` for all subclasses
  - Added `api_client_settings` parameter to constructor
  - Calls `merge_api_client_settings` internally
  - All client subclasses inherit this functionality
- **Client updates**: All API clients now inherit settings handling from
BaseClient
- **Endpoint constants**: Added for maintainability
- **Docstrings**: Updated to "Optional API client settings." for
consistency

#### Apps Layer (`packages/apps`)
- **`AppOptions.default_connection_name`**: OAuth connection name
(defaults to "graph")
- **`AppOptions.api_client_settings`**: Top-level field for API client
configuration
- **Removed `OAuthSettings`**: Simplified API by keeping all config in
`AppOptions`
- **Updated references**: Changed from
`options.oauth.default_connection_name` to
`options.default_connection_name`

### Example Usage

```python
from microsoft.teams.api import ApiClientSettings
from microsoft.teams.apps import App

# Configure for Europe region
app = App(
    default_connection_name='graph',
    api_client_settings=ApiClientSettings(
        oauth_url="https://europe.token.botframework.com"
    )
)
```

### Testing
- All 109 API unit tests passing
- Linting passed (ruff)
- Type checking passed (pyright)

### Latest Changes
- ✅ Moved `api_client_settings` handling to `BaseClient` for inheritance
- ✅ All client subclasses now pass settings to BaseClient constructor
- ✅ Removed duplicate `merge_api_client_settings` calls from subclasses
- ✅ Simplified imports by removing unused `merge_api_client_settings`
imports

<!-- START COPILOT CODING AGENT SUFFIX -->



<details>

<summary>Original prompt</summary>

> in the Python repository, apply similar changes to this Typescript PR
<a href="microsoft/teams.ts#386" rel="noreferrer
noopener" title="microsoft/teams.ts#386"
target="_blank">[apps/api] feat: allow oauth for regional bots by
lilyydu · Pull Request microsoft#386 · microsoft/teams.ts</a> <attachment
id="app-preview-card-ps8c1976db18534edbae026f7a1afc8b5e"></attachment>


</details>



<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: lilyydu <[email protected]>
Co-authored-by: lilydu <[email protected]>
Co-authored-by: Lily Du <[email protected]>
corinagum added a commit that referenced this pull request May 27, 2026
## Summary

Brings `origin/main` into `release` for the **2.0.12** release. **No
carve-outs this time** — Quoted Replies (PR #321) is included.

`version.json`: `2.0.11` → `2.0.12`.

Aligns with teams.ts/teams.net cadence.

## What's in this release (delta from 2.0.11)

**Features**
- Quoted Replies & new quotes features (#321) — previously held back
- SuggestedActionSubmitActivity for `suggestedAction/submit` invoke
(#434)
- Default targeted replies for targeted inbound messages (#439)
- Reactions API marked GA (#427) — already shipped in 2.0.11 actually,
ignore if duplicate
- Prompt Preview support (#397)
- Sample: opt targeted-messages into slash commands (#430)
- Sample: a2a-in-teams (#401)
- Sample: proactive message update (#405)
- Allow custom HTTP client via `AppOptions` (#416)

**Security & fixes**
- Lock JsonWebToken trust-boundary contract (#432)
- Bump starlette 1.0.0 -> 1.1.0 for PYSEC-2026-161 / BadHost (#441)
- warn when bot starts without credentials (#435)
- fix(apps): support AAD v1 issuers in Entra token validation (#422)
- fix(apps): log inbound activities at info, warn on missing
Authorization (#425)
- fix(http-stream): wait for in-flight flush before sending final close
(#419)
- Mark reactions API as GA and fix sample remove flow (#427)
- Revert serviceUrl allowlist (ADO 5310460) (#415)
- Route `app.get_app_graph` + `ctx.*_graph` to sovereign endpoints via
`cloud.graph_scope` (#402)

**Deprecations / package changes**
- Remove ai, openai, mcpplugin, a2a, and devtools packages (#413)
- Restore and deprecate devtools package (#410)
- Deprecate ai, openai, mcpplugin, a2a packages (#406)
- Add agent framework example, remove chatprompt/mcp client samples
(#386)

**Dependency bumps**
- urllib3 2.6.3 → 2.7.0 (#426)
- python-multipart 0.0.26 → 0.0.27 (#424)
- microsoft-kiota-http 1.9.7 → 1.9.9 (#423)
- idna 3.11 → 3.15 (#431)
- starlette 1.0.0 → 1.1.0 (#441, security)
- /examples/tab/Web: qs, postcss, uuid, follow-redirects bumps

## Quoted Replies inclusion notes

- Teams client rendering is in-sync with the wire format as of
2026-05-06.
- APX QR rollout completed: Public 2026-04-10, GCCH/DoD/Gallatin
2026-04-14.
- Builder methods (`prepend_quote()`, `add_quote()`), `ctx.quote()`, and
the quote-aware `ctx.reply()` behavior are all present in this release.
- `examples/quoting` is included.

## Conflict resolution

The 2.0.11 release branch had the QR-removed shape for four files; took
`main`'s (QR-included) version for all of them:
- `examples/targeted-messages/src/main.py`
- `packages/api/src/microsoft_teams/api/activities/message/message.py`
- `packages/apps/src/microsoft_teams/apps/routing/activity_context.py`
- `packages/apps/tests/test_activity_context.py`

`version.json` conflict resolved to `2.0.12`.

## Test plan

- [x] `uv sync` clean
- [x] `poe check` (ruff format + lint) — clean
- [x] `poe test` — 609 passed
- [x] `pyright` — 0 errors, 0 warnings
- [ ] Pipeline build + test stages green on `release` after merge
- [ ] Publish pipeline run with **Public** → ESRP approval → PyPI
- [ ] `pip install microsoft-teams-apps==2.0.12` smoke install

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Aamir Jawaid <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Co-authored-by: Shanmathi Mayuram Krithivasan <[email protected]>
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.

4 participants