Documentation Index
Fetch the complete documentation index at: https://mintlify.com/HKUDS/nanobot/llms.txt
Use this file to discover all available pages before exploring further.
ContextBuilder
TheContextBuilder class is responsible for assembling the complete context for LLM calls, including:
- System prompt with identity, memory, and skills
- Conversation history
- Runtime metadata (time, channel info)
- Media attachments (images)
Constructor
The workspace directory containing memory, skills, and bootstrap files
Methods
build_system_prompt
Optional list of specific skills to include (currently unused, always skills are loaded automatically)
The complete system prompt text
- Identity: Core nanobot identity, runtime info, workspace paths
- Bootstrap files: AGENTS.md, SOUL.md, USER.md, TOOLS.md, IDENTITY.md
- Memory: Long-term memory from MEMORY.md
- Active skills: Skills marked with
always=true - Skills summary: List of all available skills for progressive loading
build_messages
Previous conversation messages from session history
The current user message to process
Optional list of skills to include in system prompt
List of media file paths (images) to include with the message
Channel name for runtime context
Chat ID for runtime context
Complete message list ready for LLM provider
add_assistant_message
The current message list
The assistant’s response text (can be None if only tool calls)
List of tool calls made by the assistant
Reasoning content for models that support it (e.g., o1)
Extended thinking blocks for advanced reasoning models
Updated message list with the new assistant message
add_tool_result
The current message list
The ID of the tool call this result corresponds to
The name of the tool that was executed
The tool execution result (success or error message)
Updated message list with the tool result
Bootstrap Files
The context builder looks for these files in the workspace root:- AGENTS.md: Instructions for multi-agent coordination
- SOUL.md: Core personality and behavior guidelines
- USER.md: User preferences and context
- TOOLS.md: Tool usage guidelines and examples
- IDENTITY.md: Custom identity overrides
Runtime Context
Every user message includes runtime metadata:Memory Integration
The context builder integrates withMemoryStore to include:
- Long-term memory: Key facts from MEMORY.md
- History log: Searchable conversation log in HISTORY.md
Skills Integration
The context builder integrates withSkillsLoader to:
- Load skills marked with
always=trueinto every prompt - Provide a summary of all available skills
- Let the agent progressively load skills using
read_filetool
Image Support
When media files are provided:- Images are base64-encoded
- MIME type is detected
- Content is structured for multimodal models:
Architecture Notes
- The context builder is stateless - it doesn’t store conversation state
- All state management is delegated to
SessionManager - System prompt is rebuilt on every message for consistency
- Large tool results (>500 chars) are truncated when saving to session history