What is Lens?
Let your agent see what you see.
Lens is a widget for marimo, a reactive Python notebook. Mark part of a result, ask a question, and give a live notebook agent the selection and its producing cells. Lens shows the agent's activity and returns results to the notebook for your review.
Mount one Lens in a notebook:
from marimo_lens import Lens
lens = Lens()
lensPress Select, click a point or drag a region, then add an optional note. Lens stores that attention as a selection.
From a mark to a request
A target is the rendered result or page area a person can select. Most targets are notebook outputs. Host applications can also make their own page areas selectable.
A selection is one point or region inside one target. It has a stable S<n> label, an optional note, producing-cell references, and selection-image status. The current selection is the likely referent when a person says “this” or “here.” One request to an agent can use several selections.
Lens context is a detached, revisioned handoff returned by lens.context(). It keeps the selection, its producing cells, relevant notebook context, and visual evidence together for the agent.
Point, revise, review
- Point and ask. Select a point or region and add a note such as “Explain this spike.” Lens connects the marked output to its producing cells and relevant upstream computation.
- Revise and verify. Your agent reads that context, inspects the live notebook, and runs the changes. Lens marks where it is working and brings returned results into view.
- Review and continue. The agent resolves the selection into History after addressing it. You judge the evidence and can reopen the request for another pass.
Addressed records the agent's handoff. Your review determines whether the result answers the question. Reopening restores the mark and note on the current output, which may have changed since the original selection.
Connect your notebook agent
A code-mode agent can execute Python in the live notebook kernel to inspect, edit, and run cells. marimo Pair provides one such connection. Lens supplies selection context and visible feedback through that connection. The agent integration performs notebook edits and execution.
Connect an agent covers setup and the complete workflow.
Choose your next step
| I want to… | Start here |
|---|---|
| Make my first selection | Getting started |
| Understand visual and computational grounding | Why Lens? |
| Try the agent feedback loop | How Lens works |
| Select a dashboard or application region | Targets |
| Inspect what an agent receives | Context and evidence |
| Look up a method or returned value | Python API |