explaingit

0xtotem/peek-dspy

Analysis updated 2026-05-18

42PythonAudience · developerComplexity · 3/5Setup · moderate

TLDR

A DSPy library that gives AI agents a self-updating context map so they stop re-learning the same background information on every question.

Mindmap

mindmap
  root((peek-dspy))
    What it does
      Self updating context map
      Reduces repeated orientation
      Wraps DSPy modules
    Tech stack
      Python
      DSPy framework
      Claude models
    Use cases
      Codebase question answering
      Document collection agents
      Repeated interactions
    Components
      Distiller
      Cartographer
      Evictor
    Audience
      AI researchers
      DSPy developers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Make an agent that answers many questions about the same codebase more efficient over time.

USE CASE 2

Wrap an existing DSPy module so it keeps a growing summary of what it has learned.

USE CASE 3

Cap how much context an agent carries by evicting low-value information automatically.

USE CASE 4

Inspect an agent's accumulated understanding of a document collection at any point.

What is it built with?

PythonDSPyPoetryClaude

How does it compare?

0xtotem/peek-dspyant-research/memdreamerdexoryn-china/polymarket-arbitrage-bot
Stars424242
LanguagePythonPythonPython
Setup difficultymoderatehardmoderate
Complexity3/55/54/5
Audiencedeveloperresearcherdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires Poetry and an Anthropic API key since the examples use a Claude model.

No license information is provided in the explanation.

In plain English

peek-dspy is a Python library that ports a research technique called PEEK into the DSPy AI programming framework. PEEK stands for a self-updating context map, which is a block of text that lives inside an AI agent's prompt and gets smarter over time. Instead of starting fresh on every question, the agent carries a growing summary of structural knowledge about whatever it is working on, such as a codebase or a document collection. The core idea is that when you ask an AI agent many questions about the same external context, a lot of repeated orientation work gets redone on each call. PEEK separates that orientation work from question-specific reasoning, saves the useful parts, and trims what is no longer needed. This makes repeated interactions more efficient because the agent does not have to re-learn the structure of the thing it is looking at each time. Under the hood, three components handle the map updates after each call. A Distiller figures out which parts of the agent's reasoning were about understanding the context versus answering the specific question. A Cartographer then produces structured edits to the map, adding new facts, removing stale ones, or replacing outdated sections. An Evictor keeps the map within a token budget by dropping sections judged to be low-value. To use it, you wrap any existing DSPy module with the PEEK wrapper, set a token budget and an optional freeze point, and then run your questions through it as usual. The map accumulates automatically. You can inspect the current map at any time through a provided property on the policy object. Setup requires Python with Poetry, and an Anthropic API key since the examples use a Claude model. The library is a direct port of the upstream PEEK implementation described in an academic paper linked in the README.

Copy-paste prompts

Prompt 1
Help me wrap an existing DSPy module with the PEEK wrapper and set a token budget.
Prompt 2
Explain how the Distiller, Cartographer, and Evictor components work together.
Prompt 3
Show me how to inspect the current context map on a policy object.
Prompt 4
Set up this project with Poetry and an Anthropic API key so I can run the examples.
Prompt 5
Explain why a self-updating context map saves work compared to starting fresh each time.

Frequently asked questions

What is peek-dspy?

A DSPy library that gives AI agents a self-updating context map so they stop re-learning the same background information on every question.

What language is peek-dspy written in?

Mainly Python. The stack also includes Python, DSPy, Poetry.

What license does peek-dspy use?

No license information is provided in the explanation.

How hard is peek-dspy to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is peek-dspy for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.