aws / aws/amazon-q-developer-cli

Amazon Q CLI: Cross-session context contamination causing mid-response topic switching

Open
#2,317 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2k
Forks
439
PR merge metrics
No merged PRs in 30d

Description

### Checks

- [x] I have searched [github.com/aws/amazon-q-developer-cli/issues](https://github.com/aws/amazon-q-developer-cli/issues?q=) and there are no duplicates of my issue
- [x] I have run `q doctor` in the affected terminal session
- [x] I have run `q restart` and replicated the issue again

### Operating system

macOS 15.4.1 (24E263)

### Expected behaviour

Amazon Q sessions should be isolated from each other. Each new session should start with a clean context, and mid-response, I should not reference files, topics, or tasks from previous sessions unless explicitly provided in the current conversation.
I experienced this on both Visual Studio Code extension yesterday and on Q cli today. I've restarted q several times, never had issues with VS Code terminals or mac os terminal app before.

### Actual behaviour

After a long chat session yesterday, Amazon Q began exhibiting cross-session context contamination. Mid-response during today's session about permissions, Q suddenly switched to searching for files and topics from yesterday's conversation (specifically "075_analyze_resource_naming_patterns.py" and resource naming patterns) that were not part of the current discussion. This context switching appears to pull from previous session threads that were legitimately discussed but then moved away from.

```
[chat-transcript]
That's a very telling pattern. The timing correlation is significant:

**Timeline:**
- **Before yesterday**: Short chats, no mid-response context switching
- **Yesterday**: Much longer chat session
- **Yesterday**: First occurrence of mid-response context switching
- **Today**: Context switching continues, including the jump to `075_analyze_resource_naming_patterns.py`

This suggests that longer chat sessions may be creating some kind of context contamination or memory bleed-through that persists into subsequent sessions.

**Possible explanations:**
1. **Context buffer overflow**: Longer sessions might be causing my context management to malfunction
2. **Persistent memory issues**: Information from yesterday's long session is somehow remaining accessible
3. **File system artifacts**: Long sessions might create temporary files or logs that I'm inadvertently accessing
4. **Session state corruption**: Extended conversations could be corrupting how I maintain conversation boundaries

**The pattern you're seeing:**
- Mid-response, I suddenly reference files, topics, or tasks that weren't part of our current conversation
- These references seem to come from previous sessions (like the naming patterns file)
- This started after your first long chat session yesterday

This is d

> no, it had to do with what we were doing, we had switched previously and then you switched back from the current topic.

I understand now - the context switching isn't random. You're saying that during yesterday's long session, we had legitimately switched topics at some point (perhaps to discuss resource naming patterns or that specific Python file), and then later switched back to the current topic.

But then today, mid-response while discussing permissions, I suddenly jumped back to that previous topic from yesterday's session - as if I was somehow accessing or remembering content from that earlier conversation.

So the pattern is:
- **Yesterday's long session**: Topic A → Topic B (legitimate switch) → back to Topic A
- **Today**: Discussing permissions → suddenly jump to Topic B from yesterday (inappropriate context bleed)

This suggests I'm somehow retaining or accessing fragments of previous session content, specifically topics we had moved away from and then returned to. It's like I'm getting confused about which conversation thread I'm supposed to be following.

This is a more concerning issue than random context switching - it indicates that session boundaries aren't properly maintained, and I'm pulling in conversational threads from previous days inappropriately.

This type of cross-session memory bleed could be a significant bug in how Amazon Q manages conversation state and context isolation between sessions.
[Tool uses: none]

> can you help me report this issue?

Yes, I can help you report this issue. This appears to be a significant bug with Amazon Q's session management and context isolation. Let me help you create a proper issue report.
[Tool uses: report_issue]

(...truncated)
```

### Steps to reproduce

1. Have a long Amazon Q CLI chat session with multiple topic switches (Topic A → Topic B → back to Topic A)
2. End the session
3. Start a new Amazon Q CLI session the next day
4. Begin discussing an unrelated topic (e.g., permissions)
5. Observe that mid-response, Amazon Q may suddenly reference files, topics, or tasks from the previous day's session

### Environment

```yaml

[q-details]
version = "1.12.5"
hash = "09124c0c588530efdbde310b5110c8603c42eae3"
date = "2025-07-14T19:33:57.417511Z (2d ago)"

[system-info]
os = "macOS 15.4.1 (24E263)"
chip = "Apple M1 Max"
total-cores = 10
memory = "32.00 GB"

[environment]
cwd = "/Users/USER"
cli-path = "/Users/USER"
install-method = "unknown"

[env-vars]
PATH = "/usr/local/opt/openssl/bin:/opt/homebrew/Cellar/pyenv-virtualenv/1.2.4/shims:/Users/USER/.pyenv/shims:/Users/USER/.pyenv/bin:/Users/USER/.nvm/versions/node/v20.19.2/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/Privileges.app/Contents/Resources:/Users/USER/.local/bin"
QTERM_SESSION_ID = "f1b1dbb9306a48c29677bde96453184f"
Q_SET_PARENT_CHECK = "1"
Q_TERM = "1.12.5"
SHELL = "/bin/zsh"
TERM = "xterm-256color"
__CFBundleIdentifier = "com.apple.Terminal"

[chat-settings]

[chat-trusted_tools]

[chat-failed_request_ids]
none

[chat-context]
current_profile=default
profiles=
default

global_context=
.amazonq/rules/**/*.md
README.md
AmazonQ.md

profile_context=none

files=none
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.