Skip to content

.Net: Add AIContextProvider support to Semantic Kernel#11689

Merged
westey-m merged 47 commits intomainfrom
feature-conversation-state-extensions
May 22, 2025
Merged

.Net: Add AIContextProvider support to Semantic Kernel#11689
westey-m merged 47 commits intomainfrom
feature-conversation-state-extensions

Conversation

@westey-m
Copy link
Contributor

@westey-m westey-m commented Apr 23, 2025

Motivation and Context

Adding support for AI context behaviors to Semantic Kernel.
These allow creating plugins that are able to listen to messages being added to the chat history and contribute to the AI context on each invocation. This PR also integrates support for these with Agents and AgentThreads.

#10100
#10712

…dd Unit tests. (#11632)

### Motivation and Context

#10100 
#10712

### Description

This is the first PR of a number of PRs and adds

1. A base abstraction for creating a conversation state extension
2. A class to manage multiple extensions
3. Updates to the AgentThread to use extensions
4. Unit tests
5. ADR document

In follow up PRs I'll add:

- Updates to Agents to use extensions on AgentThread
- Individual Extension implementations

### 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 😄
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel kernel.core documentation labels Apr 23, 2025
@github-actions github-actions bot changed the title Add Conversation State Parts support to Semantic Kernel .Net: Add Conversation State Parts support to Semantic Kernel Apr 23, 2025
… tests (#11690)

### Motivation and Context

#10100
#10712

Other agents and actual state components to follow in future PRs.

### Description

- Add code to integrate conversation state with ChatCompletionAgent
- Add integration tests for the integration

### 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 😄
### Motivation and Context

#10100
#10712

### Description

- Add a new `mem0` conversation state part
- Add integration tests for the new component

### 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 😄
…on state (#11711)

### Motivation and Context

#10100
#10712

### Description

- Update OpenAIAssistantAgent to support conversation state
- Update AzureAIAgent to support conversation state
- Update tests and add integration tests.

### 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 😄
### Motivation and Context

#10100
#10712

### Description

- Add unit tests for the mem0 memory component
- Allow context prompt to be configurable

### 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 😄
…tests. (#11737)

### Motivation and Context

#10100
#10712

### Description

- Add support to BedrockAgent for conversation state parts
- Fix issue in AzureAIAgent with instructions merging
- Add more integration tests

### 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 😄
### Motivation and Context

#10100
#10712

### Description

Adding a rag component for easily adding RAG to an agent.

### 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 😄
### Motivation and Context

We should have a simple way of uploading text and doing RAG over that
text.
This branch is not up to date with the latest MEVD changes, but will be
updated after this PR with changes to make
use of the new features.

### Description

Adding a store that allows easy uploading of text or links to text and
exposing that text via the TextRagComponent

### 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 😄
…11862)

### Description

- Rename TextRagComponent to TextSearchBehavior
- Add Prompt tests
- Improve prompts

### 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 😄
…re tests (#11877)

### Motivation and Context

#10100 
#10712

### Description

- Adds a sample that shows how to use the rag components with an agent
- Adds support for text only uploads
- Adds some bug fixes
- Adds additional tests

### 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 😄
### Description

- Add a sample to show how to use the mem0 component
- Fix some bugs and add more tests
- Removed the clear memory tool, since it is flakey and getting invoked
when it shouldn't be.
- Can reintroduce later if we find a way to do this safely

### 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 😄
@westey-m westey-m enabled auto-merge May 19, 2025 14:30
@westey-m westey-m disabled auto-merge May 19, 2025 14:31
### Motivation and Context

Making the context behavior manager an aggregate context behavior that
is itself a behavior, allows users to reuse this and build their own
context behavior hierarchies enabling more complex scenarios.

### Description

- Rename and update AIContextBehaviorManager as discussed
- Rename event names as discussed
- Update branch with changes required after latest breaking change from
main

### 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 😄
westey-m added 2 commits May 22, 2025 11:21
…#12218)

### Motivation and Context

As discussed, naming changes to improve clarity and align with MEAI
naming.

### Description

Rename AIContextBehavior to Provider and thread to conversation

### 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 😄
@westey-m westey-m enabled auto-merge May 22, 2025 10:21
@westey-m westey-m changed the title .Net: Add AIContextBehavior support to Semantic Kernel .Net: Add AIContextProvider support to Semantic Kernel May 22, 2025
@westey-m westey-m added this pull request to the merge queue May 22, 2025
Merged via the queue into main with commit 9ada3aa May 22, 2025
19 checks passed
@westey-m westey-m deleted the feature-conversation-state-extensions branch May 22, 2025 11:17
github-merge-queue bot pushed a commit that referenced this pull request Jun 25, 2025
### Motivation and Context

- Fixes #12534 

- This regression seems to be part of #11689 where `kernel` instance was
is cloned prior agent iterations, as I didn't captured any failing unit
tests for the added `AIContext` providers considering this as a valid
fix.

- Added UT covering the expected `Kernel` mutability.

---------

Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>
jcruzmot-te pushed a commit to thousandeyes/aia-semantic-kernel that referenced this pull request Sep 15, 2025
### Motivation and Context

Adding support for AI context behaviors to Semantic Kernel.
These allow creating plugins that are able to listen to messages being
added to the chat history and contribute to the AI context on each
invocation. This PR also integrates support for these with Agents and
AgentThreads.

microsoft#10100 
microsoft#10712

---------

Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
Co-authored-by: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
jcruzmot-te pushed a commit to thousandeyes/aia-semantic-kernel that referenced this pull request Sep 15, 2025
…2538)

### Motivation and Context

- Fixes microsoft#12534 

- This regression seems to be part of microsoft#11689 where `kernel` instance was
is cloned prior agent iterations, as I didn't captured any failing unit
tests for the added `AIContext` providers considering this as a valid
fix.

- Added UT covering the expected `Kernel` mutability.

---------

Co-authored-by: westey <164392973+westey-m@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation kernel.core kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants