Skip to content

Knowledge settings and tools ​

Configure retrieval in Settings → Knowledge or the knowledge: block of langgraph-config.yaml. Use Tune knowledge recall for a comparison procedure and Manage memory for curation.

These settings control automatic delivery when middleware.knowledge is enabled. The tool signatures are maintained in Starter tools.

Memories and document collections ​

Knowledge is reference material: books, PDFs, web pages and transcripts stored as chunks in named collections. Use knowledge_ingest(source, collection="manuals") to add documents and knowledge_search(query="deployment", collection="manuals") to retrieve passages from that collection. Omit the search filter to search all collections. Results cite their collection and source. The backend's domain parameter still carries the collection internally; the agent tools expose collection.

Memory is durable preferences, standing rules, facts and decisions in the separate memories table, with kind, subject, delivery, review_state and provenance. It has no domain. memory_search searches only memory. Conversation archives, summaries and reports are history, reached through session_search and recall_session. See Memory storage and delivery for the field contract.

Store selection ​

Keyword-only FTS5 is the default (embeddings: false). embeddings: true enables keyword/vector search with reciprocal rank fusion (RRF), provided the gateway serves embed_model. Repeated embedding failures open a circuit breaker and leave keyword search available. Plugins can supply knowledge.backend or knowledge.embedder; see ADR 0031.

Retrieval settings ​

Key under knowledgeDefaultEffect
embeddingsfalseEnable hybrid search
embed_modelqwen3-embeddingEmbedding model served by the gateway
top_k5Maximum document hits automatically injected per turn; 0 stops injection. Negative values become 0 with a warning
vector_k20Vector candidates before rank fusion
rrf_k60Rank-fusion smoothing constant; this is not a semantic-versus-keyword weight
min_score0.0Retrieval score floor; 0 keeps all scored matches
recall_preview_chars1000Maximum preview length per injected hit
embed_breaker_threshold2Consecutive failures before the embedding circuit opens
embed_breaker_cooldown_s300Seconds before retrying the embedding route
factstrueExtract facts when conversations are harvested
db_path/sandbox/knowledge/agent.dbLegacy default resolves to <instance_root>/knowledge/agent.db; an explicit non-/sandbox path is used as supplied. KNOWLEDGE_DB_PATH overrides it

Chunk sizes and contextual enrichment affect ingestion, not existing chunks; see Ingestion. Tune rank fusion with retrieval evaluations rather than assuming a lower rrf_k favors one search engine.

Context and session digest ​

These keys live outside the knowledge block:

yaml
context:
  budget_pct: 8
  prior_sessions: newest  # newest | relevant | off
memory:
  max_sessions: 10
  max_tokens: 2000

budget_pct limits injected context to a percentage of the model window, with a 16,000-character floor. 0 makes it unbounded. Without a known model window the percentage is inert and delivery is unbounded, with a log warning. Over budget, document hits give way first, then session-digest entries, then skill descriptions. Working state and always-on memory are retained.

prior_sessions: newest selects recent summaries. relevant uses session-search FTS and falls back to newest for an empty query, unavailable FTS, or no matches; off disables the automatic digest while keeping on-demand session tools. The active chat's summary is always excluded. Quoted and bare YAML off both work.

max_sessions and max_tokens are digest ceilings, not switches. Non-positive values restore defaults with a warning. Token cost is estimated as characters / 4. Summaries use the instance store, or MEMORY_PATH; there is no memory.path. GET /api/prompts/preview reports the delivery budget, usage, and omitted parts.

Agent memory tools ​

ToolContract
memory_save(content, kind="fact", subject?, heading?, delivery="retrieved", expires_in_days?)Save durable text; agent memories start pending
knowledge_ingest(source, collection="general", title?)Fetch and ingest a URL or file into a document collection
knowledge_search(query, k=5, collection?)Search document passages, cited by collection and source
memory_search(query, k=5, kind?, delivery?, include_superseded=False)Search only memory, optionally including superseded rows
session_search(query, limit=5, surface?)Search prior sessions and history
recall_session(session_id, entry?)Expand a prior session
memory_list(kind?, delivery?, review_state?, limit=10)List recent eligible memories, ending with stored counts per kind and a total
memory_forget(memory_id, reason?)Permanently delete one memory

The console uses GET /api/knowledge/search; GET /api/runtime/status reports store status. Keyword recall matches whole words. The search endpoint's opt-in prefix=1 flag expands the last token to a prefix, used by the palette. It does not change ordinary recall, automatic injection, or Knowledge Store search.

Automatic delivery controls ​

Namespace scope ​

yaml
knowledge:
  inject_namespaces: []  # no filter: all namespaces eligible
  # inject_namespaces: ["projects/alpha", ""]

A nonempty list restricts automatic document injection; "" selects unnamespaced chunks. Session attachments use attach:<session_id>. Both keyword and vector rankings are filtered. Tool-driven knowledge_search remains unscoped.

Trust floor ​

knowledge.inject_min_trust defaults to 1: external/unknown sources. Set it to 2 to admit agent-derived and operator-authored content, or 3 for operator content only. Automatic hits sort by trust tier after retrieval, preserving relevance within each tier. The floor affects automatic injection, not knowledge_search; citations expose the source's trust tier.

Always-on writes ​

knowledge.hot_write_confirm: true refuses memory_save(delivery="always"), instructing the agent to ask the operator. The ingestion tool also retains a compatibility guard for knowledge_ingest(collection="hot"), before fetching. Nothing is queued for approval or partly stored. The default is false. Console writes are unaffected; this is not a universal plugin-write gate.

Always-on memory uses delivery="always" in memories, independently of kind. Knowledge collections group documents; they are not memory kinds.

For incognito request fields and retention boundaries, see Memory delivery.

Review and removal ​

Memory operator writes start confirmed; agent and extracted memories start pending. Pending private memories remain eligible for delivery. Rejected, expired and invalidated rows stay stored but do not enter search or delivery. Superseded memories are excluded by default; memory_search(include_superseded=True) exposes replaced rows for audit. Use the Memory inspector for operator review and memory_forget for a permanent deletion.

Knowledge chunk review remains a separate backend lifecycle. Its private-tier verdict route is POST /api/memory/chunks/{id}/review, accepting {"state": "confirmed" | "rejected" | "pending"}. Explicit "tier": "commons" is refused; commons removal uses curated sharing controls. Chunk revisions retain audit history through invalidation; store APIs with include_invalidated=True expose it.

Single-entry operator deletes are permanent. Bulk source deletion uses invalidate_by_source; the Undo action calls restore_by_source during the grace window. Later bulk deletes opportunistically purge expired bulk-delete rows. That sweep does not remove automatic supersession history.

Chat deletion's forget=true option removes archives in chat-archive:<session> and harvested/extracted rows whose source identifies the chat or goal-iteration subthreads. It does not reach explicit notes, hot memory, background reports, or legacy rows without that provenance. The app defaults to harvesting ordinary chats, excludes incognito chats, and makes forget and harvest mutually exclusive. The API still accepts both flags: forget runs first, so the new harvest is retained. See the user procedure.

Plugin knowledge lifecycle ​

  • sdk.knowledge_purge(domain, *, before=None) -> int hard-deletes private chunks in a domain, optionally before an ISO timestamp, across row, keyword, and vector indexes. Empty domains and invalid dates refuse with count 0. A layered store does not purge its commons. Older custom backends without this operation return a no-op count of 0.
  • sdk.knowledge_add(..., epoch=...) tags an era; sdk.knowledge_search(..., epoch=...) selects that exact era in both rankings and layered tiers. Untagged and other eras are excluded. Omitting the filter searches every era. Store APIs expose equivalent purge_domain and epoch arguments.

Fleet commons ​

Knowledge defaults to scope: scoped: private to the agent. To read shared knowledge while keeping new writes private:

yaml
knowledge:
  scope: layered
commons:
  path: ~/.protoagent/commons

scope: shared writes directly to the commons. scope: layered searches both tiers, deduplicates matches, and writes private. Share in Knowledge → Store promotes a private chunk (POST /api/knowledge/{id}/promote); Unshare removes its commons copy (POST /api/knowledge/{id}/forget). Private copies remain.

Layered search keeps distinct records within each tier, even when their text is identical. Across tiers it pairs matching text and provenance one-to-one and adds their reciprocal-rank scores; the editable private record represents each pair. Provenance includes namespace, domain, source and source type, heading, finding type, epoch, memory kind, subject, expiry, and delivery policy. Review state may differ because promotion confirms the commons copy. Different provenance stays visible as separate results, subject to the requested result limit and filters.

Promotion does not persist a lineage identifier, so this matching rule is an equivalence heuristic, not proof of shared origin. It changes search results only: listing, stored chunks, and the existing content-based promotion idempotency are unchanged. Explicit promotion lineage and changes to ingestion/promotion identity remain separate work.

All agents pointing at the same commons.path can read it, regardless of instance ID. Give isolated fleets different commons paths. Agents sharing a commons should use the same embed_model: a mismatched agent searches that commons with keywords only and logs a warning.

Part of the protoLabs autonomous development studio.