Knowledge Base
Seed sources, shape the schema, read maintained pages.
The wiki is your workspace's knowledge base. This guide walks through the lifecycle: getting raw material into the wiki, telling Levain how the pages should be organised, and reading those pages from your agents.
Open the Knowledge Base
In the dashboard, Knowledge Base is in the left sidebar. It opens on the pages tree — the maintained output. New workspaces start empty, with a friendly nudge pointing at the Sources tab.
Add sources
The Sources tab is where raw material goes in. Drop files anywhere on the page or use the Upload button. Markdown, plain text, PDFs, and images are all accepted, up to 25 MB per file.
Sources land in a Pending section first. When you're ready, click Process — the maintainer reads the new material and writes the corresponding pages. Processed sources move to the Processed section, and the new pages appear in the tree on the Pages view.
Sources are kept around so you can audit what the wiki was built from. Deleting a source removes the raw file; pages it produced stay until the next maintainer pass reconciles the change.
Add your website
The Sources tab also has a dedicated slot for your website's URL — separate from file uploads. Save it for the first time and Levain crawls it immediately, seeding the wiki without an extra step. From then on Levain re-crawls the saved URL weekly, so new pages on your site find their way into the wiki on their own. Click Re-crawl whenever you want a refresh sooner — after editing the URL, say, or right after publishing something new.
Shape the schema
The schema is the table of contents the wiki commits to — a list of page paths with a short description of what each should cover. Edit it from the dashboard the same way you edit any markdown document, and the maintainer reorganises pages on its next run: pages removed from the schema are dropped, new entries are written from sources already in the wiki.
Read pages from an agent
Every agent in the workspace can read the wiki at runtime. The pages tree in the dashboard is what your agents see too — pick a page in the tree to view its current content.
Pages always reflect the last committed maintainer run, even while a refresh is in flight, so agents never read half-written content.
Agent-engine nodes get the wiki as the levain-wiki MCP server. A node
that needs one known page can skip the agent loop and read it directly
from levain_sdk.wiki, then hand the page to call_chat:
from levain_sdk.models import call_chat
from levain_sdk.wiki import read_page
async def run(state: GraphState, config: RunnableConfig) -> GraphState:
page = await read_page("VOICE.md")
if page.get("code") == "unreachable":
raise RuntimeError(page["error"])
voice = page.get("body", "Write plainly, in the second person.")
text = await call_chat(
system=f"Write in this voice:\n\n{voice}",
messages=[{"role": "user", "content": state["draft"]}],
model="claude-sonnet-5",
)
return {"draft": text}read_page(path) returns {"path", "body"}. search(query, limit=20)
returns {"hits": [{"path", "title", "snippet", "score"}, ...]} and
list_pages() returns {"pages": [{"path"}, ...], "count"}; both add
truncated: true and a warning when the wiki has more than 1000
files and the result is partial. All three take their configuration
from the sandbox environment, so there is nothing to initialise.
call_chat needs the models extra (levain-sdk[models]).
Failures come back as a dict, never an exception. error is a sentence
an agent can show; code is the stable key your code branches on.
search and list_pages keep an empty hits / pages alongside it.
code | Meaning | From |
|---|---|---|
no_wiki | The workspace has no wiki yet | all three |
missing_credentials | Platform misconfiguration; report it | all three |
unreachable | Gitea did not answer; retry or fail the run | all three |
invalid_path | Not a browsable .md page path | read_page |
not_found | No page at that path | read_page |
too_large | Page is over the 512 KB cap | read_page |
Search pages
Agents search the wiki with the search_wiki tool. mode="lexical" (the
default) scores keyword matches; mode="semantic" finds pages about the
same thing as the query, which can be a whole draft. filters narrows the
hits by frontmatter, for example
{"platform": "linkedin", "date": {"gte": "2026-01-01"}}; bounds compare
as numbers when both sides are numeric and as strings otherwise, and a
date-only bound like {"lte": "2026-08-01"} excludes timestamps later that
day. Each hit carries the page's frontmatter, so an agent can re-rank on
likes or dates without reading every page.
similar_pages takes a page path and returns its nearest neighbours in the
semantic index, with the same filters: the closest posts to this one on
the target platform, say.
From the API:
GET /api/v1/wikis/{id}/search?q=...&mode=semantic&filter=platform=linkedinfor short queries (filterrepeats, onekey=value,key>=valueorkey<=valueeach).POST /api/v1/wikis/{id}/searchwith{"q": "...", "mode": "semantic", "filters": ["platform=linkedin"]}when the query is a whole piece, up to 16000 characters.GET /api/v1/wikis/{id}/search/similar?path=sources/my-post.md&filter=platform=linkedinfor neighbours.
Pages you save through the API join the semantic index as they are
written, and deleted pages leave it, so they are searchable right away.
The maintainer rebuilds the whole index on every run. Before its first run
there is no index yet, and semantic searches return keyword results with a
warning saying so.
Edit pages directly
You're not limited to what the maintainer produces. Click any page in the Pages tree to open it, then click Edit to modify the content. Save when you're done.
Pages you edit by hand are stamped as user-owned. On its next run the
maintainer treats them as append-only: it can add wikilinks or new
sections to incorporate fresh source material, but it won't touch
content you wrote. To hand a page back to the maintainer, delete the
user_edited_at line from the frontmatter.
To create a page from scratch, use New page in the Pages tree and
pick a path under entities/, concepts/, or sources/ (or at the
root). You can also script page creation with
PUT /api/v1/wikis/{id}/pages/{path}.
Refresh on demand
The maintainer runs automatically whenever new sources land. To force a fresh pass — after a schema change, or just to re-distill what's already there — click Process on the Sources tab. The refresh shows up in your workspace history like any other run.
From the API
Everything above has an API equivalent if you'd rather script it: upload sources, edit the schema, list pages, and trigger a refresh. See the Wikis API reference for the full surface.
Next
- The Wikis primitive covers what the maintainer is and how it fits into the platform.
- The Recipes guide shows how to wire wiki reads into your agent's logic.