Skip to content

Python: skip empty and whitespace-only instructions in prepend - #8524

Open
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/prepend-empty-instructions
Open

Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/prepend-empty-instructions

Conversation

@ManoharPaturi

@ManoharPaturi Manohar Paturi (ManoharPaturi) commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Motivation & Context

prepend_instructions_to_messages adds an empty system message for each empty or whitespace-only string in the instructions list, so options like instructions=["", "Be helpful"] produce a blank system message ahead of the real one. Reported in #8523.

Description & Review Guide

  • What are the major changes? Empty and whitespace-only instruction entries are skipped during preprocessing, so only instructions with content become messages.
  • What is the impact of these changes? No more blank system messages from sparse instruction lists; non-empty strings behave exactly as before.
  • What do you want reviewers to focus on? The skip predicate and its tests (empty string, whitespace-only, mixed lists).

Related Issue

Fixes #8523

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue
  • This is not a breaking change.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Sep 18, 2026
@eavanvalkenburg

Copy link
Copy Markdown
Member

Manohar Paturi (@ManoharPaturi), thanks for the contribution. The current head is not green: Package Checks, Pre-commit Hooks, and Merge Gatekeeper are failing. The PR body also does not retain and complete the current template’s four required sections, all three Description & Review Guide prompts, a valid closing reference to #8523, or the contribution checklist. Please address the check failures and update the PR body, then re-request review.

@ManoharPaturi

Copy link
Copy Markdown
Contributor Author

Eduard van Valkenburg (@eavanvalkenburg) the branch was cut from an older main which is what the failing package/pre-commit checks were tripping over. rebased onto current main (the actual change is 2 files, 28 lines), tests pass, and the body now follows the template with Fixes #8523. pushed in 9e42c3b.

@ManoharPaturi

Copy link
Copy Markdown
Contributor Author

Eduard van Valkenburg (@eavanvalkenburg) the remaining pre-commit failure was two stray blank lines at the top of the test file that pyupgrade rewrites. cleaned up and pushed, checks should go green now.

Only None short-circuited before; an instructions value of "" (the
usual unset-options default) still injected a system message with empty
content ahead of the conversation. Empty and all-whitespace entries are
dropped, and a real instruction prepends verbatim.

Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
@ManoharPaturi

Copy link
Copy Markdown
Contributor Author

Eduard van Valkenburg (@eavanvalkenburg) found the remaining one: the new test file was missing the copyright notice header that the core lint requires (and ruff reflowed one import while i was in there). header added, all three hooks pass locally now (ruff clean, pyupgrade idempotent, tests 3/3). pushed.

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

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: empty-string instructions inject a contentless system message

3 participants