> ## Documentation Index
> Fetch the complete documentation index at: https://docs.asteragents.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Write to Knowledge Base

> Save files to a knowledge base from agent conversations

## What it does

The Write to Knowledge Base tool allows agents to save files directly to your organization's knowledge bases during conversations. Agents can save existing conversation attachments (user-uploaded or tool-generated files) or create new text files from content they generate.

<Info>
  For complete information about Knowledge Bases, including setup, file upload, and management, see [Knowledge Bases](/features/knowledge-bases).
</Info>

## Key features

* **Save Attachments**: Save user-uploaded or tool-generated files from the conversation to a KB
* **Create New Files**: Write inline content (summaries, reports, notes) as new KB files
* **Automatic Processing**: Saved files are automatically chunked, embedded, and indexed for search
* **Writable KB Allowlist**: Restrict which knowledge bases each agent can write to
* **Size Limits**: 10 MB maximum for inline content writes

## Parameters

| Parameter           | Type    | Required | Description                                                                                                                                             |
| ------------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `knowledge_base_id` | integer | Yes      | The ID of the knowledge base to save the file to                                                                                                        |
| `file_name`         | string  | Yes      | The name of the file to save. Must match an attachment name, or pair with `content` to create a new file                                                |
| `content`           | string  | No       | Text content to save as a new file. Use this to write summaries, reports, or notes. If omitted, the tool looks for a matching attachment by `file_name` |

## Configuration

### Writable Knowledge Bases

When enabling this tool on an agent, you must select which knowledge bases the agent is allowed to write to. This prevents agents from writing to unintended KBs.

Configure this in **Control Hub > Edit Agent > Tools > Write to Knowledge Base**.

## Common use cases

### Save a conversation summary

```
file_name: "meeting-notes-2026-03-11.md"
content: "## Meeting Notes\n\n- Discussed Q1 results..."
knowledge_base_id: 123
```

Agent creates a new markdown file with generated content.

### Save an uploaded document

```
file_name: "quarterly-report.pdf"
knowledge_base_id: 456
```

A user-uploaded PDF from the conversation is copied to the knowledge base.

### Save a tool-generated file

```
file_name: "analysis-output.xlsx"
knowledge_base_id: 789
```

A file generated by another tool (e.g., Run Code) is saved to the KB.

## Best practices

* Use descriptive file names that help with future search and organization
* Choose the right knowledge base — agents can only write to KBs in their allowlist
* For inline content, use markdown formatting for best search results
* Combine with [Search Knowledge Base](/tools/search_knowledge_base) to build agents that both read and write knowledge

## Troubleshooting

**"Knowledge base not in writable list"**

* The agent's tool configuration doesn't include this KB. Update the writable KB list in the agent's tool settings.

**"Content exceeds maximum size"**

* Inline content is limited to 10 MB. For larger files, upload them directly to the KB.

**"No matching attachment found"**

* The `file_name` must exactly match an attachment in the conversation (case-insensitive). Check the exact filename of the uploaded or generated file.

**"Knowledge base not found"**

* Verify the knowledge base ID exists and belongs to your organization.

## Related tools

* [Search Knowledge Base](/tools/search_knowledge_base) - Search KB content that this tool writes to
* [Run Code](/tools/execute_python) - Generate files that can then be saved to a KB
* [Call API](/tools/call_api) - Fetch external data to save into knowledge bases
