Agent context via nanobot, brain search with ranking, stack memory ask - #101
Merged
Merged
Conversation
Replacing prior tool-turn answers with "[earlier answer from ...]" taught the model that format. In a long room it sent the placeholder as its reply and repeated the same grep. - lean_state: only prior tool results become pointers - test: no assistant message holds a placeholder after 10 tool turns - log entry in agent-improvement-log.md
…rep routing Our context shims worked against nanobot's own mechanisms. lean_state duplicated microcompact, broke the prefix cache, and its "re-run" placeholders made the model repeat tool calls. grep_tool ran regex patterns as semantic queries, so the model retried the same grep. - lean_state removed; state_log keeps the debug log, opt-in via AGENT_STATE_LOG=1 - grep_tool removed; vault grep is literal again - compact_tools: vault read tools join nanobot's microcompact set - config.json: context_window_tokens 32768, so token consolidation and history snip act (budget 23.5k) and prefill stays short - agent-lab: replay subcommand removed with lean_messages - ADR-012 update, improvement log entry
Claude Code reads CLAUDE.md, not AGENTS.md, so the repo rules were never in its context. - CLAUDE.md imports AGENTS.md, docs/agent/ops.md, docs/agent/dev.md - .gitignore: keep the root CLAUDE.md, still ignore nested ones
Search read the source vault and sorted by date. Generated pages (the diary) exist only in the brain, and the newest pages naming a person filled the limit before the page with the rare word. - search reads memory/brain (memory/vault before the first curator run); no Forgejo pull on the brain, the curator writes it - rank: each top-level alternative scores its IDF, then date; one keyword keeps date order - excerpt: the line with the rarest matching keyword - "matches:" line for multi-keyword queries - title/tag values and diacritic folding from 2ca1116 - ADR-011 update: search reads the brain
- person becomes a ranking keyword, not a --person filter; a parent's diary entry about a child does not list the child - stderr block per search: query, regex, count, path and matched keywords per hit; no page text - description matches what the output contains
Same shape as stack web ask: question in, short answer with [N] citations and sources out. One model call; the search uses the question's own words, because the --nl rewrite adds ontology words that outrank the answering page. - host: search the brain, send top hits as JSON to the bot-runner - bot-runner: `answer` command, 600-token cap - --json, --sources N; timing line on stderr - sources print when the model is unreachable (exit 1)
nanobot reads context_window_tokens from the active preset (default 200000); the value under agents.defaults was ignored, so token consolidation still budgeted against 200000. - config.json: context_window_tokens 32768 on model_presets.primary - test: the window sits on the active preset, not under defaults
A diary month is one page and the day is its heading, so the matching line alone did not say when; the agent read the page again to find out. - excerpt: "<nearest heading> › <line>"; the heading alone when it matched
Tool output is prompt the model reads before its next step; on the local model each 1k tokens costs 5-7 s of prefill. The model asked for 20 hits and 30 changes, most of them noise.
Design note, nothing built. Every brain page gets the document pattern (frontmatter, summary and facts, ontology tags, OKF fields). The diary gets one card per entry in the vault, posted as a thread reply on the entry's last main-timeline message and corrected by replying in that thread, like documents; the warm diary pages are compiled from the cards. - entry unit open: message group, day or occasion - built as a second compiler and compared against the current one
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Faster, more reliable vault answers from the local agent, and a
one-call
stack memory ask.Agent
lean_state(its answerplaceholders were copied into replies) and the grep-to-search shim
(grep is literal again).
consolidation runs.
memory_searchcappedat 8 hits,
memory_historyat 10.memory_searchtreats the person as a ranking keyword, not a filter,and logs its ranked result paths.
Search
(diary) are found. ADR-011 updated.
stack memory ask[N]citations and sources out, likestack web ask. One model call; searches with the question's ownwords.
Other
CLAUDE.mdloadsAGENTS.mdand the role guides.docs/design/brain/content-pattern.md: one contentpattern for the brain, diary cards in the vault.
Measured on a diary question: the answer page is now found by the first
search (before: 72-89 s, found by grep).
Unit suite green. Agent changes tested on the live agent; the result
caps and context window are live since the last rebuild and not yet
observed in use.
stack memory askis covered by unit tests only.