Skip to content

.NET: [Feature]: Make the RequestMessages property of ChatMessageStore.InvokedContext writable #3194

@marcominerva

Description

@marcominerva

Description

With the new WithMessageFilters method, it is now possible to easily filter messages before they are passed to a Message Store.

However, I noticed that the RequestMessages property in the ChatMessageStore.InvokedContext class is read-only. Because of this, if the collection needs to be modified, a completely new InvokedContext instance must be created.

For example:

.WithMessageFilters(invokedMessagesFilter: context =>
{
    var newContext = new ChatMessageStore.InvokedContext(context.RequestMessages
        .Where(x => !(x.AdditionalProperties?.TryGetValue("IsPrivate", out bool value) is true && value is true)),
        context.ChatMessageStoreMessages)
    {
        ResponseMessages = context.ResponseMessages,
        AIContextProviderMessages = context.AIContextProviderMessages,
        InvokeException = context.InvokeException
    };

    return newContext;
});

Would it be possible to make the RequestMessages property writable, or alternatively provide a supported way to modify the request messages without recreating the entire InvokedContext?

Language/SDK

.NET

Metadata

Metadata

Assignees

Labels

.NETagent memoryRelated to agentic memoryv1.0Features being tracked for the version 1.0 GA

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions