{"slug": "how-to-build-a-qwenpaw-agent-workspace-with-custom-skills-model-providers-access", "title": "How to Build a QwenPaw Agent Workspace with Custom Skills, Model Providers, Console Access, and Streaming API Testing", "summary": "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.", "body_md": "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.\n\n``` python\nimport os\nimport sys\nimport json\nimport time\nimport uuid\nimport shlex\nimport signal\nimport shutil\nimport socket\nimport secrets\nimport pathlib\nimport subprocess\nfrom datetime import datetime\nRESET_QWENPAW = False\nPORT = int(os.environ.get(\"QWENPAW_COLAB_PORT\", \"8088\"))\nROOT = pathlib.Path(\"/content/qwenpaw_colab\")\nWORKING_DIR = ROOT / \"working\"\nSECRET_DIR = ROOT / \"secrets\"\nLOG_DIR = ROOT / \"logs\"\nWORKSPACE_DIR = WORKING_DIR / \"workspaces\" / \"default\"\nPID_FILE = ROOT / \"qwenpaw_app.pid\"\nAPP_LOG = LOG_DIR / \"qwenpaw_app.log\"\nif RESET_QWENPAW and ROOT.exists():\n   shutil.rmtree(ROOT)\nfor p in [ROOT, WORKING_DIR, SECRET_DIR, LOG_DIR, WORKSPACE_DIR]:\n   p.mkdir(parents=True, exist_ok=True)\nos.environ[\"QWENPAW_WORKING_DIR\"] = str(WORKING_DIR)\nos.environ[\"QWENPAW_SECRET_DIR\"] = str(SECRET_DIR)\nos.environ[\"QWENPAW_AUTH_ENABLED\"] = \"true\"\nos.environ[\"QWENPAW_AUTH_USERNAME\"] = os.environ.get(\"QWENPAW_AUTH_USERNAME\", \"admin\")\nos.environ[\"QWENPAW_LOG_LEVEL\"] = os.environ.get(\"QWENPAW_LOG_LEVEL\", \"info\")\nos.environ[\"QWENPAW_SKILL_SCAN_MODE\"] = os.environ.get(\"QWENPAW_SKILL_SCAN_MODE\", \"warn\")\nos.environ[\"QWENPAW_TOOL_GUARD_ENABLED\"] = os.environ.get(\"QWENPAW_TOOL_GUARD_ENABLED\", \"true\")\npassword_file = SECRET_DIR / \".colab_ui_password\"\nif not password_file.exists():\n   password_file.write_text(\"qpw-\" + secrets.token_urlsafe(18), encoding=\"utf-8\")\nos.environ[\"QWENPAW_AUTH_PASSWORD\"] = password_file.read_text(encoding=\"utf-8\").strip()\ndef run(cmd, check=False, env=None, cwd=None, stream=False):\n   if isinstance(cmd, str):\n       display_cmd = cmd\n       shell = True\n   else:\n       display_cmd = \" \".join(shlex.quote(str(x)) for x in cmd)\n       shell = False\n   print(f\"\\n$ {display_cmd}\")\n   if stream:\n       proc = subprocess.Popen(cmd, shell=shell, env=env, cwd=cwd, text=True)\n       rc = proc.wait()\n       if check and rc != 0:\n           raise RuntimeError(f\"Command failed with exit code {rc}: {display_cmd}\")\n       return rc, \"\"\n   out = subprocess.run(\n       cmd,\n       shell=shell,\n       env=env,\n       cwd=cwd,\n       text=True,\n       stdout=subprocess.PIPE,\n       stderr=subprocess.STDOUT,\n   )\n   print(out.stdout[-4000:])\n   if check and out.returncode != 0:\n       raise RuntimeError(f\"Command failed with exit code {out.returncode}: {display_cmd}\")\n   return out.returncode, out.stdout\ndef port_open(host=\"127.0.0.1\", port=8088, timeout=0.5):\n   try:\n       with socket.create_connection((host, port), timeout=timeout):\n           return True\n   except OSError:\n       return False\ndef wait_for_port(port, seconds=90):\n   start = time.time()\n   while time.time() - start < seconds:\n       if port_open(\"127.0.0.1\", port):\n           return True\n       time.sleep(1)\n   return False\ndef stop_previous_app():\n   if PID_FILE.exists():\n       try:\n           pid = int(PID_FILE.read_text().strip())\n           os.kill(pid, signal.SIGTERM)\n           time.sleep(2)\n           try:\n               os.kill(pid, 0)\n               os.kill(pid, signal.SIGKILL)\n           except OSError:\n               pass\n       except Exception:\n           pass\n       PID_FILE.unlink(missing_ok=True)\ndef qwenpaw_cmd(*args):\n   exe = shutil.which(\"qwenpaw\")\n   if exe:\n       return [exe, *args]\n   return [sys.executable, \"-m\", \"qwenpaw\", *args]\ndef colab_secret_or_env(name):\n   value = os.environ.get(name, \"\")\n   try:\n       from google.colab import userdata\n       secret_value = userdata.get(name)\n       if secret_value:\n           value = secret_value\n   except Exception:\n       pass\n   return value or \"\"\nprint(\"Python:\", sys.version)\nassert sys.version_info >= (3, 10), \"QwenPaw needs Python 3.10+.\"\npip_spec = os.environ.get(\"QWENPAW_PIP_SPEC\", \"qwenpaw\")\nrun([sys.executable, \"-m\", \"pip\", \"install\", \"-q\", \"-U\", \"pip\", \"setuptools\", \"wheel\"], check=False)\nrun([sys.executable, \"-m\", \"pip\", \"install\", \"-q\", \"-U\", pip_spec, \"requests\"], check=True)\ntry:\n   import requests\nexcept Exception:\n   run([sys.executable, \"-m\", \"pip\", \"install\", \"-q\", \"-U\", \"requests\"], check=True)\n   import requests\n```\n\nWe 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.\n\n```\nif not (WORKING_DIR / \"config.json\").exists():\n   run(qwenpaw_cmd(\"init\", \"--defaults\"), check=False)\nelse:\n   print(\"QwenPaw working directory already initialized:\", WORKING_DIR)\nprovider_candidates = [\n   {\n       \"env\": \"OPENAI_API_KEY\",\n       \"provider_id\": \"openai\",\n       \"name\": \"OpenAI\",\n       \"base_url\": \"https://api.openai.com/v1\",\n       \"model\": os.environ.get(\"QWENPAW_MODEL\", \"gpt-4o-mini\"),\n       \"chat_model\": \"OpenAIChatModel\",\n       \"prefix\": \"sk-\",\n   },\n   {\n       \"env\": \"OPENROUTER_API_KEY\",\n       \"provider_id\": \"openrouter\",\n       \"name\": \"OpenRouter\",\n       \"base_url\": \"https://openrouter.ai/api/v1\",\n       \"model\": os.environ.get(\"QWENPAW_MODEL\", \"openai/gpt-4o-mini\"),\n       \"chat_model\": \"OpenAIChatModel\",\n       \"prefix\": \"sk-or-\",\n   },\n   {\n       \"env\": \"DASHSCOPE_API_KEY\",\n       \"provider_id\": \"dashscope\",\n       \"name\": \"DashScope\",\n       \"base_url\": \"https://dashscope.aliyuncs.com/compatible-mode/v1\",\n       \"model\": os.environ.get(\"QWENPAW_MODEL\", \"qwen-plus\"),\n       \"chat_model\": \"OpenAIChatModel\",\n       \"prefix\": \"sk-\",\n   },\n   {\n       \"env\": \"DEEPSEEK_API_KEY\",\n       \"provider_id\": \"deepseek\",\n       \"name\": \"DeepSeek\",\n       \"base_url\": \"https://api.deepseek.com\",\n       \"model\": os.environ.get(\"QWENPAW_MODEL\", \"deepseek-chat\"),\n       \"chat_model\": \"OpenAIChatModel\",\n       \"prefix\": \"sk-\",\n   },\n   {\n       \"env\": \"GEMINI_API_KEY\",\n       \"provider_id\": \"gemini\",\n       \"name\": \"Google Gemini\",\n       \"base_url\": \"https://generativelanguage.googleapis.com\",\n       \"model\": os.environ.get(\"QWENPAW_MODEL\", \"gemini-2.5-flash\"),\n       \"chat_model\": \"GeminiChatModel\",\n       \"prefix\": \"\",\n   },\n   {\n       \"env\": \"GOOGLE_API_KEY\",\n       \"provider_id\": \"gemini\",\n       \"name\": \"Google Gemini\",\n       \"base_url\": \"https://generativelanguage.googleapis.com\",\n       \"model\": os.environ.get(\"QWENPAW_MODEL\", \"gemini-2.5-flash\"),\n       \"chat_model\": \"GeminiChatModel\",\n       \"prefix\": \"\",\n   },\n]\nselected = None\nfor candidate in provider_candidates:\n   api_key = colab_secret_or_env(candidate[\"env\"])\n   if api_key:\n       selected = {**candidate, \"api_key\": api_key}\n       break\ndef read_json(path, default):\n   try:\n       if path.exists():\n           return json.loads(path.read_text(encoding=\"utf-8\"))\n   except Exception:\n       pass\n   return default\ndef write_json(path, data):\n   path.parent.mkdir(parents=True, exist_ok=True)\n   path.write_text(json.dumps(data, indent=2, ensure_ascii=False), encoding=\"utf-8\")\nconfig_path = WORKING_DIR / \"config.json\"\nconfig = read_json(config_path, {})\nconfig.setdefault(\"agents\", {})\nconfig[\"agents\"].setdefault(\"active_agent\", \"default\")\nconfig[\"agents\"].setdefault(\"agent_order\", [\"default\"])\nconfig[\"agents\"].setdefault(\"profiles\", {})\nconfig[\"agents\"][\"profiles\"].setdefault(\"default\", {})\nconfig[\"agents\"][\"profiles\"][\"default\"].update(\n   {\n       \"id\": \"default\",\n       \"name\": \"Colab Research Assistant\",\n       \"description\": \"A QwenPaw agent configured for Google Colab tutorials, local files, custom skills, and API testing.\",\n       \"workspace_dir\": str(WORKSPACE_DIR),\n       \"enabled\": True,\n   }\n)\nconfig[\"last_api\"] = {\"host\": \"127.0.0.1\", \"port\": PORT}\nconfig[\"show_tool_details\"] = True\nconfig[\"user_timezone\"] = \"Asia/Kolkata\"\nwrite_json(config_path, config)\n```\n\nWe 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.\n\n```\nagent_dir = WORKING_DIR / \"agents\" / \"default\"\nagent_dir.mkdir(parents=True, exist_ok=True)\nagent_path = agent_dir / \"agent.json\"\nagent = read_json(agent_path, {})\nagent.update(\n   {\n       \"id\": \"default\",\n       \"name\": \"Colab Research Assistant\",\n       \"description\": \"Advanced QwenPaw tutorial agent for Colab: file-aware, skill-aware, API-testable, and guarded.\",\n       \"language\": \"en\",\n       \"workspace_dir\": str(WORKSPACE_DIR),\n       \"enabled\": True,\n       \"channels\": {\n           \"console\": {\n               \"enabled\": True\n           }\n       },\n       \"running\": {\n           \"max_iters\": 30,\n           \"llm_retry_enabled\": True,\n           \"stream_output\": True\n       },\n       \"security\": {\n           \"tool_guard\": True,\n           \"file_guard\": True,\n           \"skill_scanner\": True,\n           \"skill_scan_mode\": \"warn\"\n       },\n       \"tool_filter\": {\n           \"enabled\": False,\n           \"allow\": [],\n           \"deny\": []\n       },\n       \"memory\": {\n           \"enabled\": True\n       }\n   }\n)\nif selected:\n   provider_dir = SECRET_DIR / \"providers\" / \"builtin\"\n   provider_dir.mkdir(parents=True, exist_ok=True)\n   provider_payload = {\n       \"id\": selected[\"provider_id\"],\n       \"name\": selected[\"name\"],\n       \"base_url\": selected[\"base_url\"],\n       \"api_key\": selected[\"api_key\"],\n       \"chat_model\": selected[\"chat_model\"],\n       \"models\": [],\n       \"extra_models\": [\n           {\n               \"id\": selected[\"model\"],\n               \"name\": selected[\"model\"],\n               \"supports_image\": None,\n               \"supports_video\": None,\n               \"supports_multimodal\": None,\n               \"is_free\": False,\n               \"max_tokens\": int(os.environ.get(\"QWENPAW_MAX_TOKENS\", \"2048\")),\n               \"max_input_length\": int(os.environ.get(\"QWENPAW_MAX_INPUT_LENGTH\", \"131072\")),\n               \"generate_kwargs\": {\n                   \"temperature\": float(os.environ.get(\"QWENPAW_TEMPERATURE\", \"0.2\")),\n                   \"max_tokens\": int(os.environ.get(\"QWENPAW_MAX_TOKENS\", \"2048\")),\n               },\n           }\n       ],\n       \"api_key_prefix\": selected[\"prefix\"],\n       \"is_local\": False,\n       \"freeze_url\": True,\n       \"require_api_key\": True,\n       \"is_custom\": False,\n       \"support_model_discovery\": False,\n       \"support_connection_check\": False,\n       \"generate_kwargs\": {\n           \"temperature\": float(os.environ.get(\"QWENPAW_TEMPERATURE\", \"0.2\")),\n           \"max_tokens\": int(os.environ.get(\"QWENPAW_MAX_TOKENS\", \"2048\")),\n       },\n       \"custom_headers\": {},\n       \"auth_mode\": \"api_key\",\n       \"meta\": {},\n   }\n   write_json(provider_dir / f\"{selected['provider_id']}.json\", provider_payload)\n   write_json(\n       SECRET_DIR / \"providers\" / \"active_model.json\",\n       {\"provider_id\": selected[\"provider_id\"], \"model\": selected[\"model\"]},\n   )\n   agent[\"active_model\"] = {\"provider_id\": selected[\"provider_id\"], \"model\": selected[\"model\"]}\n   print(f\"Configured model provider: {selected['name']} / {selected['model']}\")\nelse:\n   print(\n       \"No model key found. The web app will still launch, but chat requires a configured model.\\n\"\n       \"Add one Colab secret or environment variable such as OPENAI_API_KEY, OPENROUTER_API_KEY, \"\n       \"DASHSCOPE_API_KEY, DEEPSEEK_API_KEY, GEMINI_API_KEY, or GOOGLE_API_KEY, then rerun.\"\n   )\nwrite_json(agent_path, agent)\n```\n\nWe 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.\n\n```\nskill_dir = WORKSPACE_DIR / \"skills\" / \"research_brief\"\nskill_dir.mkdir(parents=True, exist_ok=True)\n(skill_dir / \"SKILL.md\").write_text(\n   \"\"\"---\nname: research_brief\ndescription: Create rigorous research briefs from user questions, local notes, uploaded files, and available tools.\n---\n# Research Brief Skill\nUse this skill when the user asks for research, product analysis, market mapping, technical due diligence, paper analysis, repo analysis, or a decision memo.\n## Procedure\n1. Restate the user's objective in one sentence.\n2. Identify the most important entities, assumptions, and constraints.\n3. Search available local workspace files first.\n4. Use tools only when they are relevant and allowed.\n5. Separate verified facts from inference.\n6. Produce a compact brief with:\n  - answer\n  - evidence\n  - risks or caveats\n  - recommended next step\n## Output Style\nPrefer clear sections, short paragraphs, and explicit uncertainty.\nDo not invent citations, file contents, commands, or results.\n\"\"\",\n   encoding=\"utf-8\",\n)\ndemo_dir = WORKSPACE_DIR / \"demo_knowledge\"\ndemo_dir.mkdir(parents=True, exist_ok=True)\n(demo_dir / \"qwenpaw_colab_notes.md\").write_text(\n   f\"\"\"# QwenPaw Colab Demo Notes\nCreated: {datetime.now().isoformat(timespec=\"seconds\")}\nThis workspace is prepared by a Google Colab tutorial.\nThe tutorial demonstrates:\n- QwenPaw installation and initialization\n- provider auto-configuration from Colab secrets or environment variables\n- authenticated Console launch\n- custom workspace skill creation\n- local workspace knowledge files\n- streaming REST API calls\n- optional public tunnel exposure\nRecommended first prompt in the Console:\n\"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.\"\n\"\"\",\n   encoding=\"utf-8\",\n)\n(WORKSPACE_DIR / \"README_COLAB_TUTORIAL.md\").write_text(\n   \"\"\"# QwenPaw Advanced Colab Workspace\nThis workspace is intentionally small but structured like a real assistant workspace.\nSuggested experiments:\n1. Ask QwenPaw to inspect the demo_knowledge folder.\n2. Ask it to use the research_brief skill style.\n3. Use the REST API client in this notebook for automated tests.\n4. Add more SKILL.md folders under workspace/skills.\n5. Add more notes, CSVs, markdown files, or task briefs under workspace folders.\n\"\"\",\n   encoding=\"utf-8\",\n)\nprint(\"\\nWorkspace prepared:\")\nprint(\"Working dir:\", WORKING_DIR)\nprint(\"Secret dir :\", SECRET_DIR)\nprint(\"Workspace  :\", WORKSPACE_DIR)\nprint(\"Skill file :\", skill_dir / \"SKILL.md\")\nrun(qwenpaw_cmd(\"daemon\", \"version\"), check=False)\nrun(qwenpaw_cmd(\"models\", \"list\"), check=False)\nrun(qwenpaw_cmd(\"skills\", \"list\", \"--agent-id\", \"default\"), check=False)\n```\n\nWe 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.\n\n```\nstop_previous_app()\nAPP_LOG.parent.mkdir(parents=True, exist_ok=True)\nlog_fh = APP_LOG.open(\"w\", encoding=\"utf-8\")\napp_proc = subprocess.Popen(\n   qwenpaw_cmd(\"app\", \"--host\", \"0.0.0.0\", \"--port\", str(PORT), \"--log-level\", os.environ[\"QWENPAW_LOG_LEVEL\"]),\n   stdout=log_fh,\n   stderr=subprocess.STDOUT,\n   env=os.environ.copy(),\n)\nPID_FILE.write_text(str(app_proc.pid), encoding=\"utf-8\")\nif not wait_for_port(PORT, seconds=120):\n   print(\"\\nQwenPaw did not open the port. Last log lines:\")\n   try:\n       print(APP_LOG.read_text(encoding=\"utf-8\")[-6000:])\n   except Exception as e:\n       print(\"Could not read log:\", e)\n   raise RuntimeError(\"QwenPaw app failed to start.\")\nprint(f\"\\nQwenPaw app is running on http://127.0.0.1:{PORT}\")\nprint(\"Username:\", os.environ[\"QWENPAW_AUTH_USERNAME\"])\nprint(\"Password:\", os.environ[\"QWENPAW_AUTH_PASSWORD\"])\nprint(\"App log:\", APP_LOG)\ntry:\n   from google.colab import output\n   proxy_url = output.eval_js(f\"google.colab.kernel.proxyPort({PORT})\")\n   print(\"\\nColab proxied Console URL:\")\n   print(proxy_url)\n   try:\n       output.serve_kernel_port_as_window(PORT)\n   except Exception:\n       pass\nexcept Exception as e:\n   print(\"\\nNot running inside Google Colab proxy environment:\", e)\ndef start_cloudflared_tunnel(port):\n   system_bin = pathlib.Path(\"/usr/local/bin/cloudflared\")\n   local_bin = ROOT / \"cloudflared\"\n   cloudflared = system_bin if system_bin.exists() else local_bin\n   if not cloudflared.exists():\n       url = \"https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64\"\n       target = str(system_bin)\n       rc, _ = run(f\"wget -q {shlex.quote(url)} -O {shlex.quote(target)} && chmod +x {shlex.quote(target)}\", check=False)\n       if rc != 0 or not system_bin.exists():\n           target = str(local_bin)\n           rc, _ = run(f\"wget -q {shlex.quote(url)} -O {shlex.quote(target)} && chmod +x {shlex.quote(target)}\", check=False)\n       cloudflared = pathlib.Path(target)\n   if not cloudflared.exists():\n       print(\"cloudflared tunnel unavailable. Use the Colab proxy URL above.\")\n       return None, None\n   tunnel_log = LOG_DIR / \"cloudflared.log\"\n   fh = tunnel_log.open(\"w\", encoding=\"utf-8\")\n   proc = subprocess.Popen(\n       [str(cloudflared), \"tunnel\", \"--url\", f\"http://127.0.0.1:{port}\", \"--no-autoupdate\"],\n       stdout=fh,\n       stderr=subprocess.STDOUT,\n       text=True,\n   )\n   public_url = None\n   start = time.time()\n   while time.time() - start < 45:\n       time.sleep(1)\n       try:\n           text = tunnel_log.read_text(encoding=\"utf-8\", errors=\"ignore\")\n       except Exception:\n           text = \"\"\n       for token in text.replace(\"|\", \" \").split():\n           if token.startswith(\"https://\") and \"trycloudflare.com\" in token:\n               public_url = token.strip()\n               break\n       if public_url:\n           break\n   if public_url:\n       print(\"\\nTemporary public tunnel URL:\")\n       print(public_url)\n       print(\"Use the same username/password printed above.\")\n   else:\n       print(\"\\nCloudflare tunnel started but no URL was detected yet.\")\n       print(\"Tunnel log:\", tunnel_log)\n   return proc, public_url\nENABLE_CLOUDFLARE_TUNNEL = os.environ.get(\"ENABLE_QWENPAW_TUNNEL\", \"1\") == \"1\"\ncloudflared_proc, public_url = (None, None)\nif ENABLE_CLOUDFLARE_TUNNEL:\n   cloudflared_proc, public_url = start_cloudflared_tunnel(PORT)\n```\n\nWe 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.\n\n``` python\ndef qwenpaw_chat(message, session_id=None, user_id=\"colab-user\", agent_id=\"default\", timeout=180):\n   session_id = session_id or f\"colab-{uuid.uuid4().hex[:10]}\"\n   url = f\"http://127.0.0.1:{PORT}/api/console/chat\"\n   headers = {\n       \"Content-Type\": \"application/json\",\n       \"X-Agent-Id\": agent_id,\n   }\n   payload = {\n       \"message\": message,\n       \"session_id\": session_id,\n       \"user_id\": user_id,\n   }\n   print(\"\\nAPI request:\")\n   print(json.dumps({**payload, \"message\": message[:300]}, indent=2))\n   with requests.post(url, headers=headers, json=payload, stream=True, timeout=timeout) as response:\n       print(\"HTTP status:\", response.status_code)\n       if response.status_code >= 400:\n           print(response.text[:4000])\n           response.raise_for_status()\n       last_text = \"\"\n       final_text = \"\"\n       raw_events_seen = 0\n       for raw in response.iter_lines(decode_unicode=True):\n           if not raw:\n               continue\n           if raw.startswith(\"data:\"):\n               raw_events_seen += 1\n               data = raw[len(\"data:\"):].strip()\n               if data == \"[DONE]\":\n                   break\n               try:\n                   event = json.loads(data)\n               except Exception:\n                   continue\n               candidate_texts = []\n               def walk(x):\n                   if isinstance(x, dict):\n                       for key, value in x.items():\n                           if key in {\"text\", \"content\", \"message\", \"delta\"} and isinstance(value, str):\n                               candidate_texts.append(value)\n                           else:\n                               walk(value)\n                   elif isinstance(x, list):\n                       for item in x:\n                           walk(item)\n               walk(event)\n               if candidate_texts:\n                   text = candidate_texts[-1]\n                   if text and len(text) >= len(final_text):\n                       final_text = text\n                       if text.startswith(last_text):\n                           print(text[len(last_text):], end=\"\", flush=True)\n                       else:\n                           print(\"\\n\" + text, end=\"\", flush=True)\n                       last_text = text\n       print(\"\\n\\nStreaming events seen:\", raw_events_seen)\n       return {\"session_id\": session_id, \"text\": final_text}\nif selected:\n   try:\n       result = qwenpaw_chat(\n           \"Read the local workspace notes if available. Then explain this Colab QwenPaw setup in five bullets and suggest two advanced experiments.\",\n           session_id=\"qwenpaw-colab-demo\",\n       )\n       print(\"\\nFinal session_id:\", result[\"session_id\"])\n   except Exception as e:\n       print(\"\\nAPI demo failed. The Console may still work; inspect the app log below.\")\n       print(\"Error:\", repr(e))\n       try:\n           print(APP_LOG.read_text(encoding=\"utf-8\")[-8000:])\n       except Exception:\n           pass\nelse:\n   print(\n       \"\\nSkipping API chat demo because no model provider key was found.\\n\"\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.\"\n   )\nprint(\"\\nSummary\")\nprint(\"Console username:\", os.environ[\"QWENPAW_AUTH_USERNAME\"])\nprint(\"Console password:\", os.environ[\"QWENPAW_AUTH_PASSWORD\"])\nprint(\"Local URL:\", f\"http://127.0.0.1:{PORT}\")\nif public_url:\n   print(\"Public tunnel:\", public_url)\nprint(\"Workspace:\", WORKSPACE_DIR)\nprint(\"Logs:\", APP_LOG)\nprint(\"\\nTo stop the server manually, run:\")\nprint(f\"import os, signal; os.kill({app_proc.pid}, signal.SIGTERM)\")\n```\n\nWe 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.\n\nIn 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.\n\nCheck out the ** Full Codes with Notebook here. **Also, feel free to follow us on\n\n**and don’t forget to join our**[Twitter](https://x.com/intent/follow?screen_name=marktechpost)\n\n**and Subscribe to**\n\n[150k+ML SubReddit](https://www.reddit.com/r/machinelearningnews/)**. Wait! are you on telegram?**\n\n[our Newsletter](https://www.aidevsignals.com/)\n\n[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)\n\nSana 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.\n\n- Sana Hassan\n- Sana Hassan\n- Sana Hassan\n- Sana Hassan", "url": "https://wpnews.pro/news/how-to-build-a-qwenpaw-agent-workspace-with-custom-skills-model-providers-access", "canonical_source": "https://www.marktechpost.com/2026/06/13/how-to-build-a-qwenpaw-agent-workspace-with-custom-skills-model-providers-console-access-and-streaming-api-testing/", "published_at": "2026-06-13 17:27:22+00:00", "updated_at": "2026-06-13 17:51:25.898029+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "artificial-intelligence", "machine-learning", "large-language-models"], "entities": ["QwenPaw", "Colab", "Cloudflare", "Marktechpost"], "alternates": {"html": "https://wpnews.pro/news/how-to-build-a-qwenpaw-agent-workspace-with-custom-skills-model-providers-access", "markdown": "https://wpnews.pro/news/how-to-build-a-qwenpaw-agent-workspace-with-custom-skills-model-providers-access.md", "text": "https://wpnews.pro/news/how-to-build-a-qwenpaw-agent-workspace-with-custom-skills-model-providers-access.txt", "jsonld": "https://wpnews.pro/news/how-to-build-a-qwenpaw-agent-workspace-with-custom-skills-model-providers-access.jsonld"}}