31 tools· updated nov 2026

Gemini CLI context window: 1,048,576 tokens, a hidden usage percent, /compress and /clear

Marek.

  • gemini-cli
  • coding-agents
  • context-engineering

The Gemini CLI context window is 1,048,576 tokens for every Gemini model the CLI knows. That number sits in tokenLimits.ts in the v0.68.0 source. Only two Gemma 4 models get less, 256,000. The footer can show the percent used, but it is off by default. This post is for people who know the Claude Code side and want the Gemini CLI numbers. I do not run Gemini CLI. It is not installed on my machine. Everything here comes from the docs and the v0.68.0 code, read on 12 November 2026.

{
  "ui": { "footer": { "hideContextPercentage": false } },
  "model": { "compressionThreshold": 0.5 }
}

The first key turns the percent on. The second is the default compression trigger, written out.

  • Size. 1,048,576 tokens on Gemini models, 256,000 on gemma-4-31b-it and gemma-4-26b-a4b-it. The docs do not state it. The code does.
  • Where to look. A footer item reads "N% used". It is hidden until you set hideContextPercentage to false or pick it in /footer. /stats model shows token counts.
  • Auto compression. At half the window by default, so 524,288 tokens. model.compressionThreshold moves it.
  • Manual. /compress summarizes the older history now. /clear throws the context away and starts a new session.
  • How I know. Docs and code only. No session of my own.

How Claude Code handles the same budget, with the 33 edits I wasted after compaction, is in Claude Code context window. The Codex numbers are in Codex context window.

What is the Gemini CLI context window size?

Gemini CLI uses a 1,048,576-token window for Gemini models in v0.68.0. In packages/core/src/core/tokenLimits.ts the function tokenLimit returns 1,048,576 for gemini-3-pro-preview, gemini-2.5-pro and the default Flash and Flash Lite models. Any model not listed falls back to the same DEFAULT_TOKEN_LIMIT. The two Gemma 4 models get 256,000.

So Gemini 3 gets the full window too. gemini-3-flash-preview also lands on 1,048,576. A comment in the file says the values were pulled from the Gemini API models page. I did not cross-check that page.

The docs pages I read do not give the number. The configuration reference mentions a "context window usage percentage" but never says what 100 percent is. So the size here comes from the code.

How do I check the context window in Gemini CLI?

Turn on the context item in the footer. In v0.68.0 the setting ui.footer.hideContextPercentage defaults to true, so you see nothing at first. Set it to false in settings.json, or run /footer and pick the item called "context". The item then reads "N% used", or "%" on a narrow terminal.

The percent comes from contextUsage.ts. It is the token count of the last prompt divided by tokenLimit for the current model. In ContextUsageDisplay.tsx the text turns to the warning color at the compression threshold and to the error color at 100 percent.

/footer has the alias /statusline in footerCommand.tsx. The commands reference does not list either name. One trap is in footerItems.ts. Once ui.footer.items holds a list, which is what the /footer dialog saves in FooterConfigDialog.tsx, the old hideContextPercentage flag no longer decides.

For counts instead of a percent, the commands reference says /stats model shows "token counts and quota information". The footer item token-count shows the session total. In headless mode the stream-json result event carries token stats per model, see Gemini CLI headless.

What happens when the Gemini CLI context is full?

Gemini CLI compresses the history before it gets there. The configuration reference describes model.compressionThreshold as "the fraction of context usage at which to trigger context compression", default 0.5, restart required. On a 1,048,576 window that is 524,288 tokens. In chatCompressionService.ts the automatic pass skips the work while the history is under that mark.

What survives is narrower than the docs suggest. The commands page says /compress will "replace the entire chat context with a summary". In the code the newest 30 percent or so of the history, measured in characters, stays as it is. The older part goes to the model, which writes a state_snapshot summary. A later pass folds the old snapshot into the new one.

The session management page offers a second brake, model.maxSessionTurns. It caps the turns kept in a session. The default is -1, no limit.

How do I clear the context window in Gemini CLI?

Type /clear. The commands reference says it clears "the agent conversation context" and starts a new session, besides wiping the screen. In clearCommand.ts it also has the alias /new and gets a fresh session ID. Ctrl+L is not the same thing. Per the docs it only redraws the screen and keeps the context.

If you want to keep the thread but shed weight, use /compress. In compressCommand.ts its aliases are /summarize and /compact, so the Claude Code habit works.

How does the Gemini CLI context window compare with Claude Code and Codex?

Gemini CLI gives every Gemini model 1,048,576 tokens and compresses earliest of the three, at half. Codex gives 500K or 272K by model and compacts at 90 percent. Claude Code starts at 200K and goes to 1M on some models. The Claude Code and Codex columns come from my earlier posts.

Gemini CLI 0.68.0Claude CodeCodex CLI 0.166.0
Default window1,048,576 on Gemini models200K, 1M on models that support it500K or 272K by model
Live viewFooter "N% used", hidden by default/context, status line/status, footer
Auto compaction50% of the windowAt the limit or autoCompactWindow90% of the window
Manual/compress (/compact)/compact with a focus/compact

Copilot CLI picks the window by model and compacts near 80 percent, see Copilot CLI context window. opencode takes the window from each model's limit.context, see opencode context window.

Frequently asked questions

Does Gemini CLI have a 1M context window?

Yes, per the v0.68.0 code. tokenLimit returns 1,048,576 tokens for the Gemini models, which is 2 to the 20th power. The docs pages I read do not print the number.

Why don't I see the context percent in the Gemini CLI footer?

The percent is off by default. ui.footer.hideContextPercentage defaults to true in v0.68.0. Set it to false, or add the "context" item with /footer. If ui.footer.items is already set, edit that list instead.

When does Gemini CLI compress the chat?

At 50 percent of the window by default, so 524,288 tokens on a Gemini model. Change it with model.compressionThreshold, a fraction like 0.3. The docs say it needs a restart. /compress runs it any time.

Did you test this?

No. Gemini CLI is not installed on my machine. I read the docs and the v0.68.0 source on 12 November 2026. I have not seen the footer, /compress or /clear run.

The verdict

Gemini CLI gives you about 1M tokens and starts compressing at half of it. I would turn on the footer percent first. Use /clear between unrelated tasks and /compress inside a long one. I have not run any of it.

Sources, read on 12 November 2026: the Gemini CLI commands reference, configuration reference and session management pages. Code from google-gemini/gemini-cli at tag v0.68.0: tokenLimits.ts, models.ts, chatCompressionService.ts, contextUsage.ts, ContextUsageDisplay.tsx, footerItems.ts, and the clear, compress and footer command files.