microsoft / microsoft/agent-framework
.NET: interceptable ChatHistoryProvider and AIContextProvider on an existing ChatClientAgent
@westey-m is already working on this.
Since Aug 18, 2026.
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 2.3k
- Avg merge
- 2d 45m
- Merged PRs (30d)
- 358
Description
Problem
There is no supported way to intercept or decorate the ChatHistoryProvider and AIContextProvider instances of an existing ChatClientAgent — they are fixed at construction, the agent creates an implicit default InMemoryChatHistoryProvider when none is configured, and per-run overrides can arrive through two separate routes (ChatOptions.AdditionalProperties and base AgentRunOptions.AdditionalProperties, the latter merged with precedence in CreateConfiguredChatOptions).
The agent-hooks integration (#7564) needs verdict-gated durability (denied content never persists; transformed content persists post-transform), and the only way to get it today is a stack of construction-time workarounds in AgentHooksChatClientExtensions.Compose and AgentHooksAgent.WrapRunOptions:
- clone the caller's
ChatClientAgentOptionsand wrap both provider kinds in gating decorators; - materialize the implicit default provider just to wrap it — which changes the history-conflict flag semantics keyed off "a provider was explicitly configured", requiring the factory to reset
Warn/Throw/ClearOnChatHistoryProviderConflictto mimic the implicit default; - clone per-run options (copy-on-write) and wrap provider overrides in both AdditionalProperties dictionaries, with ownership checks so a wrapper from a different installation is re-wrapped.
Proposed shape (for discussion)
A first-class provider-decoration seam, e.g. ChatClientAgent (or its options) exposing DecorateChatHistoryProvider(Func<ChatHistoryProvider, ChatHistoryProvider>) / the AICP equivalent, applied uniformly to the configured provider, the implicit default, and any per-run override after merge — so a decorator sees every durable write regardless of how the provider was supplied, and conflict-flag semantics stay the agent's own concern.
Context
- PR #7564 (concrete workaround sites:
AgentHooksChatClientExtensions.Compose,AgentHooksAgent.WrapRunOptions,AgentHooksGatingChatHistoryProvider/AgentHooksGatingAIContextProvider) - Review threads: https://github.com/microsoft/agent-framework/pull/7564#discussion_r3804862167 (enhancement discussion), https://github.com/microsoft/agent-framework/pull/7564#discussion_r3803408324 (ownership/re-wrap), and the default-provider gating finding from the PR's review rounds
- Related: companion issues #7726 (addressable pipeline positions) and #7729 (run-scoped lifecycle context) and #7718
Not urgent (per the review thread). cc @westey-m
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.