<!--
Sitemap:
- [Installation](/installation)
- [Upgrading](/upgrading): Version-specific steps for upgrading an existing Bento install.
- [Concepts](/concepts)
- [Build your first pipeline](/tutorials/pipeline-args)
- [Target a specific issue or PR from a URL](/tutorials/url-targeting)
- [Keep state across runs](/tutorials/pipeline-state)
- [Fire a pipeline on a schedule or on demand](/tutorials/schedule-and-fire)
- [Configuration](/configuration)
- [Knowledge Base](/knowledge-base/)
- [Method & delivery](/knowledge-base/modes)
- [Config](/knowledge-base/config)
- [MCP](/knowledge-base/mcp)
- [Pipeline configuration reference](/pipelines/config)
- [Filters](/pipelines/filters)
- [Triggers](/triggers/)
- [GitHub Trigger](/triggers/github)
- [Linear Trigger](/triggers/linear)
- [Webhook](/triggers/webhook)
- [Schedule Trigger](/triggers/schedule)
- [Manual Trigger](/triggers/manual)
- [Traces](/pipelines/traces)
- [Slack](/integrations/slack)
- [Public Access](/public-access)
- [Context Engineering](/context-engineering)
- [Best Practices](/best-practices)
- [Troubleshooting](/troubleshooting)
- [Architecture](/architecture/vision)
- [Workspaces](/workspaces)
- [Authentication](/authentication)
- [Identity](/identity)
- [Security](/security)
- [References](/references)
- [Changelog](/changelog): Bento release history.
- [CLI Reference](/cli/)
- [Setup](/cli/setup)
- [Lifecycle](/cli/lifecycle)
- [Sandbox Image](/cli/image)
- [Observability](/cli/observability)
- [Diagnostics](/cli/diagnostics)
- [Triggers](/cli/triggers)
- [Workbench](/cli/workbench)
- [Auth](/cli/auth)
- [Knowledge](/cli/knowledge)
- [Bento](/index)
- [Runtime Wrapper](/architecture/runtime-wrapper)
- [Skill Evolve](/architecture/skill-evolve)
-->

# Config

`knowledge.retrieval` in `daemon.yaml` configures the retrieval engine: the qmd searcher and the query rewriter. The [method & delivery](/knowledge-base/modes) knobs decide how results reach an agent; this block decides how results are produced — its settings apply to retrieving pipelines (`method: bm25`/`vector`), `bento ask`, and the `ask_knowledge` MCP tool alike.

The engine initializes whenever knowledge sources are discovered and `qmd` is on PATH. There is no enable switch — to keep retrieval out of pipeline runs, omit `knowledge:` blocks (and `defaults.knowledge`), or set `delivery: none`.

```yaml
knowledge:
  retrieval:
    topK: 20 # default 5
    rewrite:
      target: claude-fast
```

| Field | Default | Description |
|-------|---------|-------------|
| `topK` | `5` | Default results per source. Raise to `20` for small knowledge bases (fewer than ~20 docs); `ask_knowledge` always uses this value. Per-run `knowledge.topK` overrides it. |
| `minScore` | `0` | Drop results scoring below this. |
| `rewrite.target` | — | Named execution target. Omit to search with the raw prompt. |
| `rewrite.timeoutMs` | `15000` | Hard cap on the rewriter spawn; on timeout the raw prompt is searched as-is. |

## rewrite

When `rewrite.target` is set, the daemon spawns a one-shot CLI call that condenses the prompt into at most three queries of 3–6 words each, preserving proper nouns, file names, and error strings. Each query is searched; results merge.

The rewriter serves every daemon retrieval: `method: bm25` / `vector` pipelines, the daemon-backed `bento ask`, and `ask_knowledge`.

## Per-run settings

Injection behavior — mode, filter, instructions, `topK`, `maxTokens` (budget, default `8000`) — lives in the per-pipeline [`knowledge:` block](/pipelines/config#knowledge) and `defaults.knowledge`. Engine settings here apply underneath: `rewrite.*` and `minScore` always, `topK` unless the run overrides it.
