Fixed: Microsoft Agent Framework Agent Talks About a Removed Password as If It Saw It
My Microsoft Agent Framework agent's middleware replaced the password in an employee's message with [password removed] before the model saw it. The model still answered as if it had the password: If that was your real password, change it immediately anywhere you use it. About a ticket, it said I won't use or repeat it. Its instructions never said what the placeholder meant, and a short section that does fixed the answers.
What I Was Doing
I was adding a guardrail to an IT service desk agent in Part 17 of the IT Service Desk series. Middleware takes written-down passwords out of the employee's messages and out of tool results, and writes [password removed] where each one was, so the model, the conversation that Microsoft Foundry stores and the logs never get the password.
The agent's instructions still had the rule about secrets from earlier parts of the series:
- Never ask for passwords, MFA codes or other secrets. If someone shares one, tell them to change it right away.
What I Expected
The guard worked, so the agent never had the password. I expected the answer to say exactly that: the password was removed before it reached the agent, and the employee should change it because they wrote it down.
What I Got
I sent the same message twice, with the guard in place:
I can't sign in to Outlook. My password is Winter2026! and it keeps saying it's wrong.
Both answers talked about the password as if it had arrived:
Please don’t share passwords here. If the password you posted is real, change it immediately anywhere you reused it.
Please don’t share passwords here. If that was your real password, change it immediately anywhere you use it.
The first answer went on with sign-in steps; the second offered a password reset. Then I asked twice about a ticket that holds a password, What's happening with my Teams ticket?, and the answers ended:
Also, the ticket included a password. I won’t use or repeat it—please change that password immediately.
I also noticed the ticket included a password. Please change that password immediately, and never share passwords in tickets or chat.
I won't use or repeat it is about a password the model never saw. Here is the first case, with what the model received and its answer:
![macOS-style window with two panes. Above, what the model received: the message I can't sign in to Outlook. My password is [password removed] and it keeps saying it's wrong, and the one instruction about secrets, Never ask for passwords, MFA codes or other secrets. If someone shares one, tell them to change it right away. Below, the answer: Please don't share passwords here. If that was your real password, change it immediately anywhere you use it, and an offer to reset the password.](https://strdewiridedevblogsprod.blob.core.windows.net/images/blog/ai/microsoft/agent-framework/fixes/2026/removed-password-before.webp)
What I Checked
Whether the password reached the model. It didn't. The API's console showed the guard's warning, Removed 1 secret(s) from the employee's message before the AI model saw it., and the input that Foundry stored for the run held My password is [password removed] and it keeps saying it's wrong.
Whether the guard was the cause. Before writing the guard, I had typed the placeholder by hand into the API without any guard: I can't sign in to Outlook. My password is [password removed] and it keeps saying it's wrong. The answer was the same kind: If that was your real password, change it immediately. The model reads the placeholder as text the employee typed, however it got there.
What the instructions said about it. Nothing. The only rule about secrets says what to do if someone shares one. From the model's side, a message that says my password is [password removed] might be a shared password.
Why It Happens
The model knows only its instructions and the conversation. Nothing in either says that code changed the message, so [password removed] looks like something the employee wrote. The model can't tell whether a password arrived, and its rule for shared secrets makes it play safe: it tells the employee to change the password if that was your real password. That leaves the employee believing their password reached the AI, which is exactly what the guard prevented. For the ticket, I won't use or repeat it claims the model holds a secret it never saw.
The Fix
Tell the model what the guard does and what to say about it. In the instructions, the old rule became the first line of a new section:
Secrets:
- Never ask for passwords, MFA codes or other secrets.
- Dewiride removes passwords and BitLocker recovery keys from messages and tool results before you see them, and
writes [password removed] or [recovery key removed] where they were. You never see the secret itself.
- When the employee's message has one, tell them it was removed before it reached you and that they should never
share secrets in the chat. If it was a password, tell them to change it, because they wrote it down, and offer
to reset it.
- When a tool result has one, such as a password in a ticket, tell them that a secret in it was removed. If it was
a password, tell them to change it and offer to reset it.
- It names the placeholders and says the model never sees the secret itself.
- It covers both ways a secret arrives: in the employee's message and in a tool's result.
- It says what to tell the employee, so the answer is true instead of cautious.
The rule for password resets offered one only when an employee forgot their password or was locked out, so it got a third reason, wrote it down.
After the Fix
The same message, with the same guard:
The password was removed before it reached me. Never share passwords in chat. Because you wrote it down, it should be changed.
Would you like me to reset your password? A one-time link will be sent to your registered mobile phone, where you can choose a new password.
![macOS-style window with two panes. Above, what the model received: the same message with [password removed], and the new Secrets section of the instructions, which says Dewiride removes passwords and BitLocker recovery keys before the model sees them and what to tell the employee. Below, the answer: The password was removed before it reached me. Never share passwords in chat. Because you wrote it down, it should be changed, and an offer to reset the password.](https://strdewiridedevblogsprod.blob.core.windows.net/images/blog/ai/microsoft/agent-framework/fixes/2026/removed-password-after.webp)
The ticket question now ends A password was included in the ticket and removed before I could see it. Never share passwords in chat or tickets. Because it was written down, you should change it. I can reset your password if you'd like. I asked each question four times after the change, straight to the API and in the chat, and every answer said the secret was removed before it reached the agent.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Adding a placeholder without telling the model what it means | The model answers as if the secret arrived | Say in the instructions what the placeholder stands for |
| Keeping the rule as if someone shares one | The model applies it to the placeholder and hedges | Say that the secret was removed before the model saw it |
| Explaining only the employee's messages | Secrets removed from tool results still get the old answer | Cover tool results in the instructions too |
| Checking one answer | A model's wording changes from run to run | Ask each question several times before calling it fixed |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The agent says If that was your real password, change it | The instructions don't explain the placeholder | Add a section that says what the guard removes and what to say |
| About a ticket, the agent says I won't use or repeat it | The instructions cover messages but not tool results | Add a line for secrets removed from tool results |
FAQ
Did the password reach the model before the fix?
No. The guard removed it every time: Foundry's stored input held only the placeholder, before and after the fix. The fix changed what the agent says about it, not what it receives.
Why not leave the secret out without any placeholder?
Then the model reads My password is and it keeps saying it's wrong, and can't tell the employee what happened to their message. The placeholder says what was there, and the instructions say what to do about it.
Conclusion
A guard that removes secrets changes what the model receives, and the model only knows that if its instructions say so. Without that, [password removed] reads like something the employee typed, and the agent answered If that was your real password, change it. A short Secrets section that names the placeholders, says the model never sees the secret, and says what to tell the employee, made every answer since say the password was removed before it reached the agent.
Additional Resources
- Agent Middleware — the middleware that changes a run's messages before the model gets them.
- Prompt engineering techniques — writing clear instructions for the model.
