mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
f3db60fa65
* Python: Support GPT-5 verbosity option and restore Foundry agent_reference Adds verbosity as a typed Literal["low","medium","high"] field on OpenAIChatOptions (Responses API) and OpenAIChatCompletionOptions (Chat Completions API), set in the same way as the existing reasoning options. For the Responses API, top-level verbosity is translated to the nested text.verbosity shape the OpenAI service expects. The same field flows through to FoundryChatClient via the existing FoundryChatOptions alias. Also fixes #5582: PR #5447 removed the agent_reference injection from RawFoundryAgentChatClient._prepare_options, so first-turn calls against a Foundry Prompt Agent went out without model and without agent_reference and were rejected by the Responses API with "Missing required parameter: 'model'". Restores the injection on the non-preview path (allow_preview=False) and adds a guard test that asserts the preview path does not inject agent_reference, since the preview SDK injects it via project_client.get_openai_client(agent_name=...). Closes #5516 Closes #5582 * Python: Address Copilot review on PR #5619 - Foundry verbosity sample docstring: replace the misleading "set deployment name on model=" instruction with the actual env-var pattern the sample relies on (FOUNDRY_PROJECT_ENDPOINT and FOUNDRY_MODEL). - _build_agent_reference docstring: clarify the helper is used for both Prompt Agents and HostedAgents on the non-preview path. - Add a Responses API test that locks in the documented precedence rule: when both top-level verbosity and text["verbosity"] are supplied, the top-level value wins. * Python: Drop redundant Foundry verbosity sample and list OpenAI sample in README - Remove samples/02-agents/providers/foundry/foundry_chat_client_verbosity.py per review feedback. The verbosity functionality is identical across the OpenAI and Foundry clients (FoundryChatOptions is an alias of OpenAIChatOptions), so a single sample on the OpenAI side is sufficient. - Add the new client_verbosity.py entry to the OpenAI samples README.
f3db60fa65
ยท
2026-05-04 21:21:40 +00:00
History
OpenAI Provider Samples
This folder contains OpenAI provider samples for the generic clients in
agent_framework.openai.
Chat Completions API samples (OpenAIChatCompletionClient)
| File | Description |
|---|---|
chat_completion_client_basic.py |
Basic non-streaming and streaming chat completion sample with an explicit gpt-5.4-nano model and API key. |
chat_completion_client_with_explicit_settings.py |
Chat completion sample with explicit model and API key settings. |
chat_completion_client_with_function_tools.py |
Function tools with agent-level and run-level patterns. |
chat_completion_client_with_local_mcp.py |
Local MCP integration with the chat completions client. |
chat_completion_client_with_runtime_json_schema.py |
Runtime JSON schema output with the chat completions client. |
chat_completion_client_with_session.py |
Session management with the chat completions client. |
chat_completion_client_with_web_search.py |
Web search with the chat completions client. |
Responses API samples (OpenAIChatClient)
| File | Description |
|---|---|
client_basic.py |
Basic non-streaming and streaming responses sample with an explicit gpt-5.4-nano model and API key. |
client_image_analysis.py |
Analyze images with the responses client. |
client_image_generation.py |
Generate images from text prompts. |
client_reasoning.py |
Reasoning-focused sample for models such as gpt-5. |
client_streaming_image_generation.py |
Streaming image generation sample. |
client_verbosity.py |
GPT-5 verbosity option (low/medium/high) with default and per-call overrides. |
client_with_agent_as_tool.py |
Agent-as-tool orchestration pattern. |
client_with_code_interpreter.py |
Code interpreter sample. |
client_with_code_interpreter_files.py |
Code interpreter sample with uploaded files. |
client_with_explicit_settings.py |
Responses client with explicit model and API key settings. |
client_with_file_search.py |
Hosted file search sample. |
client_with_function_tools.py |
Function tools with agent-level and run-level patterns. |
client_with_hosted_mcp.py |
Hosted MCP tools and approval workflows. |
client_with_local_mcp.py |
Local MCP integration with the responses client. |
client_with_local_shell.py |
Local shell tool sample. |
client_with_runtime_json_schema.py |
Runtime JSON schema output with the responses client. |
client_with_session.py |
Session management with the responses client. |
client_with_shell.py |
Hosted shell tool sample. |
client_with_structured_output.py |
Structured output with Pydantic models. |
client_with_web_search.py |
Web search with the responses client. |
Environment Variables
Set these before running the OpenAI provider samples:
OPENAI_API_KEYOPENAI_MODEL
Optionally, you can also set:
OPENAI_ORG_IDOPENAI_BASE_URL
If your shell also contains AZURE_OPENAI_* variables, these samples still stay on OpenAI as long as
OPENAI_API_KEY is present. To force Azure routing with the generic clients, pass an explicit Azure
input such as credential, azure_endpoint, or api_version, or use the Azure provider samples.
Optional Dependencies
Some samples need extra packages:
client_image_generation.pyandclient_streaming_image_generation.pyuse Pillow for image display.- MCP samples require the relevant MCP server/tooling you configure locally.