Gemini CLI
Use the Gemini CLI through AnyAgent: what you can ask for, how it behaves, and the flags underneath.
The gemini-cli adapter drives the Gemini CLI in headless mode, detected as the gemini binary on PATH; import geminiCli from anyagent/gemini-cli.
What you can ask for
model, readOnly, and resume work on the CLI’s own flags; systemPrompt and schema are provided by AnyAgent. effort, mcp, and model listing are undeclared and throw. authStatus() is a heuristic over ~/.gemini/oauth_creds.json, GEMINI_API_KEY/GOOGLE_API_KEY, and ~/.gemini/settings.json; a selected auth type with no visible key answers "unknown", since keys can live in the OS keychain. The full grid is on the support matrix.
Good to know
Pin a model. Automatic routing can spend minutes self-investigating a trivial prompt, so never leave model unset expecting a sane default.
- The init event’s session id lands on
result.sessionId;resumetakes that UUID. - Resuming a live session from a different process can fail; start a fresh session instead.
- Usage maps the terminal stats block:
cachedbecomescacheReadTokens.
Under the hood
Every run executes gemini -p "" --output-format stream-json --skip-trust --approval-mode yolo with the prompt piped over stdin. Run options change the mode and append flags:
| Option | Flag |
|---|---|
readOnly: true | --approval-mode default, whose headless toolset has no write or shell tools |
model | -m <name>, in the Gemini CLI’s own vocabulary; never defaulted |
resume | --resume <sessionId> |