Skip to content

Conversation

@dmytrostruk
Copy link
Member

Motivation and Context

This PR contains an implementation of create/get API with Provider type for OpenAI Assistants chat client, based on Option 2 from this ADR.

Example:

from agent_framework.openai import OpenAIAssistantProvider
from openai import OpenAI

client = OpenAI()
provider = OpenAIAssistantProvider(client)

agent = await provider.create_agent(name="MyAssistant", model="gpt-4", instructions="...")
agent = await provider.get_agent(assistant_id="asst_123")
agent = provider.as_agent(assistant)

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@dmytrostruk dmytrostruk self-assigned this Jan 13, 2026
Copilot AI review requested due to automatic review settings January 13, 2026 21:01
@dmytrostruk dmytrostruk added documentation Improvements or additions to documentation python labels Jan 13, 2026
Copy link
Contributor

Copilot AI left a comment

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 introduces a new OpenAIAssistantProvider class that provides a clean, provider-based API for creating and managing OpenAI Assistant agents. This implements Option 2 from ADR #2618, offering three key methods: create_agent() to create new assistants, get_agent() to retrieve existing assistants by ID, and as_agent() to wrap SDK Assistant objects without additional HTTP calls.

Changes:

  • Added OpenAIAssistantProvider class with create/get/as_agent methods
  • Refactored tool conversion utilities to shared module for reuse
  • Updated all OpenAI Assistants samples to use the new provider API
  • Added comprehensive unit tests for the provider

Reviewed changes

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

Show a summary per file
File Description
python/packages/core/agent_framework/openai/_assistant_provider.py New provider class with create_agent, get_agent, and as_agent methods
python/packages/core/agent_framework/openai/_shared.py Added tool conversion utilities (to_assistant_tools, from_assistant_tools)
python/packages/core/agent_framework/openai/_assistants_client.py Refactored to use shared tool conversion utilities
python/packages/core/agent_framework/openai/__init__.py Exports the new OpenAIAssistantProvider
python/packages/core/tests/openai/test_assistant_provider.py Comprehensive unit tests covering all provider functionality
python/samples/getting_started/agents/openai/openai_assistants_basic.py Updated to use provider API
python/samples/getting_started/agents/openai/openai_assistants_provider_methods.py New sample demonstrating all provider methods
python/samples/getting_started/agents/openai/openai_assistants_with_response_format.py New sample showing structured output with response_format
python/samples/getting_started/agents/openai/openai_assistants_with_thread.py Updated to use provider API
python/samples/getting_started/agents/openai/openai_assistants_with_function_tools.py Updated to use provider API
python/samples/getting_started/agents/openai/openai_assistants_with_file_search.py Updated to use provider API
python/samples/getting_started/agents/openai/openai_assistants_with_code_interpreter.py Updated to use provider API
python/samples/getting_started/agents/openai/openai_assistants_with_explicit_settings.py Updated to use provider API
python/samples/getting_started/agents/openai/openai_assistants_with_existing_assistant.py Updated to demonstrate get_agent and as_agent methods
python/samples/getting_started/agents/openai/README.md Updated documentation for all samples

@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Jan 15, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework/openai
   _assistant_provider.py1091189%153–154, 166, 291, 357, 472–477
   _shared.py1321588%63, 69–72, 150, 152, 159, 161, 174, 250, 274, 338–339, 341
TOTAL17361266684% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3141 213 💤 0 ❌ 0 🔥 1m 5s ⏱️

@dmytrostruk dmytrostruk enabled auto-merge January 15, 2026 22:47
@dmytrostruk dmytrostruk added this pull request to the merge queue Jan 15, 2026
Merged via the queue into microsoft:main with commit b5ca0c8 Jan 15, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants