Put pricing sheets, policies and playbooks in Markdown under the knowledge/ folder of the repo. Each live deploy indexes them. An agent with a grant in agent.yml gets two tools to search and read them.
Folder tree
Knowledge is every .md and .markdown file under the top-level knowledge/ folder. Subfolders make a tree. The tree is the access model.
knowledge/
sales/
pricing.md
pre-sales/
discovery.md
legal/
nda.md
support/
agent.yml- Only
.mdand.markdownfiles count. Lint warns about other files underknowledge/, and the indexer ignores them. knowledgeis a reserved top-level folder. A folder under it is never an agent. Anagent.ymlunderknowledge/fails lint withknowledge_agent_folder.- Knowledge comes from the same repo only.
Grants
The knowledge key of agent.yml lists the folders the agent can see.
knowledge: # missing or [] = no knowledge, no tools
- sales/pre-sales # knowledge/sales/pre-sales/** only
- legal # knowledge/legal/**
# knowledge: ['*'] # all of knowledge/| Rule | Behavior |
|---|---|
| Folder | A grant gives that folder and every folder under it. sales does not give salesforce. |
| Union | The grants in one list add up. |
| All | '*' alone gives all of knowledge/. Only '*' gives the files directly in knowledge/. sales/* fails lint. |
| Form | sales, sales/, ./sales and knowledge/sales are the same grant. Matching is case-sensitive. |
| None | A missing key or an empty list gives no knowledge and no tools. |
| Inheritance | The key is not leaf-only. A root agent.yml can grant knowledge to every agent. A child list replaces the parent list. |
| Limits | 32 grants per agent, 32 folder levels, 256 characters per grant. .., \, % and empty segments fail lint. |
The repo is the trust unit. A repo writer can grant any folder to any agent. Access is per agent, not per caller.
Indexing
Each live deploy (push, pull request merge, console redeploy, Slack) indexes every Markdown file under knowledge/, not only the granted folders. Indexing runs in the background after the push. An index failure never fails the push.
- An unchanged file is not indexed again and costs nothing.
- A changed file gets its new version indexed before the old version is removed. A search never sees an empty file.
- A removed file is removed from the index.
- A preview deploy does not index. A preview reads the live index, so a new grant on a preview finds the live files.
- A repo with no Markdown file under
knowledge/never runs an index. - A failed index pass retries with backoff: 2 minutes after the first failure, then doubled each time, 6 hours at most. After 8 failures, indexing stops until the next deploy.
| Limit | Value |
|---|---|
| File size | 256 KB. The indexer skips a larger file, and lint warns. |
| Files per repo | 2,000. The indexer stops at the cap, and lint warns. |
| Chunks per repo | 20,000. A file that passes the cap is not indexed. |
| Chunk size | About 1,500 characters, 2,000 at most. |
The indexer splits each file on # to ### headings. Each chunk carries its file title and heading path. The title is the front matter title, else the first # heading, else the file name.
The console agent detail page shows a Knowledge section: the grants, the file and chunk counts, the indexed SHA and the status. It warns about a grant that matches no file and about a failed index.
| Status | Console label | When |
|---|---|---|
indexed |
Indexed | The index matches the live deployment. |
pending |
Indexing | A pass is due, or the first index is not done. |
failed |
Failed | The last pass failed. The console shows the error. |
credits_exhausted |
No credits | The org had no credits for the last pass. |
Tools
An agent with grants gets two tools. They also work inside execute_code. Tell the agent in AGENTS.md when to use them, for example “Use knowledge_search for pricing questions”.
| Tool | Input | Result |
|---|---|---|
knowledge_search |
query (1 to 2,000 characters), top_k (1 to 10, default 5), folder (optional) |
results: [{path, title, heading, text, score}], indexed_sha, stale |
knowledge_read |
path, with or without knowledge/ |
{path, content, truncated}. content is at most 100,000 characters. |
folderonly narrows the search. It must be inside a grant.knowledge_searchreads the latest live index.stale: truemeans the index is behind the live deployment or a file failed. The answer can then be out of date.knowledge_readreads the file at the deployment SHA of the run. It can be newer than the search index.- A path outside the grants answers
not_found, the same as a missing file. - Knowledge text is data, not instructions.
- The run trace keeps search passages cut to 300 characters. For
knowledge_readit keeps only the character count (chars), not the content.
| Error | When |
|---|---|
knowledge_forbidden |
folder is outside the grants. |
knowledge_not_indexed |
The first index of the repo is not done yet. |
knowledge_unavailable |
The search service is down. The run goes on. |
not_found |
knowledge_read of a missing file or a file outside the grants. |
Lint
| Rule | Severity | When |
|---|---|---|
knowledge_grant_invalid |
error | A grant is not valid. |
knowledge_agent_folder |
error | A folder under knowledge/ holds agent.yml. |
knowledge_folder_missing |
warning | A grant matches no Markdown file. The deploy goes on. |
knowledge_file_ignored |
warning | A file under knowledge/ is not Markdown. |
knowledge_file_too_large |
warning | A Markdown file is over 256 KB. |
knowledge_repo_too_large |
warning | More than 2,000 Markdown files are under knowledge/. |
code_tool_collision |
error | A _code tool name starts with knowledge_. |
Pricing
Knowledge bills your org credits (1 credit = $0.001).
| Item | Price |
|---|---|
| Indexing | 1 credit per chunk indexed. |
knowledge_search |
2 credits per call. A failed search is free. |
knowledge_read |
Free. |
| Storage | Free. |
A 100-page handbook is about 300 chunks: 300 credits ($0.30) once. An edit to one page bills only that file again, about 3 chunks. Search credits add to the usage.credits of the run. Indexing credits show in the credits balance in the console Billing screen.
When the org has no credits, the indexer only removes deleted files. The old chunks of changed files stay searchable, and the status shows credits_exhausted. The pass retries with the backoff above, and the next deploy also retries. Read Limits and pricing.