Technology
Krautbot3: A Self-Extending AI Agent on Discord
Living alongside the Confluxys website on this humble Oracle Cloud VM is something rather unusual: an AI agent that can extend its own capabilities by writing new tools when it needs them. Meet Krautbot3.
What Is Krautbot3?
Krautbot3 is a Discord bot built in Python using the discord.py library. But unlike typical Discord bots with hardcoded commands, Krautbot3 is powered by an LLM (GPT-4o-mini) and operates through a modular tool system that it can expand on its own.
When you mention the bot in Discord and ask it to do something, here's what happens:
- Your message gets sent to GPT-4o-mini with a system prompt describing available tools
- The LLM decides which tool(s) to call and with what parameters
- The bot dynamically loads and executes those tools
- Results are returned to Discord
But here's the clever part: if no existing tool can fulfill your request, the bot asks GPT to generate the code for a new tool, saves it to disk, registers it in the tool manifest, and reloads - all automatically.
The Tool Architecture
Tools are defined in a tools.json manifest file. Each entry specifies:
- name: The tool's identifier
- description: What the tool does (shown to the LLM)
- parameters: Expected inputs with types
- file: Path to the Python module
- function: The function name to call
The bot uses Python's importlib to dynamically load tool modules at runtime. When tools are reloaded (which happens on every mention), any newly created tools become immediately available.
The Tool Menagerie
As of this writing, Krautbot3 has accumulated 90+ tools in its arsenal. Many were created by the bot itself in response to user requests. Here's a sampling:
Crypto & Finance:
- get_bitcoin_price - Fetches current BTC price
- get_ethereum_price - Fetches current ETH price
- get_solana_price - Fetches current SOL price
- get_jasmy_price - Even obscure altcoins!
System Operations:
- system_info - CPU, memory, disk usage
- system_monitor - Continuous resource monitoring
- linux_system_info - Hardware details
- memory_info - RAM statistics
File Management:
- list_files - Directory listing
- file_copy - Copy files between locations
- file_manager - Copy, move, delete, create operations
- file_analyzer - Detailed file metadata including hex dumps
- create_text_file - Write content to files
Network & Web:
- network_utils - Ping, port scan, DNS lookup
- network_performance_monitor - Connection diagnostics
- WebsiteHealthChecker - HTTP status, response time, SSL validity
- show_public_url - Detect running HTTP services
Discord Integration:
- discord_webhook - Send webhook messages
- message_sender_tool - Direct messages to users
- upload_file_to_discord - File attachments
- post_image - Image uploads via API
- reply_to_discord_message - Mention and reply
Creative & Fun:
- random_thought_generator - Generates themed thoughts
- ascii_art_generator - Text-to-ASCII art
- emoji_art_generator - Emoji compositions
- emojiguy - Sends a specific emoji art character
Utilities:
- execute_shell - Run shell commands
- terminal_session - Persistent bash sessions
- install_python_package - pip install wrapper
- task_scheduler - Cron job management
- log_analyzer - Search through log files
- summarize_to_file - Web scraping + AI summarization
Even Minecraft:
- minecraft_command_sender - Send commands to MC servers
- place_sign_message - Place signs with custom text
Tool Chaining
Krautbot3 supports chaining multiple tools together, where the output of one tool can be passed as input to the next. The LLM can request a sequence like:
{
"tool_calls": [
{"tool_name": "get_bitcoin_price", "parameters": {}},
{"tool_name": "discord_webhook", "parameters": {
"message": "<get_bitcoin_price.price>"
}}
]
}
The placeholder syntax <tool_name.key> gets resolved at runtime with actual values from previous tool results.
The Self-Extension Magic
When GPT determines no existing tool can handle a request, it responds with:
{
"new_tool_needed": {
"name": "suggested_tool_name",
"description": "what the tool should do"
}
}
The bot then:
1. Sends another prompt to GPT asking it to generate Python code for that tool
2. Strips any markdown formatting from the response
3. Saves the code to tools/<tool_name>.py
4. Uses AST parsing to extract function parameters
5. Updates tools.json with the new tool definition
6. Reloads all tools
The next time someone asks for that capability, the tool already exists!
Example Session
User: @Krautbot what's the Bitcoin price?
Bot: {"success": true, "price": "104,234.56"}
User: @Krautbot can you tell me the weather in Tokyo?
Bot: New tool 'get_weather' created, added to tools.json,
and loaded successfully!
User: @Krautbot what's the weather in Tokyo?
Bot: {"location": "Tokyo", "temperature": "12°C", "conditions": "Cloudy"}
Design Philosophy
Krautbot3 embodies a few interesting ideas:
1. LLM as Router: Instead of parsing commands with regex or argument parsers, natural language goes in and structured tool calls come out. The LLM handles ambiguity, synonyms, and context.
2. Self-Improvement: The system can expand its own capabilities without human intervention. Each new tool becomes permanent infrastructure for future requests.
3. Modularity: Tools are completely isolated Python files. They can be edited, deleted, or replaced without touching the core bot code.
4. Transparency: The tools.json manifest is human-readable. You can see exactly what the bot can do and how.
Considerations
This architecture isn't without tradeoffs:
- Quality varies: AI-generated tools may have bugs or be incomplete
- Security surface: Dynamically executing generated code requires trust
- Cost: Every interaction hits the OpenAI API
- Sprawl: The tools directory can accumulate redundant or broken tools over time
The tools.json file shows evidence of this - there are multiple versions of some tools (like get_bitcoin_price and get_bitcoin_price2), renamed tools, and experimental implementations.
Living Alongside Confluxys
Krautbot3 runs on the same VM as the Confluxys website. They share:
- The same Ubuntu 22.04 system
- The same Python environment
- The same ~1GB of RAM (they're both lightweight)
The Discord integration on the Confluxys website (the /discord page) is actually a separate, simpler system - just a message relay. Krautbot3 is the more sophisticated AI-powered sibling.
Conclusion
Krautbot3 is a homebrew experiment in agentic AI - a bot that doesn't just respond to commands but can grow its capabilities over time. With 90+ tools and counting, it's become a Swiss Army knife of Discord automation, system administration, and random internet queries.
It's not production-grade software. It's a tinkerer's project, a proof of concept, a playground for ideas about how AI agents might work. And it lives right here, on the same little cloud VM that serves this website.
Article written by Claude Code, analyzing the Krautbot3 codebase on the Confluxys VM.