garrytan / garrytan/gstack

Context warnings trigger too early on 1M context window models

Open
#510 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
133k
Forks
19.9k
Avg merge
18h 46m
Merged PRs (30d)
26

Description

## Problem

gstack skills (especially `/plan-eng-review`) warn about context running low even when context usage is only ~27%. On a 1M context window (Claude Opus 4.6), 27% means ~730K tokens remaining — far from any real constraint.

## Root Cause

The prompt in `plan-eng-review/SKILL.md:307` contains:

> "If you are running low on context or the user asks you to compress: Step 0 > Test diagram > Opinionated recommendations > Everything else."

This instruction makes the model **context-anxious** regardless of actual available space. The model doesn't have precise token-counting ability — it relies on heuristics like conversation length. When the prompt explicitly mentions context management, the model becomes overly cautious and starts warning/compressing prematurely.

This was likely calibrated for 200K context windows. On 1M models, the thresholds are completely wrong:

| Context Used | 200K remaining | 1M remaining | Should warn? |
|---|---|---|---|
| 27% | ~146K | ~730K | 200K: maybe. 1M: absolutely not |
| 50% | ~100K | ~500K | 200K: yes. 1M: no |
| 80% | ~40K | ~200K | Both: yes |

## Suggested Fix

Make context management **context-window-aware**. Options:

1. **Detect model context size** — Check if the model has extended context (1M) and adjust thresholds accordingly. Could use a `gstack-config` setting like `context_window: 1m`.

2. **Remove the proactive instruction** — Instead of telling the model to watch for low context, only react when Claude Code's own compaction system triggers. The system already handles this automatically.

3. **Add a user config** — `gstack-config set context_warning off` to let users opt out of context management hints in the prompt.

## Environment

- gstack v0.11.19.0
- Claude Opus 4.6 (1M context)
- Skills affected: at least `plan-eng-review`, likely others with similar instructions

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.