A step-by-step tutorial that incrementally builds an autonomous LLM agent — from a simple chatbot to a system resembling Cursor or Claude Code.
Each step is a self-contained, independently runnable project. Later steps build upon earlier ones, adding one new core capability at a time.
| Step | Name | Core Capability |
|---|---|---|
| 01 | Basic Chatbot | LLM API calls, multi-turn conversation |
| 02 | Context Management | Token counting, context inspection, debug view |
| 03 | Tool Use | Function calling, tool schema, smart compaction, calibrated token tracking |
| 04 | File Tools | File read/write/search + dynamic skill-based schema exposure |
| 05 | Shell Tool | Shell command execution with safety approvals |
| 06 | Error Recovery | Task-level retry, autonomous repair, optional failed-trace cleanup |
| 07 | CUDA Agent | Domain-specific CUDA kernel development with compile-verify-profile loop |
| 08 | Preemptible CUDA Agent | Queue-based interruptible autonomy with runtime task preemption |
| 09 | MCP Support | Model Context Protocol, dynamic tool discovery |
| 10 (optional) | Streaming | Streaming output and richer terminal UX |
cd 01_basic_chatbot
pip install -r requirements.txt
# Option A: Ksyun (mco-4 / opus4.6, used by default when key is set)
export KSYUN_API_KEY="your-key"
# Option B: InfiniAI (deepseek-v3, fallback when KSYUN_API_KEY is absent)
export INFINI_API_KEY="your-key"
python chatbot.pyThe chatbot auto-detects the provider from environment variables — Ksyun takes priority when KSYUN_API_KEY is set, otherwise it falls back to InfiniAI.
| Provider | Env var | Default model | Base URL |
|---|---|---|---|
| Ksyun | KSYUN_API_KEY |
mco-4 (opus4.6) |
https://kspmas.ksyun.com/v1/ |
| InfiniAI | INFINI_API_KEY |
deepseek-v3 |
https://cloud.infini-ai.com/maas/v1 |
Override the model at any time with --model <name>.