mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
1fe41e17a90e002aa7f4f834f7ebd9475d80803c
745
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e696dc7d52 |
Python: Add directory allowlist configuration for SessionsPythonTool file (#13467)
### Motivation and Context
When `SessionsPythonTool` is used with an AI model, providing explicit
directory boundaries for file operations gives developers fine-grained
control over which parts of the filesystem the plugin can access. This
follows the pattern established by `HttpPlugin.allowed_domains`.
- Add `allowed_upload_directories` parameter to control which local
directories can be used for file uploads
- Add `allowed_download_directories` parameter for optional restrictions
on file download destinations
- Implement path canonicalization to resolve symlinks and normalize
paths
Usage:
```python
tool = SessionsPythonTool(
credential=credential,
allowed_upload_directories={"/app/data/uploads", "/app/user_files"},
allowed_download_directories={"/app/data/downloads"}, # optional
)
```
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
### Description
- `upload_file` now requires `allowed_upload_directories` to be
configured (deny-by-default)
- `download_file` optionally supports `allowed_download_directories`
(permissive-by-default, since it's not exposed as a kernel function)
- Both parameters accept `set[str]` or `list[str]` for convenience
- Paths are canonicalized using `os.path.realpath()` before validation
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
|
||
|
|
72bc02551f |
Python: added allowed_domains to HttpPlugin (#13462)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Adds allowed_domains setup for HttpPlugin. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 |
||
|
|
1e1fb14d68 |
Python: Bump Python version to 1.39.2 for a release (#13459)
### Motivation and Context Bump Python version to 1.39.2 for a release <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Bump Python version to 1.39.2 for a release <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 |
||
|
|
f511c965c1 |
Python: inversed the filter logic for InMemory vector stores (#13457)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Fixes some issues with the forbidden list approach for the in-memory vector store filtering. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 |
||
|
|
adb71bc63b |
Python: Bump to v1.39.1 for a release (#13455)
### Motivation and Context Bump to v1.39.1 for a release <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Bump to v1.39.1 for a release <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 |
||
|
|
e68f09c710 |
Python: adding collection to all for oracle (#13412)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Adding the OracleCollection to the all for oracle ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 |
||
|
|
e50ba67f00 |
Python: improve the filtering of in-memory vector stores (#13440)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Slight improvement to the in-memory vector store filtering. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 |
||
|
|
28e2fa6046 |
INTPYTHON-724 - Add DriverInfo metadata to MongoDB connector (#13379)
### Motivation and Context This PR updates the MongoDB connector to use best practices for DriverInfo while connecting to the database. ### Description ### Contribution Checklist Passing MongoDB connector tests: https://spruce.mongodb.com/task/ai_ml_pipeline_testing_test_semantic_kernel_python_rhel_test_semantic_kernel_python_local_patch_888cccaf0dc36ca794fde4fd82cb1f997e5a4211_69209c01107dec0007300089_25_11_21_17_06_20/logs?execution=0 <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 |
||
|
|
775b8fc1f1 |
Fix YAML agent ignoring model.options execution settings (#13365)
## Summary Fixes #13349 When loading agents from YAML files using `AgentRegistry.create_from_file()` or `create_from_yaml()`, the `model.options` field (containing settings like `response_format`, `temperature`, etc.) were being added as regular `KernelArguments` dict items instead of being placed in the `execution_settings` property. This caused AI service calls to ignore these critical settings. ## Root Cause In `_normalize_spec_fields()` method in `python/semantic_kernel/agents/agent.py`, model options were being passed to `KernelArguments` constructor as `**kwargs`: ```python # OLD (buggy) CODE arguments = KernelArguments(**model_options) ``` This made them regular dict items, but execution settings need to be in the `execution_settings` property to be passed to AI services. ## Changes Modified `_normalize_spec_fields()` in `python/semantic_kernel/agents/agent.py`: - Added import for `PromptExecutionSettings` - Convert model.options to `PromptExecutionSettings` object before creating `KernelArguments` - Model options now correctly placed in `execution_settings` property - Input defaults continue to be added as regular dict items (correct behavior) ## Testing - ✅ Created custom test verifying model.options are now in execution_settings - ✅ All 30 existing unit tests in `tests/unit/agents/test_agent.py` pass - ✅ No breaking changes introduced - ✅ Verified execution_settings passed programmatically still work correctly ## Example YAML file: ```yaml type: chat_completion_agent name: TestAgent description: Test agent instructions: You are a test agent model: options: response_format: structured_output temperature: 0.7 ``` **Before this fix:** - `response_format` was in dict items (wrong location) - AI service calls ignored it **After this fix:** - `response_format` is in `execution_settings.extension_data` - AI service calls receive it properly |
||
|
|
e1fbafe552 |
Python: feat(oracle): add new Oracle connector for Semantic Kernel (#13229)
…ync support ### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> This change is required to enable Semantic Kernel users to store and retrieve embeddings using Oracle databases. Currently, Semantic Kernel supports vector storage for several backends, but Oracle was missing. This connector solves that gap by providing full async support, native VECTOR type handling, and vector index management. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> This PR introduces a new Oracle connector for Semantic Kernel with the following features: - Asynchronous upsert, get, delete and search operations for memory records. - Native Oracle VECTOR type support for storing embeddings efficiently. - Support for HNSW and IVFFLAT vector indexes for similarity search. - Integration with Semantic Kernel collections, enabling semantic search and memory operations. - Comprehensive unit tests to ensure correctness and stability. The connector is designed to work seamlessly with existing Semantic Kernel memory abstractions and follows the same async patterns as other vector stores. Integration tests have also been implemented and verified locally; however, they are not included in this PR because the current CI environment setup for Oracle Database support is unknown. Once guidance is provided on Oracle DB availability in the CI pipeline, integration tests can be enabled and added in a follow-up PR. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 |
||
|
|
9cb9aba41d |
Python: Bump to v1.39.0 for a release (#13392)
### Motivation and Context Bump to v1.39.0 for a release <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Bump to v1.39.0 for a release <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 |
||
|
|
d84363f477 |
Python: Migrate to new Google GenAI SDK (#13371)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Closes #12970, #13352 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> 1. Migrate Google AI connector to use the new Google AI SDK. 2. This PR also marks the VertexAI connector as deprecated in favor of the Google AI connector. With this update, if users wants to connect to a VertexAI project instead of a Google AI endpoint, they can do so with the Google AI connector. 3. This PR also adds the ability for users to provide a custom client to the Google AI connector (#13352). 4. This PR also marks `AzureTextCompletion` deprecated. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 |
||
|
|
849cff0b50 |
Python: Bump Python version to 1.38.0 for a release. (#13354)
### Motivation and Context Bump Python version to 1.38.0 for a release. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Bump Python version to 1.38.0 for a release. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 |
||
|
|
145ad9bfd2 |
Python: Upgrade Onnx Connector to use 0.9.0 (#13162)
### Motivation and Context Fixes : #13001 ### Description Package version 0.9.0 introduced very helpful methods like applying chat templates automatically from the tokenizer and also support for multi audio & image files. This PR adds the following functionalities: - [x] Add Inference with multiple Images - [x] Add Inference with multiple Audios - [x] Chat Templates for non Multimodal Models are read via onnx ### Samples Text Sample with ONNX: <img width="1728" height="90" alt="image" src="https://github.com/user-attachments/assets/b93d9fc1-4e38-4fa9-b535-cc316e0900ed" /> Image Sample with ONNX : <img width="1721" height="91" alt="image" src="https://github.com/user-attachments/assets/47761beb-b728-4936-a6b6-fd253e041689" /> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
b2cceb5985 |
.Net: Update OTel GenAI operation names (#13334)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> OTel GenAI operation names have the following updates: 1. `chat.completion` to `chat` 2. `text.completion` to `text_completion` ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> This PR updates those operation names ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 |
||
|
|
1c11258a32 |
Python: added af_tool bridge for kernel_functions (#13227)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Adds a new method to KernelFunction that creates a Agent Framework Tool from that function. Does require the user to install agent-framework-core themselves. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 |
||
|
|
265130743d |
Python: Bump Python version to 1.37.1 for a release. (#13314)
### Motivation and Context Bump Python version to 1.37.1 for a release. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Bump Python version to 1.37.1 for a release. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |
||
|
|
9962d434ab |
Python: Fixed sending "text" parameter to OpenAI Responses API (#13280)
## Summary
Fixed an issue where the `text` parameter was missing in requests to the
OpenAI Responses API.
## Changes Made
Modified the `ResponsesAgentThreadActions._generate_options()` method to
correctly handle the `text` parameter:
- Added to the options dictionary **only** if `text` is not `None`.
- Not added if it is an empty dict (the default value).
- This ensures that **only explicitly set `text` parameters** are sent
to the API.
## Fix Location
**File:**
`semantic_kernel/agents/open_ai/responses_agent_thread_actions.py`
**Before:**
```python
options = {
"model": merged.get("model"),
"top_p": merged.get("top_p"),
"temperature": merged.get("temperature"),
"truncation": truncation,
"metadata": merged.get("metadata"),
"max_output_tokens": max_output_tokens,
"parallel_tool_calls": parallel_tool_calls,
}
```
**After:**
```python
options = {
"model": merged.get("model"),
"top_p": merged.get("top_p"),
"temperature": merged.get("temperature"),
"truncation": truncation,
"metadata": merged.get("metadata"),
"max_output_tokens": max_output_tokens,
"parallel_tool_calls": parallel_tool_calls,
}
# Add text option if it exists
if merged.get("text") is not None:
options["text"] = merged.get("text")
```
- Closes #13281
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
---------
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Evan Mattson <[email protected]>
|
||
|
|
05d659d6e9 |
Python: Fix non-string KernelArguments being converted to strings in prompt template function calls (#13292)
### Motivation and Context Fixes #13199 - Non-string kernel arguments are now preserved when passed to functions in prompt templates. Adds unit tests. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |
||
|
|
1f8fea2b49 |
Python: Fix ai connector integration tests (#13311)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Vertex AI and Bedrock integration tests have been failing. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> 1. This PR fixes the vertex ai integration tests by upgrading the Google AI SDK version. 2. This PR fixes the Bedrock integration tests by upgrading the models. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: moonbox3 <[email protected]> |
||
|
|
cf9a5f21f7 |
Python: Fix onnx pkg by pinning. Pin openai < 2.0. (#13284)
### Motivation and Context For the latest onnxruntime 1.23.2 pkg: our GitHub Actions run is failing because uv is not matching the macOS wheel tag. Pinning to last-known-good until it's sorted out. - Pin openai pkg < 2.0 until we can investigate if 2.0 brings in other breaking changes. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 |
||
|
|
e73446e86e |
Python: [Python] Updated Agents SDK version to latest for CopilotStudio connector (#13144)
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
- The Agents SDK has been released, and the recent release changed the
namespace from `microsoft.agents` to `microsoft_agents`, which breaks
imports.
2. What problem does it solve?
- This updates the `pyproject.toml` and copilot studio related files to
fix the imports
3. What scenario does it contribute to?
- Using a Copilot Studio agent as an Agent in Semantic Kernel
4. If it fixes an open issue, please link to the issue here.
- N/A
-->
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
- Updated pyproject.toml to use the released packages for the Agents
SDK.
- Updated imports in the `copilot_studio_agent` related files to use the
new `microsoft_agents` namespace
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [] I didn't break anyone 😄
|
||
|
|
d455a20033 |
.Net & Python: Add tool definitions to agent invoke span (#13153)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> The current GenAI Semantic Conventions have changed since the last time we modified the `agent_invoke` span. Previous PRs: #12940, #12928, #12834 ### Description The following changes were made: 1. `gen_ai.agent.invocation_input` -> `gen_ai.input.messages` 2. `gen_ai.agent.invocation_output` -> `gen_ai.output.messages` 3. Add `gen_ai.tool.definitions` .Net: <img width="2056" height="459" alt="image" src="https://github.com/user-attachments/assets/533b8e08-7674-4c70-bdbe-ba3600855b20" /> Python: <img width="1323" height="659" alt="image" src="https://github.com/user-attachments/assets/702171ac-dc0b-4187-933d-dad77f2719df" /> <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 |
||
|
|
cc71ebfafa |
Python: Bump Python version to 1.37.0 for a release. (#13127)
### Motivation and Context Bump Python version to 1.37.0 for a release. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Bump Python version to 1.37.0 for a release. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |
||
|
|
61d3e6ee8d |
Python: Introduce NvidiaChatCompletion AI Connector (#12952)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? Enables developers to use NVIDIA's chat models through Semantic Kernel with structured output support. 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> This change adds chat completion support with structured output to the existing NVIDIA connector, enabling developers to use NVIDIA's chat models through Semantic Kernel while building conversational AI applications that require structured, validated responses. The connector will support more model types iteratively, with future PRs introducing VLM models and additional capabilities. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> - New Chat Completion Service: `NvidiaChatCompletion`: Chat completion service following same structure as other connectors - Extends existing NVIDIA embedding connector patterns and architecture - Custom logic for handling structured output specific to NVIDIA models - Enhanced Configuration: `NvidiaChatPromptExecutionSettings`: Chat-specific settings following existing connector patterns ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 |
||
|
|
d8af1ed633 |
Python: Safely clone plugins (#13109)
### Motivation and Context Currently, we attempt to deep copy plugins, no matter what the plugin instance holds. This will cause issues when plugins contain unpickleable items like an async generator. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description - Closes #12819 <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |
||
|
|
1404a72bce |
Python: Fix Cosmos DB NoSQL vector search functionality (issue #13028) (#13055)
## Summary Fixes vector search functionality in Cosmos DB NoSQL connector that was failing with syntax errors and "One of the input values is invalid" errors. ## Changes - Fixed VectorDistance function call to use correct 2-parameter syntax instead of 4 parameters - Removed RANK keyword from ORDER BY clause to fix SQL syntax error - Removed distance function parameter setting as it should be configured in vector index, not query - Added proper handling for empty where clauses ## Testing - Verified fix resolves the syntax errors reported in issue #13028 - Vector search functionality now works correctly with existing collections Fixes #13028 --------- Co-authored-by: Jian Wang <[email protected]> Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
652575a97a |
Python: Bump Python version to 1.36.2 for a release (#13067)
### Motivation and Context Bump Python version to 1.36.2 for a release <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Bump Python version to 1.36.2 for a release <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |
||
|
|
22ff5f844f |
Python: Fix responses agent kernel args bug (#13056)
### Motivation and Context The `arguments: KernelArguments` are not getting handled properly for the Responses Agent invoke. Use the provided `arguments` instead of trying to get them from the kwargs. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description - Closes #13053 - Adds unit test coverage. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |
||
|
|
d7db35dc47 |
Python: Fix Azure AI Inference connector model_extras duplication (#13066)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Addresses #13005 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> 1. Remove the `extra_parameters` key from `AzureAIInferenceChatPromptExecutionSettings` before calling the chat completion API to avoid unknown parameter error. 2. Allow setting the API version on the `AzureAIInferenceXXX` connectors. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 |
||
|
|
06d6494ae9 |
Python: Don't return code output via on_intermediate_msg callback (#13058)
### Motivation and Context
Current, while using an OpenAIAssistantAgent, we are returning code
output via the on_intermediate_message callback. This shouldn't be
happening right now, as all other agents return code via TextContent
with a metadata `{"code": True}` key-value pair in the dictionary.
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
1. Why is this change required?
2. What problem does it solve?
3. What scenario does it contribute to?
4. If it fixes an open issue, please link to the issue here.
-->
### Description
- Closes #12956
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
|
||
|
|
f1aac84b51 |
Python: Add framework name into UserAgent header for bedrock integration (#12901)
### Motivation and Context This PR adds the framework name into User-Agent header of Bedrock API call, so it can be used to collect the usage. ### Description Updated integration with Amazon Bedrock services to include the framework name `semantic-kernel` into the User-Agent header field for Bedrock API call for improved client identification. No changes to user-facing features or workflows. Similar change had been made to other framework such as [langchain](https://github.com/langchain-ai/langchain-aws/pull/558) ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Tao Chen <[email protected]> |
||
|
|
ea564cf04f |
Python: docs(typing): add return type and docstring to store_results in utils/chat.py (#12910)
## Summary - Added explicit return type `-> ChatHistory` to `store_results`. - Added detailed docstring explaining parameters, return type, and behavior. ## Why - Improves static analysis, IDE support, and code readability. - Makes the function self-documenting for new contributors. ## Testing - No changes to runtime behavior. - Existing test suite passes locally. ### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 --------- Co-authored-by: Tao Chen <[email protected]> |
||
|
|
da8ca43064 |
Python: fix (openai): only propagate usage metadata for final streaming chunk without choices (#12977)
### Motivation and Context
1. Why is this change required?
- The previous condition copied usage metadata whenever chunk.usage
existed, which could incorrectly propagate usage into chunks that
already contained choices.
2. What problem does it solve?
- Prevents incorrect propagation of usage metadata that can cause empty
messages or duplicated metadata when a streaming chunk contains choices
plus usage.
3. What scenario does it contribute to?
- Streaming OpenAI chat responses where the API may send a final
usage-only chunk (no choices) to report usage stats.
4. If it fixes an open issue, please link to the issue here.
- No linked issue.
### Description
- File modified:
-
python/semantic_kernel/connectors/ai/open_ai/services/open_ai_chat_completion_base.py
- Change summary:
- In
OpenAIChatCompletionBase._inner_get_streaming_chat_message_contents,
replace:
if chunk.usage is not None
with:
if len(chunk.choices) == 0 and chunk.usage is not None
- Design notes:
- This is a minimal, targeted fix to ensure usage metadata is only
copied when the streaming chunk contains no choices (typical for the
final usage-only chunk).
- Behavior of other streaming logic is unchanged.
- Recommend adding unit tests covering:
- A chunk that contains choices and usage (should not propagate usage).
- A usage-only final chunk (should propagate usage to the synthesized
choice).
### Contribution Checklist
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the SK Contribution Guidelines and formatting
script raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
Files changed:
-
python/semantic_kernel/connectors/ai/open_ai/services/open_ai_chat_completion_base.py
---------
Co-authored-by: chentiantian <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Evan Mattson <[email protected]>
|
||
|
|
4e9ea78390 |
Python: Bump Python version to 1.36.1 for a release (#13049)
### Motivation and Context Bump Python version to 1.36.1 for a release <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Bump Python version to 1.36.1 for a release <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |
||
|
|
f7fdfcd9a9 |
Python: Add AzureAIAgent Deep Research Tool support (#13034)
### Motivation and Context The deep research tool was introduced for the AzureAIAgent; however, we didn't have support yet in SK. Adding support now for using the deep research tool for both streaming and non-streaming. Samples added as well. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description - Add support for deep research tool. - Add samples with notes on prerequisites to configure the sample to run properly. - Added support for `AZURE_AI_AGENT_DEEP_RESEARCH_MODEL` env var within `AzureAIAgentSettings` class. - Bumped min allowed `azure-ai-agents` package ver to 1.2.0b3. - Closes #12978 <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |
||
|
|
86b10b95d2 |
Python: provide AzureAIAgent thread msg id during streaming (#13032)
### Motivation and Context As part of invoking an AzureAIAgent via streaming, we weren't providing the `thread_id` via the `AgentStreamEvent.THREAD_MESSAGE_CREATED` event. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Supply the caller with the `thread_msg_id` by sticking it into the returned SCMC's `metadata` dictionary. - Closes #12959 Sample output looks like: ``` Sample Output: # User: 'Hello' # AuthorRole.ASSISTANT: (thread message id: msg_HZ2h4Wzbj7GEcnVCjnyEuYWT) Hello! How can I assist you with the menu today? # User: 'What is the special soup?' # AuthorRole.ASSISTANT: (thread message id: msg_TSjkJK6hHJojIkPvF6uUofHD) The special soup today is Clam Chowder. Would you like to know more about it or anything else from the menu? # User: 'How much does that cost?' # AuthorRole.ASSISTANT: (thread message id: msg_liwTpBFrB9JpCM1oM9EXKiwq) The Clam Chowder costs $9.99. Is there anything else you'd like to know? # User: 'Thank you' # AuthorRole.ASSISTANT: (thread message id: msg_K6lpR3gYIHethXq17T6gJcxi) You're welcome! If you have any more questions or need assistance, feel free to ask. Enjoy your meal! ``` <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |
||
|
|
5e50e190c4 |
Python: Add reasoning support for OpenAI Responses Agents (GPT-5, o4-mini, o3) (#12881)
## Summary Adds reasoning capabilities to Python OpenAI ResponsesAgent, bringing parity with the C# implementation. This enables fine-grained control over reasoning effort for O-series models (o1, o3-mini, o4-mini) and gpt-5 that support the reasoning parameter. Fixes #12843 ## Changes ### Core Implementation - **`openai_responses_agent.py`**: Added reasoning configuration support - Constructor-level reasoning effort setting - Per-invocation reasoning effort override capability - Proper parameter validation and model compatibility checks - **`responses_agent_thread_actions.py`**: Extended thread actions to support reasoning parameters - Reasoning effort propagation through thread operations - Metadata preservation for reasoning tokens and summaries ### Sample and Tests - **`responses_agent_reasoning.py`**: Comprehensive demonstration sample - Constructor vs per-invocation reasoning configuration - Function calling integration with reasoning - Reasoning comparison scenarios (low/medium/high effort) - Error handling and troubleshooting guidance - **`test_openai_responses_agent_reasoning.py`**: Full unit test coverage - Parameter validation tests - Integration scenarios with function calling - Edge cases and error conditions ## Features ✅ **Constructor-Level Reasoning**: Set default reasoning effort when creating agents ✅ **Per-Invocation Override**: Override reasoning effort per request ✅ **Priority Hierarchy**: per-invocation > constructor > model default ✅ **Function Calling Compatible**: Works seamlessly with existing plugin system ✅ **Azure OpenAI & OpenAI Support**: Compatible with both service providers ✅ **Model Validation**: Automatic compatibility checks for O-series models nad GÜT-5 ✅ **Metadata Access**: Reasoning tokens and summaries available in response metadata ## Usage Example ```python # Constructor-level reasoning # Constructor-level reasoning configuration agent = AzureResponsesAgent( ai_model_id="gpt-5", client=client, reasoning={"effort": "low"} # Default reasoning for all requests ) # Per-invocation override response = await agent.invoke( "Solve this complex problem step by step", reasoning={"effort": "high"} ) # Invoke with reasoning callback to capture intermediate thoughts response = await agent.invoke( "Analyze this data step by step", reasoning={"effort": "high", "summary": "detailed"}, on_intermediate_message=handle_reasoning_message ) # Streaming with reasoning async for response in agent.invoke_stream( "Explain quantum computing in detail", reasoning={"effort": "high", "summary": "detailed"}, on_intermediate_message=handle_reasoning_message ): print(response.content, end="", flush=True) --------- Co-authored-by: Evan Mattson <[email protected]> Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
d3318adfc2 |
Python: Add container_id and filename fields to AnnotationContent class (#12985)
### Motivation and Context
I confirmed that Code Interpreter can run via Azure Responses API in
Semantic Kernel, but I found two issues: an error occurs when a file is
created inside the Code Interpreter, and the response lacks parameters
required to access the created file.
### Description
#### Bug 1: ValidationError for AnnotationContent
Semantic Kernel uses the following enum for
`AnnotationContent.content_type`:
```python
@experimental
class CitationType(str, Enum):
"""Citation type."""
URL_CITATION = "url_citation"
FILE_PATH = "file_path"
FILE_CITATION = "file_citation"
```
However, the Responses API returns file citations with a `type` like
this:
```json
{"container_id": "cntr_68a6c50135d88190b6fdc062051155b50847ddec73d3be1b", "end_index": 94, "file_id": "cfile_68a6c67a7fcc8190889d7e1789d485e2", "filename": "sample.txt", "start_index": 66, "type": "container_file_citation"}
```
There is no matching enum member on the Semantic Kernel side. The
`CitationType` should include `CONTAINER_FILE_CITATION`, for example:
```python
@experimental
class CitationType(str, Enum):
"""Citation type."""
URL_CITATION = "url_citation"
FILE_PATH = "file_path"
FILE_CITATION = "file_citation"
CONTAINER_FILE_CITATION = "container_file_citation"
```
#### Bug 2: Missing parameters to access generated files
The response returned by the agent shows a `file_id`, but lacks the
`container_id` and `filename` required to download the file (the
filename is needed to replace `sandbox:/mnt/data/sample.txt`):
Example call:
```python
r = await agent.get_response(cast(list, history.messages), thread=thread)
print(r.content.items)
```
Example output:
```python
[
TextContent(inner_content=None, ai_model_id=None, metadata={}, content_type='text', text='<user_prompt>', encoding=None),
TextContent(inner_content=None, ai_model_id=None, metadata={}, content_type='text', text='<assistant_message>\n\n[sample.txt](sandbox:/mnt/data/sample.txt)', encoding=None),
AnnotationContent(inner_content=None, ai_model_id=None, metadata={}, content_type='annotation', file_id='cfile_68a6c67a7fcc8190889d7e1789d485e2', quote=None, start_index=88, end_index=116, url=None, title=None, citation_type=<CitationType.CONTAINER_FILE_CITATION: 'container_file_citation'>)
]
```
To include these values in the parsed result, `AnnotationContent` in
`semantic_kernel/contents/annotation_content.py` should expose
`container_id` and `filename`, and map the incoming `type` to
`citation_type`. Example suggested structure:
```python
@experimental
class AnnotationContent(KernelContent):
"""Annotation content."""
content_type: Literal[ContentTypes.ANNOTATION_CONTENT] = Field(ANNOTATION_CONTENT_TAG, init=False) # type: ignore
tag: ClassVar[str] = ANNOTATION_CONTENT_TAG
file_id: str | None = None
quote: str | None = None
start_index: int | None = None
end_index: int | None = None
url: str | None = None
title: str | None = None
# added
container_id: str | None = None
filename: str | None = None
citation_type: CitationType | None = Field(None, alias="type")
model_config = ConfigDict(
extra="ignore",
populate_by_name=True,
)
def __str__(self) -> str:
...
def to_element(self) -> Element:
...
@classmethod
def from_element(cls: type[_T], element: Element) -> _T:
...
def to_dict(self) -> dict[str, Any]:
...
```
Summary: add the missing enum value `container_file_citation` and extend
`AnnotationContent` to include `container_id` and `filename` (and map
`type` to `citation_type`) so file references returned by the Azure
Responses API are fully usable.
#### Code
```python
client: AsyncAzureOpenAI = AsyncAzureOpenAI(
base_url=urljoin(server_settings.AZURE_OPENAI_COMPLETION_ENDPOINT.rstrip("/") + "/", "openai/v1/"),
api_key=server_settings.AZURE_OPENAI_COMPLETION_API_KEY,
api_version="preview",
)
async def run(history: ChatHistory) -> dict[str, Any]:
with open("sample.txt", "rb") as fp:
f = await client.files.create(file=fp, purpose="assistants")
agent = AzureResponsesAgent(
ai_model_id=server_settings.AZURE_OPENAI_COMPLETION_DEPLOYMENT_NAME,
client=client,
name="name",
function_choice_behavior=FunctionChoiceBehavior.Required(),
tools=[
CodeInterpreter(
type="code_interpreter",
container=CodeInterpreterContainerCodeInterpreterToolAuto(type="auto", file_ids=[f.id]),
)
],
)
thread = ResponsesAgentThread(client, history, previous_response_id=None, enable_store=True)
r = await agent.get_response(cast(list, history.messages), thread=thread)
print(thread.id, r.content.items)
annotation_content = [item for item in r.content.items if isinstance(item, AnnotationContent)]
for ac in annotation_content:
print(ac.file_id, ac.filename, ac.container_id)
```
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
Co-authored-by: Evan Mattson <[email protected]>
|
||
|
|
1179122a5e |
Python: Bump Python version to 1.36.0 for a release. (#13014)
### Motivation and Context Bump Python version to 1.36.0 for a release. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Bump Python version to 1.36.0 for a release. <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |
||
|
|
18d9a8e8b2 |
Python: .Net: Updated encoding logic in prompt templates (#12983)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> Resolves: https://github.com/microsoft/semantic-kernel/issues/11821 Today, the encoding of template arguments is performed only if argument type is `string`. In case of custom type, anonymous type or collection - the encoding is not performed. This PR contains changes to throw an exception in case if encoding is enabled but complex type is used. In case of complex type, the encoding should be performed manually according to business logic and automatic encoding should be explicitly disabled. This enforces stricter, but more secure template rendering rules. **Note**: this is a breaking change for customers who use Handlebars or Liquid template with complex type arguments. Code changes are required when initializing template arguments: ```diff var arguments = new KernelArguments() { { "customer", new { - firstName = userInput.FirstName, - lastName = userInput.LastName, + firstName = HttpUtility.HtmlEncode(userInput.FirstName), + lastName = HttpUtility.HtmlEncode(userInput.LastName), } } }; var templateFactory = new LiquidPromptTemplateFactory(); var promptTemplateConfig = new PromptTemplateConfig() { TemplateFormat = "liquid" + InputVariables = new() + { + // We set AllowDangerouslySetContent to 'true' because each property of this argument is encoded manually. + new() { Name = "customer", AllowDangerouslySetContent = true }, + } }; var promptTemplate = templateFactory.Create(promptTemplateConfig); var renderedPrompt = await promptTemplate.RenderAsync(kernel, arguments); ``` ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 |
||
|
|
2a47ba9b7d |
Python: Removed usage of DefaultAzureCredential (#12964)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> The usage of `DefaultAzureCredential` by default is unsafe and raises security issues. Instead, users should provide their own credential types such as `AzureCliCredential`, `ManagedIdentityCredential` and so on. More information here: https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity.aio?view=azure-python In this PR: 1. Removed the usage of `DefaultAzureCredential` from authentication logic. 2. Replaced `DefaultAzureCredential` with `AzureCliCredential` in all examples. **Note**: this is breaking change for Azure users, who relies on `DefaultAzureCredential`. Users will need to update the code and pass the credential type of their choice by using `credential` parameter when initializing one of the Azure clients. Before: ```python chat_completion = AzureChatCompletion() ``` After: ```python chat_completion = AzureChatCompletion(credential=AzureCliCredential()) ``` ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 |
||
|
|
45fe60545c |
Python: Fix issue with orphaned tool/tool_calls (#12923)
### Motivation and Context Tool/tool_calls are getting orphaned. Issue : https://github.com/microsoft/semantic-kernel/issues/12708 How to reproduce : ```python from semantic_kernel.contents import ( AuthorRole, ChatMessageContent, FunctionCallContent, FunctionResultContent, ChatHistoryTruncationReducer, ) messages = [ ChatMessageContent(role=AuthorRole.SYSTEM, content="sys"), ChatMessageContent(role=AuthorRole.USER, content="user A"), ChatMessageContent( role=AuthorRole.ASSISTANT, items=[ FunctionCallContent( id="123", function_name="search", plugin_name="plugin", arguments={"q": "x"} ) ], ), ChatMessageContent( role=AuthorRole.TOOL, items=[ FunctionResultContent( id="123", function_name="search", plugin_name="plugin", result="RESULT" ) ], ), ChatMessageContent(role=AuthorRole.USER, content="user B"), ChatMessageContent(role=AuthorRole.ASSISTANT, content="done"), ] reducer = ChatHistoryTruncationReducer(target_count=3, threshold_count=0) reducer.messages = messages print("Before reduce:", [m.role for m in reducer.messages]) await reducer.reduce() print("After reduce:", [m.role for m in reducer.messages]) # After reduce: [<AuthorRole.TOOL: 'tool'>, <AuthorRole.USER: 'user'>, <AuthorRole.ASSISTANT: 'assistant'>] ``` ### Description Move backward as long as we are in a tool/tool_call island when reducing the messages. --------- Co-authored-by: Allaoua Benchikh <[email protected]> Co-authored-by: Evan Mattson <[email protected]> Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
09fb007bb1 |
Python: Bump Python version to 1.35.3 for a release (#12945)
### Motivation and Context Bump Python version to 1.35.3 for a release <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Bump Python version to 1.35.3 for a release <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |
||
|
|
6416c58b90 |
Python: Add arguments and results attributes to execute tool span (#12940)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> We are adding two new attributes to the execute tool span according to this proposal to Otel Semantic Conventions: https://github.com/open-telemetry/semantic-conventions/pull/2528 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> The following two attributes are added to the `execute_tool` span: 1. `gen_ai.tool.call.arguments` 2. `gen_ai.tool.call.result` ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 |
||
|
|
40734345dc |
Python: Fix the Responses agent msg chaining with reasoning models (#12907)
### Motivation and Context When running a reasoning model with the OpenAI responses agent, it was producing 400s due to the way we were either including or not including FCC related to tool calls. This PR fixes it for both the default (store_enabled=True) and the case where uses don't want to use OpenAI's previous response id as a pseudo-thread (store_enabled=False). <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description - Closes #12843 <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |
||
|
|
d4e0278330 |
Python: Bump Python version to 1.35.2 for a release (#12894)
### Motivation and Context Bump Python version to 1.35.2 for a release <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description Bump Python version to 1.35.2 for a release <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |
||
|
|
73ad6e8923 |
Python: Fix: Implement __deepcopy__ on KernelFunction to handle non-serializable OTEL metrics (#12803)
### Description This PR fixes TypeError: cannot pickle '_thread.RLock' object which occurs when kernel.clone() is called while OpenTelemetry metrics are enabled. - Fixes: #12802 ### Motivation and Context When using features like `HandoffOrchestration`, the agent's `Kernel` is cloned. This process uses `copy.deepcopy`, which fails on the `KernelFunction`'s OpenTelemetry `Histogram` fields (`invocation_duration_histogram` and `streaming_duration_histogram`). These histogram objects contain thread locks, making them non-serializable. Previous solutions, like the one in **PR #9292**, used `Field(exclude=True, default_factory=...)`. While that was a necessary step, it was insufficient because `deepcopy` does not respect the `exclude` flag in the same way that Pydantic's serialization does. This bug blocks the use of certain agentic features in any application that has metrics-based observability enabled. ### Description of the change This solution introduces a custom __deepcopy__ method to the KernelFunction Pydantic model. This method correctly handles the deep-copying process for KernelFunction instances: 1. It intercepts the deepcopy call for KernelFunction objects. 2. It uses self.model_copy(deep=False) to create a new instance of the Pydantic model. Using deep=False allows the default_factory for the histogram fields to create new, clean instances on the copied object, while other fields are shallow-copied. 3. It then manually deep-copies all other attributes from the original object to the new one, ensuring that any other mutable objects (like metadata`) are correctly duplicated. The histogram fields are explicitly skipped in this step, as they have already been recreated by `model_copy. 4. Standard deepcopy memoization is used to prevent infinite recursion in the case of cyclic object graphs. This approach ensures that the non-serializable fields are re-initialized instead of copied, resolving the TypeError while maintaining the integrity of the cloned object. ### How has this been tested? The fix was validated using the reproduction steps outlined in the associated issue. Running an agent orchestration that triggers kernel.clone() with OpenTelemetry metrics enabled now completes successfully without any errors. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 --------- Co-authored-by: Evan Mattson <[email protected]> |
||
|
|
a6b5f34d9b |
Python: fix parsing of types in mcp server (#12871)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> The parsing of tool call output was not working correctly, this fixes that. Solves #12850 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄 |
||
|
|
91392a77e0 |
Python: Fix ResponsesAgent image duplication in chat history preparation (#12859)
### Motivation and Context The ResponsesAgent is duplicating messages in chat history preparation when messages contained multiple content items (text + images). The `response_inputs.append()` call is inside the content processing loop, causing each message to be added once per content item. The fix: - Moved `response_inputs.append()` outside the content processing loop - Added unit test to verify multiple images don't get duplicated <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description - Fixed loop placement in `_prepare_chat_history_for_request` - Added test `test_prepare_chat_history_multiple_images_no_duplication` - Fixes #12848 <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄 |