Skip to content

Commit a1f75ea

Browse files
author
Jesus Terrazas
committed
Merge branch 'main' into users/jterrazas/google-adk-support
2 parents 76050f5 + abdf5ec commit a1f75ea

File tree

164 files changed

+15112
-665
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+15112
-665
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
* @microsoft/agent365-approvers
33
/.github/ @microsoft/agent365-approvers
44
/libraries/microsoft-agents-a365-observability-*/ @microsoft/agent365-observability-approvers
5-
/tests/observability/ @microsoft/agent365-observability-approvers
5+
/tests/observability/ @microsoft/agent365-observability-approvers
6+
/libraries/microsoft-agents-a365-notifications/ @microsoft/agent365-tooling-approvers
7+
/libraries/microsoft-agents-a365-tooling*/ @microsoft/agent365-tooling-approvers
8+
/tests/tooling/ @microsoft/agent365-tooling-approvers

.github/workflows/ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,13 @@ jobs:
105105

106106
- name: Install the project
107107
run: uv lock && uv sync --locked --all-extras --dev
108-
108+
109+
- name: Verify centralized version constraints
110+
run: python scripts/verify_constraints.py
111+
109112
- name: Check linting
110113
run: |
111-
uv run --frozen ruff check .
112-
continue-on-error: true
114+
uv run --frozen ruff check . --preview
113115
114116
- name: Check formatting
115117
run: |

CLAUDE.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,34 @@ libraries/
136136
- MCP (Model Context Protocol) integration
137137
- Framework-specific adapters for tool execution
138138

139+
### Centralized Dependency Version Management
140+
141+
This monorepo uses uv's `constraint-dependencies` feature to centralize version constraints:
142+
143+
**How it works:**
144+
1. **Root pyproject.toml** defines version constraints for all external packages
145+
2. **Package pyproject.toml** files declare dependencies by name only (no version)
146+
3. **uv** applies root constraints during dependency resolution
147+
148+
**Adding a new dependency:**
149+
1. Add the package name to your package's `dependencies` array
150+
2. Add the version constraint to root `pyproject.toml` `constraint-dependencies`
151+
3. Run `uv lock && uv sync`
152+
153+
**Updating a dependency version:**
154+
1. Edit the constraint in root `pyproject.toml` only
155+
2. Run `uv lock && uv sync`
156+
3. All packages automatically use the new version
157+
158+
**Internal workspace dependencies:**
159+
- Package pyproject.toml files list internal deps by name only (e.g., `microsoft-agents-a365-runtime`)
160+
- Root pyproject.toml `[tool.uv.sources]` maps them to `{ workspace = true }` for local development
161+
- At build time, `setup.py` injects exact version matches (e.g., `== 1.2.3`) for published packages
162+
- This ensures all SDK packages require the exact same version of each other
163+
164+
**CI Enforcement:** The `scripts/verify_constraints.py` script runs in CI to prevent
165+
accidental reintroduction of version constraints in package files.
166+
139167
### Test Organization
140168

141169
Tests mirror the library structure:
@@ -168,11 +196,45 @@ Place it before imports with one blank line after.
168196

169197
### Python Conventions
170198

171-
- Type hints preferred (Pydantic models heavily used)
199+
- Type hints required on all function parameters and return types
172200
- Async/await patterns for I/O operations
173201
- Use explicit `None` checks: `if x is not None:` not `if x:`
174202
- Local imports should be moved to top of file
175203
- Return defensive copies of mutable data to protect singletons
204+
- **Async method naming**: Do NOT use `_async` suffix on async methods. The `_async` suffix is only appropriate when providing both sync and async versions of the same method. Since this SDK is async-only, use plain method names (e.g., `send_chat_history_messages` not `send_chat_history_messages_async`)
205+
206+
### Type Hints - NEVER Use `Any`
207+
208+
**CRITICAL: Never use `typing.Any` in this codebase.** Using `Any` defeats the purpose of type checking and can hide bugs. Instead:
209+
210+
1. **Use actual types from external SDKs** - When integrating with external libraries (OpenAI, LangChain, etc.), import and use their actual types:
211+
```python
212+
from agents.memory import Session
213+
from agents.items import TResponseInputItem
214+
215+
async def send_chat_history(self, session: Session) -> OperationResult:
216+
...
217+
```
218+
219+
2. **Use `Union` for known possible types**:
220+
```python
221+
from typing import Union
222+
MessageType = Union[UserMessage, AssistantMessage, SystemMessage, Dict[str, object]]
223+
```
224+
225+
3. **Use `object` for truly unknown types** that you only pass through:
226+
```python
227+
def log_item(item: object) -> None: ...
228+
```
229+
230+
4. **Use `Protocol` only as a last resort** - If external types cannot be found or imported, define a Protocol. However, **confirm with the developer first** before proceeding with this approach, as it may indicate a missing dependency or incorrect understanding of the external API.
231+
232+
**Why this matters:**
233+
- `Any` disables all type checking for that variable
234+
- Bugs that type checkers would catch go unnoticed
235+
- Code readability suffers - developers don't know what types to expect
236+
- Using actual SDK types provides better IDE support and ensures compatibility
237+
- This applies to both production code AND test files
176238

177239
## CI/CD
178240

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
[![PyPI](https://img.shields.io/pypi/v/microsoft-agents-a365-observability-core?label=PyPI&logo=pypi)](https://pypi.org/search/?q=microsoft-agents-a365)
44
[![PyPI Downloads](https://img.shields.io/pypi/dm/microsoft-agents-a365-observability-core?label=Downloads&logo=pypi)](https://pypi.org/search/?q=microsoft-agents-a365)
5-
[![Build Status](https://img.shields.io/github/actions/workflow/status/microsoft/Agent365-python/.github/workflows/ci.yml?branch=main&label=Build&logo=github)](https://github.com/microsoft/Agent365-python/actions)
5+
[![CI - Build, Test, and Publish SDKs](https://github.com/microsoft/Agent365-python/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/microsoft/Agent365-python/actions/workflows/ci.yml)
6+
[![CodeQL](https://github.com/microsoft/Agent365-python/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/microsoft/Agent365-python/actions/workflows/github-code-scanning/codeql)
67
[![License](https://img.shields.io/github/license/microsoft/Agent365-python?label=License)](LICENSE.md)
78
[![Python Version](https://img.shields.io/badge/Python-3.10%2B-3776AB?logo=python)](https://www.python.org/)
89
[![Contributors](https://img.shields.io/github/contributors/microsoft/Agent365-python?label=Contributors&logo=github)](https://github.com/microsoft/Agent365-python/graphs/contributors)

docs/design.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,51 @@ Framework-specific adapters for MCP tool integration:
227227
|---------|---------|------------|
228228
| `extensions-agentframework` | Adapt MCP tools to Microsoft Agents SDK | [design.md](../libraries/microsoft-agents-a365-tooling-extensions-agentframework/docs/design.md) |
229229
| `extensions-azureaifoundry` | Azure AI Foundry tool integration | [design.md](../libraries/microsoft-agents-a365-tooling-extensions-azureaifoundry/docs/design.md) |
230-
| `extensions-openai` | OpenAI function calling integration | [design.md](../libraries/microsoft-agents-a365-tooling-extensions-openai/docs/design.md) |
230+
| `extensions-openai` | OpenAI function calling integration and chat history | [design.md](../libraries/microsoft-agents-a365-tooling-extensions-openai/docs/design.md) |
231231
| `extensions-semantickernel` | Semantic Kernel plugin integration | [design.md](../libraries/microsoft-agents-a365-tooling-extensions-semantickernel/docs/design.md) |
232232

233+
#### OpenAI Extension: Chat History API
234+
235+
The OpenAI tooling extension provides methods to send chat history to the MCP platform for real-time threat protection:
236+
237+
**Key Classes:**
238+
239+
| Class | Purpose |
240+
|-------|---------|
241+
| `McpToolRegistrationService` | MCP tool registration and chat history management |
242+
243+
**Methods:**
244+
245+
| Method | Purpose |
246+
|--------|---------|
247+
| `send_chat_history(turn_context, session, limit, options)` | Extract messages from OpenAI Session and send to MCP platform |
248+
| `send_chat_history_messages(turn_context, messages, options)` | Send a list of OpenAI TResponseInputItem messages to MCP platform |
249+
250+
**Usage Example:**
251+
252+
```python
253+
from agents import Agent, Runner
254+
from microsoft_agents_a365.tooling.extensions.openai import McpToolRegistrationService
255+
256+
service = McpToolRegistrationService()
257+
agent = Agent(name="my-agent", model="gpt-4")
258+
259+
# In your agent handler:
260+
async with Runner.run(agent, messages) as result:
261+
session = result.session
262+
263+
# Option 1: Send from Session object
264+
op_result = await service.send_chat_history(turn_context, session)
265+
266+
# Option 2: Send from message list
267+
op_result = await service.send_chat_history_messages(turn_context, messages)
268+
269+
if op_result.succeeded:
270+
print("Chat history sent successfully")
271+
```
272+
273+
The methods convert OpenAI message types to `ChatHistoryMessage` format and delegate to the core `McpToolServerConfigurationService.send_chat_history()` method.
274+
233275
### 6. Notifications (`microsoft-agents-a365-notifications`)
234276

235277
> **Detailed documentation**: [libraries/microsoft-agents-a365-notifications/docs/design.md](../libraries/microsoft-agents-a365-notifications/docs/design.md)

0 commit comments

Comments
 (0)