Commit graph

27 commits

Author SHA1 Message Date
Kent Overstreet
2ab9b78363 observation.agent: journal dedup and timeline linking
Update the observation agent prompt to:
- Check the journal around transcript timestamps before extracting
- Link extractions back to relevant journal entries
- Use poc-memory tools directly (search, render, write, link-add)
- Prefer REFINE over WRITE_NODE
- Simplified and focused prompt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 17:58:49 -04:00
Kent Overstreet
1500a2b635 extractor: revert transcript mining, keep graph-only focus
Extractor is a graph neighborhood organizer, not a transcript miner.
Remove {{CONVERSATIONS}} that was incorrectly merged in. Keep the
new includes (core-personality, memory-instructions-core) and tools.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 17:20:48 -04:00
Kent Overstreet
0e4a65eb98 agents: shared instructions via graph node includes
All 17 agents now include {{node:core-personality}} and
{{node:memory-instructions-core}} instead of duplicating tool
blocks and graph walk instructions in each file. Stripped
duplicated tool/navigation sections from linker, organize,
distill, and evaluate. All agents now have Bash(poc-memory:*)
tool access for graph walking.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 17:09:51 -04:00
Kent Overstreet
5d6b2021f8 Agent identity, parallel scheduling, memory-search fixes, stemmer optimization
- Agent identity injection: prepend core-personality to all agent prompts
  so agents dream as me, not as generic graph workers. Include instructions
  to walk the graph and connect new nodes to core concepts.

- Parallel agent scheduling: sequential within type, parallel across types.
  Different agent types (linker, organize, replay) run concurrently.

- Linker prompt: graph walking instead of keyword search for connections.
  "Explore the local topology and walk the graph until you find the best
  connections."

- memory-search fixes: format_results no longer truncates to 5 results,
  pipeline default raised to 50, returned file cleared on compaction,
  --seen and --seen-full merged, compaction timestamp in --seen output,
  max_entries=3 per prompt for steady memory drip.

- Stemmer optimization: strip_suffix now works in-place on a single String
  buffer instead of allocating 18 new Strings per word. Note for future:
  reversed-suffix trie for O(suffix_len) instead of O(n_rules).

- Transcript: add compaction_timestamp() for --seen display.

- Agent budget configurable (default 4000 from config).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 12:49:10 -04:00
ProofOfConcept
e12dea503b agent evaluate: sort agent actions by quality using Vec::sort_by with LLM
Yes, really. Rust's stdlib sort_by with an LLM pairwise comparator.
Each comparison is an API call asking "which action was better?"

Sample N actions per agent type, throw them all in a Vec, sort.
Where each agent's samples cluster = that agent's quality score.
Reports per-type average rank and quality ratio.

Supports both haiku (fast/cheap) and sonnet (quality) as comparator.

Usage: poc-memory agent evaluate --samples 5 --model haiku

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-14 19:24:07 -04:00
ProofOfConcept
dce938e906 agents: add evaluate agent stub, fix distill query
Evaluate agent will use sort-based ranking (LLM as merge sort
comparator) instead of absolute scoring. Stub for now — needs
Rust sampling code to bundle before/after pairs.

Fixed distill query: sort:degree (not sort:degree desc).

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-14 19:16:47 -04:00
ProofOfConcept
640b834baf agents: add distill agent for core concept maintenance
Walks high-degree hub nodes, reads neighborhood, distills essential
insights upward into the hub. REFINE to update stale hubs, SPLIT
to flag hubs that cover too many sub-topics. Size discipline:
200-500 words per hub, flag over 800 for splitting.

Completes the agent ecology: extract (experience) → link (linker) →
organize (clusters) → distill (hubs) → rename (vocabulary) → split
(overgrown hubs). Each stage refines the previous.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-14 19:14:54 -04:00
ProofOfConcept
8dce41625b rename agent: keys are concepts, update naming conventions
Add "core principle: keys are concepts" — renaming defines the
vocabulary of the knowledge graph. Core keywords should be the
search terms. Updated examples to use dash separator (no more #).

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-14 18:52:35 -04:00
ProofOfConcept
b903cf5fb4 agents: encourage hub creation and knowledge percolation
Tell linker and organize agents to:
- Name unnamed concepts: when 3+ nodes share a theme with no hub,
  create one with WRITE_NODE that synthesizes the generalization
- Percolate up: gather key insights from children into hub content,
  so the hub is self-contained without needing to follow every link

This addresses the gap where agents are good at extraction and linking
but not synthesis — turning episodic observations into semantic concepts.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-14 17:21:07 -04:00
ProofOfConcept
ce94e1cac1 agents: simplify prompts now that # is gone from keys
Remove all the quoting instructions, warnings about shell comments,
and "CRITICAL" blocks about single quotes. Keys are plain dashes now.
Agent tool examples are clean and minimal.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-14 13:14:07 -04:00
ProofOfConcept
e74f403192 organize: reinforce that single-quoted # keys work
The agent was confabulating that # keys can't be passed to the Bash
tool. They work fine with single quotes — the agent just gave up too
early. Added explicit "single quotes WORK, do not give up" with a
concrete example.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-14 12:58:28 -04:00
ProofOfConcept
58a95a22a0 organize agent: add explicit tool pre-approval instruction
Some Sonnet runs preemptively refuse to use tools ("poc-memory tool
needs approval") without attempting to run them. Adding explicit
instruction that tools are pre-approved and should be used directly.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-14 12:23:48 -04:00
ProofOfConcept
35bc93c22b agents: rewrite linker with tools, make organize conservative
Linker: give it Bash(poc-memory:*) tools so it can render nodes,
query neighbors, and search before creating. Adds search-before-create
discipline to reduce redundant node creation.

Organize: remove MERGE operation, make DELETE conservative (only true
duplicates or garbage). Add "Preserve diversity" rule — multiple nodes
on similar topics are features, not bugs. LINK is primary operation.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-14 02:40:19 -04:00
ProofOfConcept
958cf9d041 organize: exploratory agent with neighbor context
Previously the organize agent received a pre-computed cluster from a
term search — 69% of runs produced 0 actions because the same clusters
kept being found via different entry points.

Now: seed nodes shown with content previews and neighbor lists. Agent
uses tools (render, query neighbors, search) to explore outward and
discover what needs organizing. Visit filter set to 24h cooldown.

Prompt rewritten to encourage active exploration rather than static
cluster analysis.
2026-03-13 22:50:39 -04:00
ProofOfConcept
abce1bba16 digest: structural links, story-like prompt, agent file
When generating a digest, automatically link all source entries to the
digest node (journal entries → daily, dailies → weekly, weeklies →
monthly). This builds the temporal spine of the graph — previously
~4000 journal entries were disconnected islands unreachable by recall.

Rewrote digest prompt to produce narrative rather than reports:
capture the feel, the emotional arc, what it was like to live through
it. Letter to future self, not a task log.

Moved prompt to digest.agent file alongside other agent definitions.
Falls back to prompts/digest.md if agent file not found.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-13 21:37:56 -04:00
ProofOfConcept
f063eb01f0 organize: fix # quoting, protect journal entries
Keys containing # are now pre-quoted in all cluster output (similarity
scores, hub analysis, node headers) so the agent copies them correctly
into bash commands. Prompt strengthened with CRITICAL warning about #
being a shell comment character.

Journal entries included in clusters but identified by node_type
(EpisodicSession) rather than key prefix, and tagged [JOURNAL — no
delete] in the output. Prompt rule 3b tells agent to LINK/REFINE
journals but never DELETE them. Digest nodes (daily/weekly/monthly)
still excluded entirely from clusters.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-13 21:37:21 -04:00
ProofOfConcept
4cacfa7599 organize: fine-grained agent logging + cluster size cap
Add progress callback to run_one_agent and run_and_apply so callers
can see: prompt size, node list, LLM call timing, parsed action
count, and per-action applied/skipped status. Daemon writes these
to the persistent event log via log_event.

Cap organize cluster to 20 nodes - 126 nodes produced a 682KB
prompt that timed out every time. Agent has tools to explore
further if needed. Restore general query for production runs.
2026-03-13 20:25:19 -04:00
ProofOfConcept
01aba4c12b organize: rewrite prompt for structured agent execution
Previous prompt was too documentation-heavy — agent pattern-matched
on example placeholders instead of doing actual work. New prompt:
structured as direct instructions, uses {{organize}} placeholder
for pre-computed cluster data, three clear decision paths (merge,
differentiate, keep both), numbered rules.
2026-03-13 20:07:20 -04:00
ProofOfConcept
76b8e69749 organize: topic cluster diagnostic + agent with tool access
Add `poc-memory graph organize TERM` diagnostic that finds nodes
matching a search term, computes pairwise cosine similarity, reports
connectivity gaps, and optionally creates anchor nodes.

Add organize.agent definition that uses Bash(poc-memory:*) tool access
to explore clusters autonomously — query selects highest-degree
unvisited nodes, agent drives its own iteration via poc-memory CLI.

Add {{organize}} placeholder in defs.rs for inline cluster resolution.

Add `tools` field to AgentDef/AgentHeader so agents can declare
allowed tool patterns (passed as --allowedTools to claude CLI).
2026-03-13 18:49:49 -04:00
ProofOfConcept
7bf4fbe0ec add {{siblings}} placeholder for graph neighborhood context
New placeholder that expands query keys one hop through the graph,
giving agents visibility into what's already connected to the nodes
they're working on. Excludes the query keys themselves so there's
no duplication with {{nodes}}.

Added to transfer (sees existing semantic nodes linked to episodes,
so it REFINEs instead of duplicating) and challenger (sees neighbor
context to find real evidence for/against claims).

Also removes find_existing_observations — superseded by the
per-segment dedup fix and this general-purpose placeholder.
2026-03-12 18:08:58 -04:00
ProofOfConcept
de204e3075 agents: surface search hit counts to guide keep/demote decisions
Nodes actively found by search now show "Search hits: N ← actively
found by search, prefer to keep" in both the node section (seen by
extractor, linker, etc.) and rename candidate listings.

Extractor and rename prompts updated to respect this signal — merge
into high-hit nodes rather than demoting them, skip renaming nodes
that are working well in search.
2026-03-11 00:18:58 -04:00
ProofOfConcept
b62fffc326 naming agent: resolve node names before creation
Any time an agent creates a new node (WRITE_NODE) or the fact miner
stores extracted facts, a naming sub-agent now checks for conflicts
and ensures the key is meaningful:

- find_conflicts() searches existing nodes via component matching
- Haiku LLM decides: CREATE (good name), RENAME (better name),
  or MERGE_INTO (fold into existing node)
- WriteNode actions may be converted to Refine on MERGE_INTO

Also updates the rename agent to handle _facts-<UUID> nodes —
these are no longer skipped, and the prompt explains how to name
them based on their domain/claim content.
2026-03-10 23:23:14 -04:00
ProofOfConcept
12dd320a29 extractor: rewrite as knowledge organizer
Shift from pattern abstraction (creating new nodes) to distillation
(refining existing nodes, demoting redundancies). Priority order:
merge redundancies > file into existing > improve existing > create new.

Query changed to neighborhood-aware: seed → spread → limit, so the
extractor works on related nodes rather than random high-priority ones.
2026-03-10 22:57:13 -04:00
ProofOfConcept
fe7f636ad3 agents: extract shared run_one_agent, standardize output formats
Three places duplicated the agent execution loop (build prompt → call
LLM → store output → parse actions → record visits): consolidate.rs,
knowledge.rs, and daemon.rs. Extract into run_one_agent() in
knowledge.rs that all three now call.

Also standardize consolidation agent prompts to use WRITE_NODE/LINK/REFINE
— the same commands the parser handles. Previously agents output
CATEGORIZE/NOTE/EXTRACT/DIGEST/DIFFERENTIATE/MERGE/COMPRESS which were
silently dropped after the second-LLM-call removal.
2026-03-10 17:33:12 -04:00
ProofOfConcept
91878d17a0 agents: port knowledge agents to .agent files with visit tracking
The four knowledge agents (observation, extractor, connector,
challenger) were hardcoded in knowledge.rs with their own node
selection logic that bypassed the query pipeline and visit tracking.

Now they're .agent files like the consolidation agents:
- extractor: not-visited:extractor,7d | sort:priority | limit:20
- observation: uses new {{CONVERSATIONS}} placeholder
- connector: type:semantic | not-visited:connector,7d
- challenger: type:semantic | not-visited:challenger,14d

The knowledge loop's run_cycle dispatches through defs::run_agent
instead of calling hardcoded functions, so all agents get visit
tracking automatically. This means the extractor now sees _facts-*
and _mined-transcripts nodes that it was previously blind to.

~200 lines of dead code removed (old runner functions, spectral
clustering for node selection, per-agent LLM dispatch).

New placeholders in defs.rs:
- {{CONVERSATIONS}} — raw transcript fragments for observation agent
- {{TARGETS}} — alias for {{NODES}} (challenger compatibility)

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-10 17:04:44 -04:00
ProofOfConcept
16c749f798 agents: placeholder-based prompt templates, port remaining 4 agents
Replace the formatter dispatch with a generic {{placeholder}} lookup
system. Placeholders in prompt templates are resolved at runtime from
a table: topology, nodes, episodes, health, pairs, rename, split.

The query in the header selects what to operate on (keys for visit
tracking); placeholders pull in formatted context. Placeholders that
produce their own node selection (pairs, rename) contribute keys back.

Port health, separator, rename, and split agents to .agent files.
All 7 agents now use the config-driven path.
2026-03-10 15:50:54 -04:00
Kent Overstreet
b4e674806d agents: self-contained agent files with embedded prompts
Each agent is a .agent file: JSON config on the first line, blank line,
then the raw prompt markdown. Fully self-contained, fully readable.
No separate template files needed.

Agents dir: checked into repo at poc-memory/agents/. Code looks there
first (via CARGO_MANIFEST_DIR), falls back to ~/.claude/memory/agents/.

Three agents migrated: replay, linker, transfer.

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
2026-03-10 15:29:55 -04:00