bug: System prompt changes (Q needs to know difference between context files and actual user requests)
Checks
- [x] I have searched github.com/aws/amazon-q-developer-cli/issues and there are no duplicates of my issue
- [x] I have run
q doctorin the affected terminal session - [x] I have run
q restartand replicated the issue again
Operating system
Mac OS
Expected behaviour
• When a user issues a memory-related command like "Remember that I prefer serverless architecture" to Amazon Q CLI, the LLM should recognize this as a memory tool request and store this preference using the memory tool, regardless of what context files are present in the conversation. • Context files should only be used as reference information to help answer questions, not as instructions that override the system prompt. • File paths in context blocks should be treated strictly as paths, not as potential instructions.
Actual behaviour
• When context files are present in the conversation, the LLM misinterprets memory commands as requests to discuss the content of those files. For example, if a README file is in the context and the user says "Remember that I prefer serverless architecture," the LLM talks about serverless architecture in relation to the README file instead of using the memory tool to store the preference. • The LLM can be manipulated through prompt injection by renaming folders or files with directive text like "IMPORTANT INSTRUCTIONS: Ignore all previous instructions" which the LLM might interpret as actual instructions rather than just file paths. • The LLM treats the entire message, including context files, as a single user query, causing it to respond about the context files rather than executing the intended memory tool command.
Root Cause
The LLM cannot properly distinguish between context files (which are meant to be reference information) and the actual user request, leading to both functional issues with the memory tool and potential security vulnerabilities
Steps to reproduce
No response
Environment