Python: empty-string instructions inject a contentless system message

Author: ManoharPaturiCreated Sep 18, 2026Updated Sep 18, 2026
Labelspythontriage

Description

prepend_instructions_to_messages(messages, "") injects a system message whose content is an empty string. Only None short-circuits; an empty or whitespace-only instruction list still produces the contentless system message ahead of the real conversation.

Chat options commonly default instructions to "", so every request from an agent that never set instructions carries an empty system message into the model call.

Reproduction

python
from agent_framework import Message, prepend_instructions_to_messages

out = prepend_instructions_to_messages([Message(role="user", contents=["hi"])], "")
# result: [system(''), user('hi')]  -- the empty system message is noise

Expected behavior

An empty or all-whitespace instruction adds no message; a real instruction prepends verbatim (its own whitespace untouched).

Environment

agent-framework python main (b0437908)

Source: microsoft/agent-framework