Python: empty-string instructions inject a contentless system message

Open Beginner friendly
#8,523 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
ai

Research direction

Start at the prepend_instructions_to_messages entry point and reproduce the empty-string case shown in the issue. Add coverage for empty and whitespace-only instructions, while confirming real instructions are prepended verbatim and no message is added for blank input.

Written by the indexing model from the issue text.

Description

python triage
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
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)

Dominant language
Python
Stars
13.6k
Forks
2.3k
Avg merge
1d 20h
Merged PRs (30d)
342

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/agent-framework

All issues in microsoft/agent-framework

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.