Files
semantic-kernel/python/tests
Evan Mattson da1e1e5b63 Python: Fix Agent StreamingTextContent Yielding and Proper Handling of FunctionCallContent/FunctionResultContent (#11563)
### Motivation and Context

This PR addresses an issue where responses during the `invoke_stream`
call were not being properly filtered by content type. The bug caused
the system to yield responses containing non-text content (i.e.,
FunctionCallContent or FunctionResultContent) directly, rather than
routing them through the on_intermediate_message callback for
specialized handling. The fix ensures that only responses exclusively
composed of StreamingTextContent are yielded, while other
function-related content types are passed to the appropriate callback.

Additionally, the `ChatHistoryAgentThread` id property wasn't set - it
was configuring a `_thread_id`, which the base class doesn't use.

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

### Description

- Properly yield expected content type `StreamingTextContent` from an
agent `invoke_stream(...)` call. Other FCC or FRC types are yielded via
the `on_intermediate_message` callback.
- Fix `ChatHistoryAgentThread` id bug that was setting `_thread_id`
instead of `_id`.
- Update integration tests to make sure we receive the expected content
types during function call invocations.
- Closes #11561
- Closes #11535 

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
2025-04-16 00:23:34 +00:00
..
2023-04-13 16:12:36 -07:00