Skip to content

Cherry pick PR for rel-0.9.0#491

Open
baijumeswani wants to merge 3 commits intoreleases/rel-0.9.0from
bmeswani/cherry-pick
Open

Cherry pick PR for rel-0.9.0#491
baijumeswani wants to merge 3 commits intoreleases/rel-0.9.0from
bmeswani/cherry-pick

Conversation

@baijumeswani
Copy link
Collaborator

No description provided.

selenayang888 and others added 3 commits March 6, 2026 18:36
Co-authored-by: Prathik Rao <prathikrao@microsoft.com>
…ChatClient streaming path (#466)

Fixes the bug where `ChatClient` streaming was not checking the
`Response.Error` field returned by `ExecuteCommandWithCallbackAsync`.
When the native layer reported an error without invoking any callbacks,
the streaming method would silently complete with an empty stream
instead of propagating the error to the caller.

The equivalent fix for `AudioClient` was merged separately via PR #471.

## Changes Made

- **`ChatClient.cs`**: Capture the return value of
`ExecuteCommandWithCallbackAsync` and, when it carries an error (and no
callback has already failed), complete the channel with a
`FoundryLocalException` so the error propagates to the consumer's `await
foreach` loop. Added an internal constructor accepting `ICoreInterop`
and `ILogger` for dependency injection in unit tests.
- **`ChatClientStreamingErrorTests.cs`**: Unit tests verifying that
native-layer errors reported via `Response.Error` are propagated as
`FoundryLocalException` to callers, and that a successful (no-error)
response completes the stream normally.

<!-- START COPILOT ORIGINAL PROMPT -->



<details>

<summary>Original prompt</summary>

> 
> ----
> 
> *This section details on the original issue you should resolve*
> 
> <issue_title>ExecuteCommandWithCallbackAsync response not
checked</issue_title>
> <issue_description>ExecuteCommandWithCallbackAsync returns a Response
whose .Error field may contain an error from the native layer (e.g.
missing audio file, invalid model, etc.). Both AudioClient and
ChatClient streaming paths are ignoring this return value, so when the
native side reported an error without invoking any callbacks the channel
was completed successfully and the caller observed an empty stream
instead of an exception.
> 
> Capture the Response and, when it carries an error, complete the
channel with a FoundryLocalException so the error propagates to the
consumer's `await foreach` loop.</issue_description>
> 
> <agent_instructions>Add necessary unit tests.</agent_instructions>
> 
> ## Comments on the Issue (you are @copilot in this section)
> 
> <comments>
> </comments>
> 


</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes #465

<!-- START COPILOT CODING AGENT TIPS -->
---

🔒 GitHub Advanced Security automatically protects Copilot coding agent
pull requests. You can protect all pull requests by enabling Advanced
Security for your repositories. [Learn more about Advanced
Security.](https://gh.io/cca-advanced-security)

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: baijumeswani <12852605+baijumeswani@users.noreply.github.com>
Co-authored-by: Baiju Meswani <baijumeswani@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Baiju Meswani <bmeswani@microsoft.com>
@vercel
Copy link

vercel bot commented Mar 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foundry-local Ready Ready Preview, Comment Mar 7, 2026 2:37am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants