FEAT normalize messages before sending#1613
Draft
hannahwestra25 wants to merge 3 commits intomicrosoft:mainfrom
Draft
FEAT normalize messages before sending#1613hannahwestra25 wants to merge 3 commits intomicrosoft:mainfrom
hannahwestra25 wants to merge 3 commits intomicrosoft:mainfrom
Conversation
hannahwestra25
commented
Apr 14, 2026
Comment on lines
+118
to
+125
| warnings.warn( | ||
| "Passing GenericSystemSquashNormalizer as message_normalizer is deprecated. " | ||
| "Use custom_configuration=TargetConfiguration(capabilities=TargetCapabilities(" | ||
| "supports_system_prompt=False), policy=CapabilityHandlingPolicy(behaviors={" | ||
| "CapabilityName.SYSTEM_PROMPT: UnsupportedCapabilityBehavior.ADAPT})) instead. " | ||
| "Will be removed in v0.14.0.", | ||
| DeprecationWarning, | ||
| stacklevel=2, |
Contributor
Author
There was a problem hiding this comment.
this needs to be updated
romanlutz
approved these changes
Apr 15, 2026
|
|
||
| @limit_requests_per_minute | ||
| async def send_prompt_async(self, *, message: Message) -> list[Message]: | ||
| async def _send_prompt_target_async(self, *, normalized_conversation: list[Message]) -> list[Message]: |
Contributor
There was a problem hiding this comment.
Nit: send_prompt_to_target_async?
As is, it reads a bit strangely.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Utilize the Normalization Pipeline in the Target Send Path
PR 4 of the TargetConfiguration roadmap
Problem
The
TargetConfiguration.normalize_asyncpipeline (system-squash, history-squash, etc.) was fully built in this PR but never called. Every target independently fetched conversation history, appended the current message, and sent it to the API — some with ad-hoc normalization (AzureMLChatTarget), most with none at all. This meant the centralized normalization pipeline was dead code, and normalization behavior was inconsistent across targets.Solution
Wire the normalization pipeline into the send path so that every prompt passes through
configuration.normalize_async()before reaching the target's API call. This is done by makingsend_prompt_asynca concrete template method onPromptTargetthat validates, fetches conversation from memory, runs the normalization pipeline, and delegates to a new_send_prompt_target_asyncabstract method for wire-format-specific logic.Changes
PromptTarget.send_prompt_async: Now a concrete method that callsself.configuration.normalize_async(messages=...)and passes the result to_send_prompt_target_asyncsend_prompt_async→_send_prompt_target_async, removed duplicated validation/memory-fetch boilerplate, now receive the pre-normalized conversation directlyAzureMLChatTarget:message_normalizerparameter deprecated with auto-translation toTargetConfiguration(policy={SYSTEM_PROMPT: ADAPT}); will be removed in v0.14.0Breaking Changes
_send_prompt_target_asyncinstead ofsend_prompt_asyncTests and Documentation
test_normalize_async_integration.py(395 lines) covering normalize-is-called, normalized-conversation-is-used, memory-not-mutated, and legacy deprecation pathswip: running integration tests