You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: [Python] structured_outputs_transform reuses ChatHistory across calls (prompt pollution) #14483
structured_outputs_transform creates a single ChatHistory in the factory and closes over it. Each output_transform call add_messages into that same history, so prior orchestration outputs leak into later structured-output prompts and the history grows without bound (lengths 2→3→4…).
Each transform invocation uses a fresh history (system + current message only), so independent orchestration steps do not pollute each other.
Actual
Shared history grows across calls; prior outputs leak into later structured-output prompts.
Root cause (pointer)
semantic_kernel/agents/orchestration/tools.py — structured_outputs_transform: chat_history = ChatHistory(...) created once in the factory and mutated inside output_transform.
Suggested fix direction
Construct a fresh ChatHistory (with the system message) inside output_transform on every call.
I reproduced the history leak with two calls to the same structured_outputs_transform. I am submitting a focused fix that creates a fresh ChatHistory for each invocation, with a regression test covering isolation across calls. The targeted orchestration tools tests pass locally.
Activity
[-][Python] structured_outputs_transform reuses ChatHistory across calls (prompt pollution)[/-][+]Python: [Python] structured_outputs_transform reuses ChatHistory across calls (prompt pollution)[/+]jiangjiang248 commentedon Sep 26, 2026
I reproduced the history leak with two calls to the same structured_outputs_transform. I am submitting a focused fix that creates a fresh ChatHistory for each invocation, with a regression test covering isolation across calls. The targeted orchestration tools tests pass locally.
michaelkillgta commentedon Sep 28, 2026
Thanks jiangjiang248 for #14487 — I'll leave this one with your PR.