Skip to main content

Explain it like you'd tell grandma.

Project description

grandma mascot

๐Ÿ‘ต grandma

The digest layer for noisy AI agents.

PyPI - Version PyPI - Python Version PyPI - Downloads License: MIT CI


Your AI agent just wrote 2,000 words. You need the next step. grandma extracts it.

Pipe any LLM output through grandma and get a clean terminal card: what happened, the bottom line, what to do next. No API key needed if you use Claude Code.

pipx install grandma
grandma --demo

Try it in 30 seconds

# zero-config if you have Claude Code installed
echo "$(cat some-agent-output.txt)" | grandma

# local model via Ollama (no cloud key needed)
GRANDMA_MODEL_BACKEND=ollama GRANDMA_MODEL=llama3.1 grandma --demo

# any provider
GRANDMA_MODEL_BACKEND=openai GRANDMA_MODEL=gpt-4o-mini OPENAI_API_KEY=sk-... grandma --demo

Before / After

Raw agent output (~90 words, ~120 tokens):

I inspected the repository and found that the authentication flow now routes through
the new async session adapter. I updated three files, added one regression test, and
confirmed that the login path still returns the expected token shape. There is one
compatibility consideration: the adapter relies on asyncio.TaskGroup, so Python 3.10+
is required. Overall, this should reduce request latency by ~70%, but the deployment
notes should mention the runtime floor bump.

After grandma (default mode โ€” ~30 words):

๐Ÿ‘ต grandma
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”
๐Ÿ“– Second turn reviewing an auth refactor PR.

What happened: Auth moved to the async session adapter.
Bottom line:   Faster login path, but Python โ‰ฅ3.10 required.
Do next:       Update deployment docs before shipping.
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

After grandma (deep mode โ€” full impact table):

๐Ÿ‘ต grandma
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ ๐Ÿ“– story arc โ”‚ Second turn reviewing an auth refactor PR.   โ”‚
โ”‚ ๐Ÿ‘€ happened  โ”‚ Auth moved to async session adapter.         โ”‚
โ”‚ ๐Ÿงถ changed   โ”‚ 3 files, 1 regression test added.            โ”‚
โ”‚ โœ… positive  โ”‚ Login latency reduced ~70%; token shape OK.  โ”‚
โ”‚ โš ๏ธ  negative  โ”‚ Requires Python โ‰ฅ3.10 (asyncio.TaskGroup).  โ”‚
โ”‚ โž– neutral   โ”‚ API surface unchanged.                        โ”‚
โ”‚ ๐Ÿ’ก net gain  โ”‚ Win โ€” ship it with a runtime floor note.     โ”‚
โ”‚ ๐Ÿ“‹ actions   โ”‚ - Bump requires-python to >=3.10             โ”‚
โ”‚              โ”‚ - Update deployment docs                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Install

pip install grandma        # pip
pipx install grandma       # isolated (recommended)
uv tool install grandma    # uv
pip install git+https://github.com/ypollak2/Grandma.git  # from source

Requires Python โ‰ฅ 3.10.


Usage

echo "agent output..." | grandma              # default 3-line card
cat output.txt | grandma --mode deep          # full impact table
cat output.txt | grandma --json               # raw JSON verdict
cat output.txt | grandma --mode off           # passthrough (for hooks)
grandma --demo                                # try it with no input
grandma --demo --mode deep
export GRANDMA_MODE=deep                      # set default for session

The modes

Mode Output Best for
default 3-line card: happened / bottom line / do next Most agent output
deep Full impact table with positive/negative/neutral PRs, arch decisions, refactors
off Passthrough โ€” original text unchanged Hook pass-through control

๐Ÿ’ธ Why this matters: token savings

Every intermediate agent response fed into the next prompt costs tokens. Grandma compresses the signal.

Words Tokens (approx)
Raw LLM response ~400 ~530
grandma card ~40 ~55
Saving ~90% ~90%

Across a 20-turn session: 8,000โ€“12,000 context tokens saved.


Model backends โ€” bring your own

Grandma auto-detects the best available backend. No config needed to get started with Claude Code.

Priority When Backend
1 GRANDMA_MODEL_BACKEND set Explicit provider
2 GRANDMA_MODEL / GRANDMA_API_KEY / GRANDMA_BASE_URL set OpenAI-compatible
3 OPENAI_API_KEY set OpenAI
4 GROQ_API_KEY set Groq
5 GEMINI_API_KEY / GOOGLE_API_KEY set Gemini
6 ANTHROPIC_API_KEY set Anthropic SDK
7 (nothing set) claude -p - (Claude Code subscription, no key)

Model names are fully dynamic โ€” no hardcoded vendor strings in grandma. You choose the model; grandma uses whatever you set. For backends that don't require an explicit model (claude_cli, anthropic SDK), grandma lets the provider pick its own default.

Copy .env.example โ†’ .env and uncomment your provider:

cp .env.example .env

Ollama (local, no key):

GRANDMA_MODEL_BACKEND=ollama
GRANDMA_MODEL=llama3.1
GRANDMA_DEEP_MODEL=deepseek-r1

Groq (fast inference):

GRANDMA_MODEL_BACKEND=groq
GRANDMA_MODEL=llama-3.1-8b-instant
GRANDMA_DEEP_MODEL=llama-3.3-70b-versatile
GROQ_API_KEY=gsk_...

OpenAI:

GRANDMA_MODEL_BACKEND=openai
GRANDMA_MODEL=gpt-4o-mini
GRANDMA_DEEP_MODEL=gpt-4.1
OPENAI_API_KEY=sk-...

Gemini:

GRANDMA_MODEL_BACKEND=gemini
GRANDMA_MODEL=gemini-2.5-flash
GRANDMA_DEEP_MODEL=gemini-2.5-pro
GEMINI_API_KEY=AIza...

Any OpenAI-compatible provider (Together, Fireworks, LM Studio, etc.):

GRANDMA_MODEL_BACKEND=openai_compatible
GRANDMA_BASE_URL=https://your-provider.example.com/v1
GRANDMA_API_KEY=your-key
GRANDMA_MODEL=your-model-name

Custom subprocess (anything that reads stdin):

GRANDMA_MODEL_BACKEND=custom_command
GRANDMA_MODEL_COMMAND=ollama run llama3.1

IDE & agent integrations

Auto-install all detected tools:

./install.sh
Tool How Effect
Claude Code Stop hook Auto-card after every long response
Codex CLI Stop hook Auto-card after every long response
Gemini CLI AfterAgent hook Auto-card after every agent turn
Cursor MCP + rules Agent calls grandma_summarize automatically
Cline MCP + rules Agent calls grandma_summarize after tasks
Continue MCP + slash command On demand or automatic
Windsurf MCP + rules Agent calls grandma_summarize automatically
Zed MCP (context_servers) Tool in Zed AI panel
Goose MCP extension Tool in Goose sessions
Aider pipe wrapper Pipe aider output through grandma
OpenHands pipe wrapper Pipe headless output through grandma

MCP server โ€” works with any MCP-capable IDE:

grandma serve

Add to .mcp.json:

{
  "mcpServers": {
    "grandma": { "command": "grandma", "args": ["serve"] }
  }
}

Tools exposed: grandma_summarize(text, mode, story_context) and grandma_summarize_json(...).


Troubleshooting

"No model configured for backend X" Set GRANDMA_MODEL=<model-name> in your .env. See .env.example for provider examples.

"claude CLI not found" Install Claude Code or set a different backend via GRANDMA_MODEL_BACKEND.

Output is not JSON / parsing error The model returned something unexpected. Try --mode off to see the raw response, then check your model/backend config.

Provider returns 401 / 403 Check that the right API key env var is set for your backend (e.g. OPENAI_API_KEY, GROQ_API_KEY).


How the mascot rotates

Each portrait in assets/grandmas/ was generated with Gemini Image. A daily GitHub Action picks one at random and replaces assets/grandma.png with a [skip ci] commit.

Want to add your own grandma? Drop a PNG into assets/grandmas/ and open a PR.


Contributing

See CONTRIBUTING.md for full details. Quick start:

git clone https://github.com/ypollak2/Grandma.git
cd Grandma
pip install -e ".[dev]"
pytest tests/        # run tests
ruff check src       # lint

Good first issues are tagged good first issue.


FAQ

Does grandma make it dumber? No dear. She keeps the facts. She removes the fog machine.

What model does it use? Whatever you configure via GRANDMA_MODEL. There are no hardcoded model names. If you set nothing, claude_cli lets Claude Code pick, and anthropic lets the SDK pick its default. API-based backends (openai, groq, ollama, gemini) require GRANDMA_MODEL to be set.

Why is there an off mode? Because hooks need a clean passthrough option. When GRANDMA_MODE=off, grandma becomes transparent โ€” useful for temporarily disabling the Stop hook without unregistering it.

What's the story_so_far line? Grandma reads the last 3 turns of the conversation to track where you are in the arc. Turn 8 of the same auth bug? She'll say so. This is the dementia prevention feature.

Why Python โ‰ฅ 3.10? The mcp package (used for grandma serve) requires 3.10+.

How is this different from llm / fabric / shell_gpt? llm gives you model access. fabric gives you prompt patterns. shell_gpt gives you a REPL. grandma does none of those things. It sits at the output end โ€” it is the digest layer you add after any of those tools to stop reading 2,000-word agent responses.


Changelog

See CHANGELOG.md.


Made with ๐Ÿ’œ by Yali Pollak ยท MIT License ยท PyPI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grandma-0.2.1.tar.gz (42.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grandma-0.2.1-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file grandma-0.2.1.tar.gz.

File metadata

  • Download URL: grandma-0.2.1.tar.gz
  • Upload date:
  • Size: 42.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for grandma-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a747f4835d2b18a0b5749d4d8b4be2a53464ef9b8380c1fd2869e9d11a1e5ef5
MD5 715e0e3ec0a7f40d2d77c86b200c7b84
BLAKE2b-256 410bdd2be50e5dbb4b801232ce622b43f66205e9101ed720330d82dc602daf71

See more details on using hashes here.

File details

Details for the file grandma-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: grandma-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for grandma-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0fdc32d973ad107c84544007b27836d643598f5d181c82e7d2a669977eaaa8cf
MD5 860b89016c230e5ef5636415000bcaea
BLAKE2b-256 14f87a4c1b16a44bb173c3985991b1f5430954c280db44ee8d8d99bdd32e4b49

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page