Skip to content

Commit f00fc62

Browse files
authored
Merge branch 'main' into nikhilc/Auto-SK-attributes
2 parents d3ae336 + 56e2831 commit f00fc62

File tree

34 files changed

+6315
-72
lines changed

34 files changed

+6315
-72
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

CLAUDE.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,45 @@ Place it before imports with one blank line after.
168168

169169
### Python Conventions
170170

171-
- Type hints preferred (Pydantic models heavily used)
171+
- Type hints required on all function parameters and return types
172172
- Async/await patterns for I/O operations
173173
- Use explicit `None` checks: `if x is not None:` not `if x:`
174174
- Local imports should be moved to top of file
175175
- Return defensive copies of mutable data to protect singletons
176+
- **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`)
177+
178+
### Type Hints - NEVER Use `Any`
179+
180+
**CRITICAL: Never use `typing.Any` in this codebase.** Using `Any` defeats the purpose of type checking and can hide bugs. Instead:
181+
182+
1. **Use actual types from external SDKs** - When integrating with external libraries (OpenAI, LangChain, etc.), import and use their actual types:
183+
```python
184+
from agents.memory import Session
185+
from agents.items import TResponseInputItem
186+
187+
async def send_chat_history(self, session: Session) -> OperationResult:
188+
...
189+
```
190+
191+
2. **Use `Union` for known possible types**:
192+
```python
193+
from typing import Union
194+
MessageType = Union[UserMessage, AssistantMessage, SystemMessage, Dict[str, object]]
195+
```
196+
197+
3. **Use `object` for truly unknown types** that you only pass through:
198+
```python
199+
def log_item(item: object) -> None: ...
200+
```
201+
202+
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.
203+
204+
**Why this matters:**
205+
- `Any` disables all type checking for that variable
206+
- Bugs that type checkers would catch go unnoticed
207+
- Code readability suffers - developers don't know what types to expect
208+
- Using actual SDK types provides better IDE support and ensures compatibility
209+
- This applies to both production code AND test files
176210

177211
## CI/CD
178212

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)