Fix UnboundLocalError in prompty response formatting when inputs are omitted#47005
Merged
posaninagendra merged 3 commits intoMay 20, 2026
Merged
Conversation
Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-python/sessions/40ee70eb-f614-4ef1-a0a5-472639f541a8 Co-authored-by: posaninagendra <2713981+posaninagendra@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
posaninagendra
May 19, 2026 22:19
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Fixes an UnboundLocalError in prompty response formatting when format_llm_response is invoked without inputs (seen in async evaluator flows), and adds regression coverage plus a changelog entry.
Changes:
- Initialize
sample_inputto""soformat_llm_response(..., inputs=None)can’t reference it before assignment. - Add a unit test validating the
inputs=Nonepath returns successfully and setssample_inputto an empty string. - Document the fix in the unreleased changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_legacy/prompty/_utils.py | Initializes sample_input defensively to prevent UnboundLocalError when inputs is omitted. |
| sdk/evaluation/azure-ai-evaluation/tests/unittests/test_prompty_format_llm_response.py | Adds regression test covering format_llm_response(..., inputs=None) behavior. |
| sdk/evaluation/azure-ai-evaluation/CHANGELOG.md | Notes the bug fix in the unreleased section. |
Contributor
|
Hi @copilot. We've noticed that new changes have been pushed to this pull request. Because it is set to automatically merge, we've reset the approvals to allow the opportunity to review the updates. |
slister1001
approved these changes
May 20, 2026
w-javed
approved these changes
May 20, 2026
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.
format_llm_responsecould raiseUnboundLocalErrorby referencingsample_inputbefore assignment wheninputsis not provided. This surfaced in async evaluator flows that call prompty without explicit input payloads.Runtime fix in prompty formatting path
sample_inputto an empty string before conditional input serialization.inputsis present (still emits serialized sample input payload).Regression coverage
format_llm_response(..., inputs=None)to ensure the function returns successfully and emitssample_input == "".Changelog
UnboundLocalErrorfix.