microsoft / microsoft/agent-framework
Python: empty-string instructions inject a contentless system message
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 2.3k
- Avg merge
- 2d 45m
- Merged PRs (30d)
- 358
Description
### 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`)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- python
- Domain
- ai
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100