$npx -y skills add TencentCloudBase/cloudbase-skills --skill pyBuild production-ready AI agent backends using the CloudBase Agent Python SDK — create agents with LangGraph/CrewAI/LlamaIndex, serve them via FastAPI with AG-UI protocol streaming + OpenAI-compatible endpoints, add tools (bash, filesystem, MCP, code execution), memory (in-memory
| 1 | # CloudBase Agent Python SDK |
| 2 | |
| 3 | Build production-ready AI agent backends with multi-framework support, streaming |
| 4 | protocol, rich tools, persistent memory, and full observability. |
| 5 | |
| 6 | > **Note:** This skill is for **Python** projects only. |
| 7 | |
| 8 | ## When to use this skill |
| 9 | |
| 10 | Use this skill for **AI agent development** when you need to: |
| 11 | |
| 12 | - Deploy AI agents as HTTP services with AG-UI protocol support |
| 13 | - Build agent backends using LangGraph, CrewAI, or LlamaIndex frameworks |
| 14 | - Create custom agent adapters implementing the AbstractAgent interface |
| 15 | - Understand AG-UI protocol events and message streaming |
| 16 | - Build production-ready agent servers with FastAPI |
| 17 | |
| 18 | **Do NOT use for:** |
| 19 | - Simple AI model calling without agent capabilities (use `ai-model-*` skills) |
| 20 | - CloudBase cloud functions (use `cloud-functions` skill) |
| 21 | - CloudRun backend services without agent features (use `cloudrun-development` skill) |
| 22 | - TypeScript/JavaScript agent projects (use `cloudbase-agent` skill, refer to the `ts/` sub-directory) |
| 23 | |
| 24 | ## How to use this skill (for a coding agent) |
| 25 | |
| 26 | 1. **Choose the right adapter** |
| 27 | - Use LangGraph adapter for stateful, graph-based workflows |
| 28 | - Use CrewAI adapter for multi-agent collaboration patterns |
| 29 | - Build custom adapter for specialized agent logic |
| 30 | |
| 31 | 2. **Write agent code** — follow the adapter-specific doc from the Routing table |
| 32 | |
| 33 | 3. **Deploy the agent server** — follow the **blocking deployment pipeline** in [agent-deployment](agent-deployment.md) |
| 34 | |
| 35 | ## Routing (Execution Order) |
| 36 | |
| 37 | > ⚠️ **Deployment is a BLOCKING 4-step pipeline.** Steps marked ✅ BLOCKING |
| 38 | > must be completed AND verified before proceeding to the next step. |
| 39 | > Do NOT call `manageAgent` until all blocking steps pass. |
| 40 | |
| 41 | | Step | Task | Document | Blocking? | |
| 42 | |------|------|----------|-----------| |
| 43 | | 0 | **Choose adapter & write agent code** | See "Adapter Selection" below | — | |
| 44 | | 1 | **Ensure Python 3.10** | [agent-deployment](agent-deployment.md) § Step 1 | ✅ BLOCKING | |
| 45 | | 2 | **Build env/ (one-shot)** | [agent-deployment](agent-deployment.md) § Step 2 | ✅ BLOCKING | |
| 46 | | 3 | **Verify env/ integrity** | [agent-deployment](agent-deployment.md) § Step 3 | ✅ BLOCKING | |
| 47 | | 4 | **Deploy with manageAgent** | [agent-deployment](agent-deployment.md) § Step 4 | — | |
| 48 | |
| 49 | ### Adapter Selection (Step 0) |
| 50 | |
| 51 | | Framework | Read | Install | |
| 52 | |-----------|------|---------| |
| 53 | | LangGraph (stateful graphs) | [adapter-langgraph](adapter-langgraph.md) | `cloudbase-agent-langgraph` | |
| 54 | | CrewAI (multi-agent crews) | [adapter-development](adapter-development.md) | `cloudbase-agent-crewai` | |
| 55 | | Coze platform | [adapter-coze](adapter-coze.md) | `cloudbase-agent-coze` | |
| 56 | | Custom / raw FastAPI | [server-quickstart](server-quickstart.md) + [adapter-development](adapter-development.md) | `cloudbase-agent-server` | |
| 57 | |
| 58 | ### Additional References (read on demand, NOT required for deployment) |
| 59 | |
| 60 | | Task | Read | |
| 61 | |------|------| |
| 62 | | Server setup, middleware, multi-agent, CORS | [server-quickstart](server-quickstart.md) | |
| 63 | | Authentication and user context | [authentication](authentication.md) | |
| 64 | |
| 65 | ## Quick Start (Framework-Agnostic) |
| 66 | |
| 67 | **Prerequisites:** Python >= 3.10 is required. |
| 68 | |
| 69 | **1. Install dependencies (pick ONE adapter):** |
| 70 | |
| 71 | ```bash |
| 72 | # Option A: LangGraph-based agent |
| 73 | pip install cloudbase-agent-langgraph |
| 74 | |
| 75 | # Option B: CrewAI-based agent |
| 76 | pip install cloudbase-agent-crewai |
| 77 | |
| 78 | # Option C: Custom / minimal |
| 79 | pip install cloudbase-agent-server |
| 80 | ``` |
| 81 | |
| 82 | **2. Create server entry point:** |
| 83 | |
| 84 | ```python |
| 85 | # server.py — this pattern works with ANY adapter |
| 86 | import os |
| 87 | from dotenv import load_dotenv |
| 88 | load_dotenv() |
| 89 | |
| 90 | from cloudbase_agent.server import AgentServiceApp, AgentCreatorResult |
| 91 | |
| 92 | # Import your agent (framework-specific, see adapter docs) |
| 93 | # from agents.chat.agent import create_my_agent |
| 94 | |
| 95 | def create_agent() -> AgentCreatorResult: |
| 96 | agent = create_my_agent() # Your agent factory |
| 97 | return {"agent": agent} |
| 98 | |
| 99 | app = AgentServiceApp() |
| 100 | app.set_cors_config(allow_origins=["*"]) |
| 101 | |
| 102 | if __name__ == "__main__": |
| 103 | port = int(os.environ.get("SCF_RUNTIME_PORT", "9000")) |
| 104 | app.run(create_agent, port=port, host="0.0.0.0") |
| 105 | ``` |
| 106 | |
| 107 | **3. Deploy to CloudBase:** |
| 108 | |
| 109 | Follow the **4-step deployment pipeline** in [agent-deployment](agent-deployment.md). |
| 110 | |
| 111 | --- |
| 112 | |
| 113 | ## Architecture |
| 114 | |
| 115 | ``` |
| 116 | Client (React / MiniProgram / curl) |
| 117 | │ HTTP POST + SSE streaming |
| 118 | ▼ |
| 119 | ┌───────────────────── |