Files
agent-framework/python/samples/getting_started/devui/weather_agent_azure
T
t-anjan 665aacf1ad Fix chat middleware: add streaming support, terminate flag, and check only last message (#2120)
This commit fixes three issues in the security_filter_middleware:

1. Missing context.terminate flag - Without this, middleware continues processing after setting blocked response
2. No streaming support - When context.is_streaming is True, middleware now returns async generator with ChatResponseUpdate
3. Checks all messages - Changed to check only context.messages[-1] (most recent user message) instead of iterating through conversation history

Changes:
- Added AsyncIterable import
- Added ChatResponseUpdate and TextContent imports
- Modified security_filter_middleware to handle both streaming and non-streaming modes
- Added context.terminate = True to properly stop execution
- Changed message checking logic to only inspect the last user message

Co-authored-by: Victor Dibia <chuvidi2003@gmail.com>
Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com>
665aacf1ad · 2025-11-13 04:20:44 +00:00
History
..