Skip to content

feat: digest a session without a query, with sketch - #124

Merged
dacorvo merged 2 commits into
mainfrom
sketch_verb
Aug 28, 2026
Merged

feat: digest a session without a query, with sketch#124
dacorvo merged 2 commits into
mainfrom
sketch_verb

Conversation

@dacorvo

@dacorvo dacorvo commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

funes sketch <session_id> selects the passages most distinctive within one session, from the vectors already stored — the read for an open-ended judgement about a session, where what answers it is usually what does not belong in it.

The selector is ported unchanged, with its tests, from feat/guided-curation, where it fed a preview pane: pivoted Gram-Schmidt over the stored vectors, centring each passage on the session's own mean and taking the largest residual. Left behind are the picker's context neighbours, the per-turn refresh hook, the ANSI preview, and the cache-outcome reporting, none of which has a caller here.

Agent-facing, it takes only what a caller has a basis for choosing: units, max_chars, and a from/to window. The bounds clamp the output instead of validating arguments against each other — 40 places, 40,000 characters, a floor of 240 per place, and no passage may take more than its share — and every clamp and elision is stated. A whole-session digest is cached: 13,281 turns, 1.78s to 0.15s.

`funes sketch <session_id>` selects the passages most distinctive within one
session, from the vectors already stored — the read for an open-ended judgement
about a session, where what answers it is usually what does not belong in it.

The selector is ported unchanged, with its tests, from `feat/guided-curation`,
where it fed a preview pane: pivoted Gram-Schmidt over the stored vectors,
centring each passage on the session's own mean and taking the largest residual.
Left behind are the picker's context neighbours, the per-turn refresh hook, the
ANSI preview, and the cache-outcome reporting, none of which has a caller here.

Agent-facing, it takes only what a caller has a basis for choosing: `units`,
`max_chars`, and a `from`/`to` window. The bounds clamp the output instead of
validating arguments against each other — 40 places, 40,000 characters, a floor
of 240 per place, and no passage may take more than its share — and every clamp
and elision is stated. A whole-session digest is cached: 13,281 turns, 1.78s to
0.15s.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new query-independent “session digest” read path (funes sketch) that selects the most distinctive passages within a session from stored embeddings, renders them in the agent contract format (with → get drill-down hints), and wires the command through CLI + MCP, with docs and integration coverage.

Changes:

  • Introduces session_sketch deterministic selector + caching and exposes it via funes sketch.
  • Adds agent-format rendering for sketches and integrates the command into CLI and MCP tooling.
  • Updates docs/agent contract plus adds integration test assertions for sketch behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/index_recall.rs Adds integration assertions for sketch formatting, clamping reporting, and missing-session error behavior.
src/ui/render.rs Implements the byte-stable agent rendering for sketch output, including clamp notes and → get hint lines.
src/session_sketch.rs Adds the core session sketch selection logic, budgeting/clamping rules, caching support, and unit tests.
src/main.rs Wires the new Sketch subcommand into the CLI with flags (--units, --max-chars, --from, --to).
src/lib.rs Exposes the new session_sketch module publicly.
src/commands/sketch.rs Implements the funes sketch command, including clamp reporting and cached whole-session sketches.
src/commands/recall.rs Makes is_scaffolding visible to the sketch selector so scaffolding can be excluded consistently.
src/commands/mcp.rs Adds the sketch MCP tool + request schema and routes calls to the command implementation.
src/commands.rs Registers the new sketch command module.
docs/recall.md Documents CLI usage, output shape, defaults/clamps, and intended use-cases for sketch.
AGENTS.md Extends the published agent read-contract to include the new sketch verb and MCP tool list.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread AGENTS.md
Comment on lines +127 to +131
sketch <session_id> — <n> of <units> places · <chars> of <max-chars> chars · <k> eligible units
(units clamped to <n>)
[<ts>] <role> <block_type> seq<N> · shortened
→ get <session_id> --from <seq> --to <seq> --memory <label>
<the passage>
Comment thread src/session_sketch.rs Outdated
Comment on lines +1395 to +1401
let head_len = limit * 7 / 10;
let tail_len = limit.saturating_sub(head_len);
let head: String = unit.text.chars().take(head_len).collect();
let mut tail: Vec<char> = unit.text.chars().rev().take(tail_len).collect();
tail.reverse();
let tail: String = tail.into_iter().collect();
(format!("{head}\n\n[… shortened by session-sketch …]\n\n{tail}"), true)
display_text split head and tail at the full limit and then added the
elision marker, so a shortened passage rendered past its share of the
character budget. Take the marker out of the same limit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dacorvo
dacorvo merged commit e7c8430 into main Aug 28, 2026
8 checks passed
@dacorvo
dacorvo deleted the sketch_verb branch August 28, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants