Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinUpdate Agent

LLM-powered Windows Update governance — control Windows Update with natural language.

🇨🇳 中文

⚠️ Using action="disable" WILL break Microsoft Store. The four services this tool manages are shared infrastructure — disabling kills the Store too. Use action="pause" instead to safely stop automatic updates while keeping the Store working. This is by Windows design, not a bug.


The Problem

Windows Update can be a headache:

  • Microsoft Store suddenly stops working (error 0x80070422), or gets stuck loading
  • Automatic updates force a reboot countdown during meetings or gaming sessions
  • Online "disable updates" tutorials tell you to manually fiddle with services, registry, and Task Scheduler — one wrong click and things break worse

The root cause is often the WUB (Windows Update Blocker) pattern — a service or scheduled task gets disabled by accident, triggering a chain reaction that kills both the Store and Windows Update.

WinUpdate Agent wraps all of this into an LLM Agent. Tell it what you want in plain language, and it decides which services to enable or disable, executes the changes, and reports back every step.


⚠️ Side Effects of Controlling Updates

Windows Update and Microsoft Store share the same underlying services (wuauserv, UsoSvc, BITS, WaaSMedicSvc).

This tool provides three action modes so you can choose the right level of control:

action="pause" — Safe Pause ✅ (Recommended)

  • Stops services but keeps them at Manual start type
  • Microsoft Store still works — it can start services on demand
  • Disables scheduled tasks + sets NoAutoUpdate=1 policy
  • After reboot: no automatic updates

action="disable" — Full Disable ⚠️

  • Sets services to Disabled (cannot be started by anything)
  • ❌ Microsoft Store will be unable to download or update apps
  • ❌ Some UWP apps (Xbox, OneDrive, etc.) may stop functioning
  • ❌ The system will no longer receive security patches

action="enable" — Restore ✅

  • Restores services to their original startup type
  • Enables scheduled tasks + removes NoAutoUpdate policy
  • Verifies all services are back to normal

To stop updates without breaking the Store, always use action="pause".


How It Works

You say: "Pause Windows Update for now, but I still need the Store"
        │
        ▼
   FastAPI POST /api/chat
        │
        ▼
   ChatOpenAI (GPT-4o-mini / any OpenAI-compatible API)
        │  Understands intent → decides to PAUSE (not disable!)
        ▼
   AgentExecutor calls windows_update_control(action="pause")
        │
        ├─ Backs up original service states
        ├─ Stops 4 services (keeps Manual start type — Store still works!)
        ├─ Disables scheduled tasks
        ├─ Sets NoAutoUpdate=1 registry policy
        └─ Verifies all services are in expected state
        │
        ▼
   Returns step-by-step results + Agent's natural-language explanation

The core tool windows_update_control mirrors the thoroughness of WUB (Windows Update Blocker) but adds safety — it doesn't just toggle services; it also handles scheduled tasks, registry policies, and verifies state so Windows can't silently revert your changes or leave your system in a broken state.


Project Structure

WinUpdate Agent/
├── main.py             # FastAPI entry point, Agent orchestration
├── tools.py            # LangChain @tool definitions
├── requirements.txt
├── .env.example        # Environment template (safe to commit)
├── .gitignore
├── README.md           # English documentation
└── README_zh.md        # 中文文档

Quick Start

Requirements

  • Windows 10 / 11 (uses pywin32 + schtasks)
  • Python 3.10+
  • An OpenAI-compatible API key (official, proxy, or local Ollama/vLLM)

1. Clone & Install

git clone https://github.com/FrostLeafKEE/WinUpdate-Agent.git
cd "WinUpdate Agent"

python -m venv venv
venv\Scripts\activate        # Windows

pip install -r requirements.txt

2. Configure API Key

copy .env.example .env      # Windows

Edit .env:

OPENAI_API_KEY=sk-your-real-key-here

Using a local model (Ollama/vLLM)? Set OPENAI_BASE_URL to your local endpoint — OPENAI_API_KEY can be any non-empty value.

3. Launch

⚠️ MUST run as Administrator

This program modifies Windows service startup types and starts/stops services via the Service Control Manager. Without admin privileges, every operation will fail.

Win+X → Terminal (Admin) / PowerShell (Admin)

cd "WinUpdate Agent"
venv\Scripts\activate
python main.py

Successful startup:

==========================================================
  WinUpdate Agent — Windows 系统治理服务
==========================================================
  LLM Model: gpt-4o-mini
  Tools loaded: 4

  Visit:
    http://127.0.0.1:8000/docs          — Swagger UI
    http://127.0.0.1:8000/api/chat      — Chat endpoint (POST)
==========================================================

API Reference

POST /api/chat — Chat

Request:

{
  "message": "Microsoft Store won't open, fix it for me"
}

Response:

{
  "success": true,
  "reply": "I'll restore your Windows Update services now…",
  "tools_used": ["windows_update_control"],
  "thinking": [
    {
      "step": 1,
      "phase": "reasoning",
      "detail": "Decided to call: windows_update_control\nParams: {'action': 'enable'}…"
    },
    {
      "step": 1,
      "phase": "tool_result",
      "detail": "Tool returned: …"
    }
  ]
}
Field Description
success Whether the request was handled successfully
reply Agent's final natural-language response
tools_used Names of tools called during this request
thinking Full reasoning chain: reasoning = LLM decision, tool_result = tool output

GET /health — Health Check

{
  "status": "ok",
  "model": "gpt-4o-mini",
  "tools_available": ["windows_update_control", "list_services", "get_service_status", "check_windows_update_services"]
}

GET /tools — Tool List

Returns all registered tools with descriptions.


Built-in Tools

| Tool | Function | Parameters | |---|---|---|---| | windows_update_control | Core: pause, disable, or restore WU services + scheduled tasks + registry | action: str ("pause"/"disable"/"enable") | | check_windows_update_services | Batch check status of all 4 WU services | — | | get_service_status | Query a single service's details | service_name: str | | list_services | Enumerate/search Windows services | keyword?: str |

windows_update_control Behavior

Mode Services Scheduled Tasks Registry Store
action="pause" → Manual → Stop schtasks /disable NoAutoUpdate=1 ✅ Works
action="disable" → Disabled → Stop schtasks /disable NoAutoUpdate=1 ❌ Broken
action="enable" → Original type → Start schtasks /enable Delete NoAutoUpdate ✅ Works

All modes include state verification after execution. Only these four core services are touched — other system services are unaffected.


Examples

# Microsoft Store not working
curl -X POST http://127.0.0.1:8000/api/chat \
  -H "Content-Type: application/json" \
  -d '{"message":"Microsoft Store is stuck loading, fix it"}'

# Completely disable automatic updates
curl -X POST http://127.0.0.1:8000/api/chat \
  -H "Content-Type: application/json" \
  -d '{"message":"Disable Windows Update completely"}'

# Check current status first
curl -X POST http://127.0.0.1:8000/api/chat \
  -H "Content-Type: application/json" \
  -d '{"message":"Check the status of all Windows Update services"}'

Environment Variables

Variable Required Default Description
OPENAI_API_KEY Yes — LLM API key; use any value for local models
OPENAI_BASE_URL No https://api.openai.com/v1 API endpoint; Ollama/vLLM/proxy supported
MODEL_NAME No gpt-4o-mini Model, e.g. gpt-4o, qwen2.5, llama3

Edit .env directly — loaded automatically at startup.


Tech Stack

Layer Choice
Web Framework FastAPI
LLM Orchestration LangChain (create_tool_calling_agent + AgentExecutor)
LLM Backend ChatOpenAI (any OpenAI-format API)
System Calls pywin32 + subprocess (schtasks)
Config Management python-dotenv

License

MIT

About

一个轻量级 Windows 自动更新智能拦截与治理 AI Agent。

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages