aws / aws/amazon-q-developer-cli

bug: Q is too eager to compact the context window

Open
#2,787 3 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

AL2

### Expected behaviour

Q doesn't compact the context window until it is necessary

### Actual behaviour

q tries to compact the history, even though 30% of the context window is still available

in the following example, I used ctrl+c to stop the summarization, and then checked the usage. I still have 30% space, even though it tried to compact the history. I expect Q to use the entire context window before compacting, doing this early makes Q lose it train of thought and I usually just have to completely start over from scratch.

There is no way this prompt caused Q to use 30% more tokens. Its just a follow up from its previous prompt.

if this was 90-95% I wouldn't think this was a bug, but still having 30% and getting a compaction makes no sense.

```

> it didn't there are check styles errors

The context window has overflowed, summarizing the history...

> /usage

Current context window (142280 of 200k tokens used)
████████████████████████████████████████████████████████████████████████████████ 71.14%

█ Context files: ~0 tokens (0.00%)
█ Tools: ~58850 tokens (29.43%)
█ Q responses: ~19160 tokens (9.58%)
█ Your prompts: ~64270 tokens (32.14%)

💡 Pro Tips:
Run /compact to replace the conversation history with its summary
Run /clear to erase the entire chat history
Run /context show to see tokens per context file

```

### Steps to reproduce

_No response_

### Environment

```yaml

```

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.