How to Build a QwenPaw Agent Workspace with Custom Skills, Model Providers, Console Access, and Streaming API Testing A new tutorial demonstrates how to build a QwenPaw agent workspace with custom skills, model providers, console access, and streaming API testing. The guide covers installation, authentication, workspace configuration, and launching the QwenPaw Console via Colab, enabling both interactive and API-driven agent development. In this tutorial, https://github.com/MARKTECHPOST-AI-MEDIA-INC/AI-Agents-Projects-Tutorials/blob/main/Agentic%20AI%20Codes/qwenpaw agent workspace tutorial Marktechpost.ipynb we implement a QwenPaw https://github.com/agentscope-ai/QwenPaw workflow that provides a practical environment for building and testing an agent-powered assistant. We install and initialize QwenPaw, configure its working directory, set up authentication, connect optional model providers via Colab secrets, and create a structured workspace with custom skills and local knowledge files. We also launch the QwenPaw Console via a Colab-accessible URL, expose it through an optional Cloudflare tunnel, and test the streaming chat API programmatically, enabling us to use QwenPaw both as an interactive assistant and as an API-driven agent framework. python import os import sys import json import time import uuid import shlex import signal import shutil import socket import secrets import pathlib import subprocess from datetime import datetime RESET QWENPAW = False PORT = int os.environ.get "QWENPAW COLAB PORT", "8088" ROOT = pathlib.Path "/content/qwenpaw colab" WORKING DIR = ROOT / "working" SECRET DIR = ROOT / "secrets" LOG DIR = ROOT / "logs" WORKSPACE DIR = WORKING DIR / "workspaces" / "default" PID FILE = ROOT / "qwenpaw app.pid" APP LOG = LOG DIR / "qwenpaw app.log" if RESET QWENPAW and ROOT.exists : shutil.rmtree ROOT for p in ROOT, WORKING DIR, SECRET DIR, LOG DIR, WORKSPACE DIR : p.mkdir parents=True, exist ok=True os.environ "QWENPAW WORKING DIR" = str WORKING DIR os.environ "QWENPAW SECRET DIR" = str SECRET DIR os.environ "QWENPAW AUTH ENABLED" = "true" os.environ "QWENPAW AUTH USERNAME" = os.environ.get "QWENPAW AUTH USERNAME", "admin" os.environ "QWENPAW LOG LEVEL" = os.environ.get "QWENPAW LOG LEVEL", "info" os.environ "QWENPAW SKILL SCAN MODE" = os.environ.get "QWENPAW SKILL SCAN MODE", "warn" os.environ "QWENPAW TOOL GUARD ENABLED" = os.environ.get "QWENPAW TOOL GUARD ENABLED", "true" password file = SECRET DIR / ".colab ui password" if not password file.exists : password file.write text "qpw-" + secrets.token urlsafe 18 , encoding="utf-8" os.environ "QWENPAW AUTH PASSWORD" = password file.read text encoding="utf-8" .strip def run cmd, check=False, env=None, cwd=None, stream=False : if isinstance cmd, str : display cmd = cmd shell = True else: display cmd = " ".join shlex.quote str x for x in cmd shell = False print f"\n$ {display cmd}" if stream: proc = subprocess.Popen cmd, shell=shell, env=env, cwd=cwd, text=True rc = proc.wait if check and rc = 0: raise RuntimeError f"Command failed with exit code {rc}: {display cmd}" return rc, "" out = subprocess.run cmd, shell=shell, env=env, cwd=cwd, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, print out.stdout -4000: if check and out.returncode = 0: raise RuntimeError f"Command failed with exit code {out.returncode}: {display cmd}" return out.returncode, out.stdout def port open host="127.0.0.1", port=8088, timeout=0.5 : try: with socket.create connection host, port , timeout=timeout : return True except OSError: return False def wait for port port, seconds=90 : start = time.time while time.time - start < seconds: if port open "127.0.0.1", port : return True time.sleep 1 return False def stop previous app : if PID FILE.exists : try: pid = int PID FILE.read text .strip os.kill pid, signal.SIGTERM time.sleep 2 try: os.kill pid, 0 os.kill pid, signal.SIGKILL except OSError: pass except Exception: pass PID FILE.unlink missing ok=True def qwenpaw cmd args : exe = shutil.which "qwenpaw" if exe: return exe, args return sys.executable, "-m", "qwenpaw", args def colab secret or env name : value = os.environ.get name, "" try: from google.colab import userdata secret value = userdata.get name if secret value: value = secret value except Exception: pass return value or "" print "Python:", sys.version assert sys.version info = 3, 10 , "QwenPaw needs Python 3.10+." pip spec = os.environ.get "QWENPAW PIP SPEC", "qwenpaw" run sys.executable, "-m", "pip", "install", "-q", "-U", "pip", "setuptools", "wheel" , check=False run sys.executable, "-m", "pip", "install", "-q", "-U", pip spec, "requests" , check=True try: import requests except Exception: run sys.executable, "-m", "pip", "install", "-q", "-U", "requests" , check=True import requests We start by importing all required Python modules and setting up the main directories for the QwenPaw Colab workspace. We configure environment variables for authentication, logging, working paths, and secure access to the QwenPaw Console. We also define helper functions to run shell commands, check ports, stop old app processes, and read API keys from Colab secrets or environment variables. if not WORKING DIR / "config.json" .exists : run qwenpaw cmd "init", "--defaults" , check=False else: print "QwenPaw working directory already initialized:", WORKING DIR provider candidates = { "env": "OPENAI API KEY", "provider id": "openai", "name": "OpenAI", "base url": "https://api.openai.com/v1", "model": os.environ.get "QWENPAW MODEL", "gpt-4o-mini" , "chat model": "OpenAIChatModel", "prefix": "sk-", }, { "env": "OPENROUTER API KEY", "provider id": "openrouter", "name": "OpenRouter", "base url": "https://openrouter.ai/api/v1", "model": os.environ.get "QWENPAW MODEL", "openai/gpt-4o-mini" , "chat model": "OpenAIChatModel", "prefix": "sk-or-", }, { "env": "DASHSCOPE API KEY", "provider id": "dashscope", "name": "DashScope", "base url": "https://dashscope.aliyuncs.com/compatible-mode/v1", "model": os.environ.get "QWENPAW MODEL", "qwen-plus" , "chat model": "OpenAIChatModel", "prefix": "sk-", }, { "env": "DEEPSEEK API KEY", "provider id": "deepseek", "name": "DeepSeek", "base url": "https://api.deepseek.com", "model": os.environ.get "QWENPAW MODEL", "deepseek-chat" , "chat model": "OpenAIChatModel", "prefix": "sk-", }, { "env": "GEMINI API KEY", "provider id": "gemini", "name": "Google Gemini", "base url": "https://generativelanguage.googleapis.com", "model": os.environ.get "QWENPAW MODEL", "gemini-2.5-flash" , "chat model": "GeminiChatModel", "prefix": "", }, { "env": "GOOGLE API KEY", "provider id": "gemini", "name": "Google Gemini", "base url": "https://generativelanguage.googleapis.com", "model": os.environ.get "QWENPAW MODEL", "gemini-2.5-flash" , "chat model": "GeminiChatModel", "prefix": "", }, selected = None for candidate in provider candidates: api key = colab secret or env candidate "env" if api key: selected = { candidate, "api key": api key} break def read json path, default : try: if path.exists : return json.loads path.read text encoding="utf-8" except Exception: pass return default def write json path, data : path.parent.mkdir parents=True, exist ok=True path.write text json.dumps data, indent=2, ensure ascii=False , encoding="utf-8" config path = WORKING DIR / "config.json" config = read json config path, {} config.setdefault "agents", {} config "agents" .setdefault "active agent", "default" config "agents" .setdefault "agent order", "default" config "agents" .setdefault "profiles", {} config "agents" "profiles" .setdefault "default", {} config "agents" "profiles" "default" .update { "id": "default", "name": "Colab Research Assistant", "description": "A QwenPaw agent configured for Google Colab tutorials, local files, custom skills, and API testing.", "workspace dir": str WORKSPACE DIR , "enabled": True, } config "last api" = {"host": "127.0.0.1", "port": PORT} config "show tool details" = True config "user timezone" = "Asia/Kolkata" write json config path, config We initialize the QwenPaw working directory and prepare the base configuration file for the default agent. We define multiple model-provider options, such as OpenAI, OpenRouter, DashScope, DeepSeek, and Gemini, so the setup can adapt to whichever API key we provide. We then update the QwenPaw configuration with the default agent profile, workspace path, API settings, and timezone. agent dir = WORKING DIR / "agents" / "default" agent dir.mkdir parents=True, exist ok=True agent path = agent dir / "agent.json" agent = read json agent path, {} agent.update { "id": "default", "name": "Colab Research Assistant", "description": "Advanced QwenPaw tutorial agent for Colab: file-aware, skill-aware, API-testable, and guarded.", "language": "en", "workspace dir": str WORKSPACE DIR , "enabled": True, "channels": { "console": { "enabled": True } }, "running": { "max iters": 30, "llm retry enabled": True, "stream output": True }, "security": { "tool guard": True, "file guard": True, "skill scanner": True, "skill scan mode": "warn" }, "tool filter": { "enabled": False, "allow": , "deny": }, "memory": { "enabled": True } } if selected: provider dir = SECRET DIR / "providers" / "builtin" provider dir.mkdir parents=True, exist ok=True provider payload = { "id": selected "provider id" , "name": selected "name" , "base url": selected "base url" , "api key": selected "api key" , "chat model": selected "chat model" , "models": , "extra models": { "id": selected "model" , "name": selected "model" , "supports image": None, "supports video": None, "supports multimodal": None, "is free": False, "max tokens": int os.environ.get "QWENPAW MAX TOKENS", "2048" , "max input length": int os.environ.get "QWENPAW MAX INPUT LENGTH", "131072" , "generate kwargs": { "temperature": float os.environ.get "QWENPAW TEMPERATURE", "0.2" , "max tokens": int os.environ.get "QWENPAW MAX TOKENS", "2048" , }, } , "api key prefix": selected "prefix" , "is local": False, "freeze url": True, "require api key": True, "is custom": False, "support model discovery": False, "support connection check": False, "generate kwargs": { "temperature": float os.environ.get "QWENPAW TEMPERATURE", "0.2" , "max tokens": int os.environ.get "QWENPAW MAX TOKENS", "2048" , }, "custom headers": {}, "auth mode": "api key", "meta": {}, } write json provider dir / f"{selected 'provider id' }.json", provider payload write json SECRET DIR / "providers" / "active model.json", {"provider id": selected "provider id" , "model": selected "model" }, agent "active model" = {"provider id": selected "provider id" , "model": selected "model" } print f"Configured model provider: {selected 'name' } / {selected 'model' }" else: print "No model key found. The web app will still launch, but chat requires a configured model.\n" "Add one Colab secret or environment variable such as OPENAI API KEY, OPENROUTER API KEY, " "DASHSCOPE API KEY, DEEPSEEK API KEY, GEMINI API KEY, or GOOGLE API KEY, then rerun." write json agent path, agent We create the default QwenPaw agent configuration with console access, memory support, streaming output, and guarded tool execution. We automatically configure the selected model provider when a supported API key is available in Colab secrets or environment variables. We save the active model and agent settings so QwenPaw can use the configured provider during chat and API-based interactions. skill dir = WORKSPACE DIR / "skills" / "research brief" skill dir.mkdir parents=True, exist ok=True skill dir / "SKILL.md" .write text """--- name: research brief description: Create rigorous research briefs from user questions, local notes, uploaded files, and available tools. --- Research Brief Skill Use this skill when the user asks for research, product analysis, market mapping, technical due diligence, paper analysis, repo analysis, or a decision memo. Procedure 1. Restate the user's objective in one sentence. 2. Identify the most important entities, assumptions, and constraints. 3. Search available local workspace files first. 4. Use tools only when they are relevant and allowed. 5. Separate verified facts from inference. 6. Produce a compact brief with: - answer - evidence - risks or caveats - recommended next step Output Style Prefer clear sections, short paragraphs, and explicit uncertainty. Do not invent citations, file contents, commands, or results. """, encoding="utf-8", demo dir = WORKSPACE DIR / "demo knowledge" demo dir.mkdir parents=True, exist ok=True demo dir / "qwenpaw colab notes.md" .write text f""" QwenPaw Colab Demo Notes Created: {datetime.now .isoformat timespec="seconds" } This workspace is prepared by a Google Colab tutorial. The tutorial demonstrates: - QwenPaw installation and initialization - provider auto-configuration from Colab secrets or environment variables - authenticated Console launch - custom workspace skill creation - local workspace knowledge files - streaming REST API calls - optional public tunnel exposure Recommended first prompt in the Console: "Read my workspace notes and explain what this QwenPaw Colab setup can do. Then use the research brief skill style to propose three advanced experiments." """, encoding="utf-8", WORKSPACE DIR / "README COLAB TUTORIAL.md" .write text """ QwenPaw Advanced Colab Workspace This workspace is intentionally small but structured like a real assistant workspace. Suggested experiments: 1. Ask QwenPaw to inspect the demo knowledge folder. 2. Ask it to use the research brief skill style. 3. Use the REST API client in this notebook for automated tests. 4. Add more SKILL.md folders under workspace/skills. 5. Add more notes, CSVs, markdown files, or task briefs under workspace folders. """, encoding="utf-8", print "\nWorkspace prepared:" print "Working dir:", WORKING DIR print "Secret dir :", SECRET DIR print "Workspace :", WORKSPACE DIR print "Skill file :", skill dir / "SKILL.md" run qwenpaw cmd "daemon", "version" , check=False run qwenpaw cmd "models", "list" , check=False run qwenpaw cmd "skills", "list", "--agent-id", "default" , check=False We create a custom research brief skill inside the QwenPaw workspace to guide the agent toward structured research outputs. We add demo knowledge files that explain the Colab setup and provide the agent with a local workspace context to inspect. We then print the prepared workspace paths and run QwenPaw commands to verify the daemon, available models, and registered skills. stop previous app APP LOG.parent.mkdir parents=True, exist ok=True log fh = APP LOG.open "w", encoding="utf-8" app proc = subprocess.Popen qwenpaw cmd "app", "--host", "0.0.0.0", "--port", str PORT , "--log-level", os.environ "QWENPAW LOG LEVEL" , stdout=log fh, stderr=subprocess.STDOUT, env=os.environ.copy , PID FILE.write text str app proc.pid , encoding="utf-8" if not wait for port PORT, seconds=120 : print "\nQwenPaw did not open the port. Last log lines:" try: print APP LOG.read text encoding="utf-8" -6000: except Exception as e: print "Could not read log:", e raise RuntimeError "QwenPaw app failed to start." print f"\nQwenPaw app is running on http://127.0.0.1:{PORT}" print "Username:", os.environ "QWENPAW AUTH USERNAME" print "Password:", os.environ "QWENPAW AUTH PASSWORD" print "App log:", APP LOG try: from google.colab import output proxy url = output.eval js f"google.colab.kernel.proxyPort {PORT} " print "\nColab proxied Console URL:" print proxy url try: output.serve kernel port as window PORT except Exception: pass except Exception as e: print "\nNot running inside Google Colab proxy environment:", e def start cloudflared tunnel port : system bin = pathlib.Path "/usr/local/bin/cloudflared" local bin = ROOT / "cloudflared" cloudflared = system bin if system bin.exists else local bin if not cloudflared.exists : url = "https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64" target = str system bin rc, = run f"wget -q {shlex.quote url } -O {shlex.quote target } && chmod +x {shlex.quote target }", check=False if rc = 0 or not system bin.exists : target = str local bin rc, = run f"wget -q {shlex.quote url } -O {shlex.quote target } && chmod +x {shlex.quote target }", check=False cloudflared = pathlib.Path target if not cloudflared.exists : print "cloudflared tunnel unavailable. Use the Colab proxy URL above." return None, None tunnel log = LOG DIR / "cloudflared.log" fh = tunnel log.open "w", encoding="utf-8" proc = subprocess.Popen str cloudflared , "tunnel", "--url", f"http://127.0.0.1:{port}", "--no-autoupdate" , stdout=fh, stderr=subprocess.STDOUT, text=True, public url = None start = time.time while time.time - start < 45: time.sleep 1 try: text = tunnel log.read text encoding="utf-8", errors="ignore" except Exception: text = "" for token in text.replace "|", " " .split : if token.startswith "https://" and "trycloudflare.com" in token: public url = token.strip break if public url: break if public url: print "\nTemporary public tunnel URL:" print public url print "Use the same username/password printed above." else: print "\nCloudflare tunnel started but no URL was detected yet." print "Tunnel log:", tunnel log return proc, public url ENABLE CLOUDFLARE TUNNEL = os.environ.get "ENABLE QWENPAW TUNNEL", "1" == "1" cloudflared proc, public url = None, None if ENABLE CLOUDFLARE TUNNEL: cloudflared proc, public url = start cloudflared tunnel PORT We stop any previous QwenPaw app process and launch a fresh QwenPaw Console server on the configured Colab port. We wait until the server becomes available, then print the login credentials, the local URL, the log path, and the Colab proxy URL. We also optionally start a Cloudflare tunnel so the QwenPaw Console can be accessed through a temporary public link. python def qwenpaw chat message, session id=None, user id="colab-user", agent id="default", timeout=180 : session id = session id or f"colab-{uuid.uuid4 .hex :10 }" url = f"http://127.0.0.1:{PORT}/api/console/chat" headers = { "Content-Type": "application/json", "X-Agent-Id": agent id, } payload = { "message": message, "session id": session id, "user id": user id, } print "\nAPI request:" print json.dumps { payload, "message": message :300 }, indent=2 with requests.post url, headers=headers, json=payload, stream=True, timeout=timeout as response: print "HTTP status:", response.status code if response.status code = 400: print response.text :4000 response.raise for status last text = "" final text = "" raw events seen = 0 for raw in response.iter lines decode unicode=True : if not raw: continue if raw.startswith "data:" : raw events seen += 1 data = raw len "data:" : .strip if data == " DONE ": break try: event = json.loads data except Exception: continue candidate texts = def walk x : if isinstance x, dict : for key, value in x.items : if key in {"text", "content", "message", "delta"} and isinstance value, str : candidate texts.append value else: walk value elif isinstance x, list : for item in x: walk item walk event if candidate texts: text = candidate texts -1 if text and len text = len final text : final text = text if text.startswith last text : print text len last text : , end="", flush=True else: print "\n" + text, end="", flush=True last text = text print "\n\nStreaming events seen:", raw events seen return {"session id": session id, "text": final text} if selected: try: result = qwenpaw chat "Read the local workspace notes if available. Then explain this Colab QwenPaw setup in five bullets and suggest two advanced experiments.", session id="qwenpaw-colab-demo", print "\nFinal session id:", result "session id" except Exception as e: print "\nAPI demo failed. The Console may still work; inspect the app log below." print "Error:", repr e try: print APP LOG.read text encoding="utf-8" -8000: except Exception: pass else: print "\nSkipping API chat demo because no model provider key was found.\n" "Open the Console URL above, or add a Colab secret such as OPENAI API KEY / OPENROUTER API KEY / DASHSCOPE API KEY / DEEPSEEK API KEY / GEMINI API KEY and rerun." print "\nSummary" print "Console username:", os.environ "QWENPAW AUTH USERNAME" print "Console password:", os.environ "QWENPAW AUTH PASSWORD" print "Local URL:", f"http://127.0.0.1:{PORT}" if public url: print "Public tunnel:", public url print "Workspace:", WORKSPACE DIR print "Logs:", APP LOG print "\nTo stop the server manually, run:" print f"import os, signal; os.kill {app proc.pid}, signal.SIGTERM " We define a streaming API client that sends messages to QwenPaw through the /api/console/chat endpoint. We test the configured agent by asking it to read the local workspace notes and summarize the Colab setup, including advanced experimental ideas. We finish by printing the final access details, workspace path, log location, tunnel URL if available, and a command to stop the running server. In conclusion, we have a complete Colab-ready QwenPaw setup that goes beyond basic installation and demonstrates how we can configure, extend, launch, and test an agent workspace in a reproducible way. We created a secure, authenticated assistant environment, added a custom research skill, prepared local workspace knowledge, and verified the system through both the web Console and REST API calls. It provides us a strong foundation for experimenting with QwenPaw as a local-first agent platform for research workflows, file-aware assistants, custom skills, and advanced automation-style agent applications. Check out the Full Codes with Notebook here. Also, feel free to follow us on and don’t forget to join our Twitter https://x.com/intent/follow?screen name=marktechpost and Subscribe to 150k+ML SubReddit https://www.reddit.com/r/machinelearningnews/ . Wait are you on telegram? our Newsletter https://www.aidevsignals.com/ now you can join us on telegram as well. https://t.me/machinelearningresearchnews Need to partner with us for promoting your GitHub Repo OR Hugging Face Page OR Product Release OR Webinar etc.? Connect with us https://forms.gle/wbash1wF6efRj8G58 Sana Hassan, a consulting intern at Marktechpost and dual-degree student at IIT Madras, is passionate about applying technology and AI to address real-world challenges. With a keen interest in solving practical problems, he brings a fresh perspective to the intersection of AI and real-life solutions. - Sana Hassan - Sana Hassan - Sana Hassan - Sana Hassan