[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78269KCP0V511YWC1ZN315W":3,"skill-same:01M78269KCP0V511YWC1ZN315W":56},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":38,"ownerHtmlUrl":39,"ownerBlogUrl":6,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M78269KCP0V511YWC1ZN315W","724-office-ai-agent",null,"Self-evolving AI agent system with 26 tools, three-layer memory, MCP plugins, and 24\u002F7 self-repair in pure Python.","Lord1Egypt\u002Fawesome-skill-forge","Lord1Egypt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99746359?v=4","01M7592YDNT0XK9WJ0T2MQVPDN","Mohamed Mounir Ali AL Keshita","01M75GRFNHC8VZNWEB8DKDE433",3,"MIT","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fskills_sh\u002Fs\u002Fskills-sh_aradotso_trending-skills_724-office-ai-agent\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: 724-office-ai-agent\ndescription: Self-evolving AI agent system with 26 tools, three-layer memory, MCP plugins, and 24\u002F7 self-repair in pure Python.\ntriggers:\n  - set up a self-evolving AI agent\n  - add tools to my AI agent at runtime\n  - configure three-layer memory for an agent\n  - connect MCP servers to my agent\n  - schedule recurring tasks with an AI agent\n  - build a 24\u002F7 production AI agent system\n  - integrate WeChat Work with an AI agent\n  - create custom agent tools with a decorator\n---\n\n# 7\u002F24 Office AI Agent System\n\n> Skill by [ara.so](https:\u002F\u002Fara.so) — Daily 2026 Skills collection.\n\nA 24\u002F7 production AI agent in ~3,500 lines of pure Python with no framework dependencies. Features 26 built-in tools, three-layer memory (session + compressed + vector), MCP\u002Fplugin support, runtime tool creation, self-repair diagnostics, and cron scheduling.\n\n## Installation\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fwangziqi06\u002F724-office.git\ncd 724-office\n\n# Only 3 runtime dependencies\npip install croniter lancedb websocket-client\n\n# Optional: WeChat silk audio decoding\npip install pilk\n\n# Set up directories\nmkdir -p workspace\u002Fmemory workspace\u002Ffiles\n\n# Configure\ncp config.example.json config.json\n```\n\n## Configuration (`config.json`)\n\n```json\n{\n  \"models\": {\n    \"default\": {\n      \"api_base\": \"https:\u002F\u002Fapi.openai.com\u002Fv1\",\n      \"api_key\": \"${OPENAI_API_KEY}\",\n      \"model\": \"gpt-4o\",\n      \"max_tokens\": 4096\n    },\n    \"embedding\": {\n      \"api_base\": \"https:\u002F\u002Fapi.openai.com\u002Fv1\",\n      \"api_key\": \"${OPENAI_API_KEY}\",\n      \"model\": \"text-embedding-3-small\"\n    }\n  },\n  \"messaging\": {\n    \"platform\": \"wxwork\",\n    \"corp_id\": \"${WXWORK_CORP_ID}\",\n    \"corp_secret\": \"${WXWORK_CORP_SECRET}\",\n    \"agent_id\": \"${WXWORK_AGENT_ID}\",\n    \"token\": \"${WXWORK_TOKEN}\",\n    \"encoding_aes_key\": \"${WXWORK_AES_KEY}\"\n  },\n  \"memory\": {\n    \"session_max_messages\": 40,\n    \"compression_overlap\": 5,\n    \"dedup_threshold\": 0.92,\n    \"retrieval_top_k\": 5,\n    \"lancedb_path\": \"workspace\u002Fmemory\"\n  },\n  \"asr\": {\n    \"api_base\": \"https:\u002F\u002Fapi.openai.com\u002Fv1\",\n    \"api_key\": \"${OPENAI_API_KEY}\",\n    \"model\": \"whisper-1\"\n  },\n  \"scheduler\": {\n    \"jobs_file\": \"workspace\u002Fjobs.json\",\n    \"timezone\": \"Asia\u002FShanghai\"\n  },\n  \"server\": {\n    \"host\": \"0.0.0.0\",\n    \"port\": 8080\n  },\n  \"workspace\": \"workspace\",\n  \"mcp_servers\": {}\n}\n```\n\nSet environment variables rather than hardcoding secrets:\n\n```bash\nexport OPENAI_API_KEY=\"sk-...\"\nexport WXWORK_CORP_ID=\"...\"\nexport WXWORK_CORP_SECRET=\"...\"\n```\n\n## Running the Agent\n\n```bash\n# Start the HTTP server (listens on :8080 by default)\npython3 xiaowang.py\n\n# Point your messaging platform webhook to:\n# http:\u002F\u002FYOUR_SERVER_IP:8080\u002F\n```\n\n## File Structure\n\n```\n724-office\u002F\n├── xiaowang.py      # Entry point: HTTP server, debounce, ASR, media download\n├── llm.py           # Tool-use loop, session management, memory injection\n├── tools.py         # 26 built-in tools + @tool decorator + plugin loader\n├── memory.py        # Three-layer memory pipeline\n├── scheduler.py     # Cron + one-shot scheduling, jobs.json persistence\n├── mcp_client.py    # JSON-RPC MCP client (stdio + HTTP)\n├── router.py        # Multi-tenant Docker routing\n├── config.py        # Config loading and env interpolation\n└── workspace\u002F\n    ├── memory\u002F      # LanceDB vector store\n    ├── files\u002F       # Agent file storage\n    ├── SOUL.md      # Agent personality\n    ├── AGENT.md     # Operational procedures\n    └── USER.md      # User preferences\u002Fcontext\n```\n\n## Adding a Built-in Tool\n\nTools are registered with the `@tool` decorator in `tools.py`:\n\n```python\nfrom tools import tool\n\n@tool(\n    name=\"fetch_weather\",\n    description=\"Get current weather for a city.\",\n    parameters={\n        \"type\": \"object\",\n        \"properties\": {\n            \"city\": {\n                \"type\": \"string\",\n                \"description\": \"City name, e.g. 'Beijing'\"\n            },\n            \"units\": {\n                \"type\": \"string\",\n                \"enum\": [\"metric\", \"imperial\"],\n                \"default\": \"metric\"\n            }\n        },\n        \"required\": [\"city\"]\n    }\n)\ndef fetch_weather(city: str, units: str = \"metric\") -> str:\n    import urllib.request, json\n    api_key = os.environ[\"OPENWEATHER_API_KEY\"]\n    url = f\"https:\u002F\u002Fapi.openweathermap.org\u002Fdata\u002F2.5\u002Fweather?q={city}&units={units}&appid={api_key}\"\n    with urllib.request.urlopen(url) as r:\n        data = json.loads(r.read())\n    temp = data[\"main\"][\"temp\"]\n    desc = data[\"weather\"][0][\"description\"]\n    return f\"{city}: {temp}°, {desc}\"\n```\n\nThe tool is automatically available to the LLM in the next tool-use loop iteration.\n\n## Runtime Tool Creation (Agent Creates Its Own Tools)\n\nThe agent can call `create_tool` during a conversation to write and load a new Python tool without restarting:\n\n```\nUser: \"Create a tool that converts Markdown to HTML.\"\n\nAgent calls: create_tool({\n  \"name\": \"md_to_html\",\n  \"description\": \"Convert a Markdown string to HTML.\",\n  \"parameters\": { ... },\n  \"code\": \"import markdown\\ndef md_to_html(text): return markdown.markdown(text)\"\n})\n```\n\nThe tool is saved to `workspace\u002Fcustom_tools\u002Fmd_to_html.py` and hot-loaded immediately.\n\n## Connecting an MCP Server\n\nEdit `config.json` to add MCP servers (stdio or HTTP):\n\n```json\n{\n  \"mcp_servers\": {\n    \"filesystem\": {\n      \"transport\": \"stdio\",\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@modelcontextprotocol\u002Fserver-filesystem\", \"\u002Fdata\"]\n    },\n    \"myapi\": {\n      \"transport\": \"http\",\n      \"url\": \"http:\u002F\u002Flocalhost:3000\u002Fmcp\"\n    }\n  }\n}\n```\n\nMCP tools are namespaced as `servername__toolname` (double underscore). Reload without restart:\n\n```\nUser: \"reload MCP servers\"\n# Agent calls: reload_mcp()\n```\n\n## Scheduling Tasks\n\nThe agent uses `schedule` tool internally, but you can also call the scheduler API directly:\n\n```python\nfrom scheduler import Scheduler\nimport json\n\nsched = Scheduler(jobs_file=\"workspace\u002Fjobs.json\", timezone=\"Asia\u002FShanghai\")\n\n# One-shot task (ISO 8601)\nsched.add_job(\n    job_id=\"morning_brief\",\n    trigger=\"2026-04-01T09:00:00\",\n    action={\"type\": \"message\", \"content\": \"Good morning! Here's your daily brief.\"},\n    user_id=\"user_001\"\n)\n\n# Recurring cron task\nsched.add_job(\n    job_id=\"weekly_report\",\n    trigger=\"0 9 * * MON\",          # Every Monday 09:00\n    action={\"type\": \"llm_task\", \"prompt\": \"Generate weekly summary\"},\n    user_id=\"user_001\"\n)\n\nsched.start()\n```\n\nJobs persist in `workspace\u002Fjobs.json` across restarts.\n\n## Three-Layer Memory System\n\n```python\nfrom memory import MemoryManager\n\nmem = MemoryManager(config[\"memory\"])\n\n# Layer 1 — session history (auto-managed, last 40 msgs)\nmem.append_session(user_id=\"u1\", session_id=\"s1\", role=\"user\", content=\"Hello!\")\n\n# Layer 2 — long-term compressed (triggered on session overflow)\n# LLM extracts structured facts; deduped at cosine similarity 0.92\nmem.compress_and_store(user_id=\"u1\", messages=evicted_messages)\n\n# Layer 3 — vector retrieval (injected into system prompt automatically)\nresults = mem.retrieve(user_id=\"u1\", query=\"user's dietary preferences\", top_k=5)\nfor r in results:\n    print(r[\"content\"], r[\"score\"])\n```\n\nThe LLM pipeline in `llm.py` injects retrieved memories automatically before each call:\n\n```python\n# Simplified from llm.py\nrelevant = memory.retrieve(user_id, query=user_message, top_k=5)\nmemory_block = \"\\n\".join(f\"- {m['content']}\" for m in relevant)\nsystem_prompt = base_prompt + f\"\\n\\n## Relevant Memory\\n{memory_block}\"\n```\n\n## Personality Files\n\nCreate these in `workspace\u002F` to shape agent behavior:\n\n**`workspace\u002FSOUL.md`** — Personality and values:\n```markdown\n# Agent Soul\nYou are Xiao Wang, a diligent 24\u002F7 office assistant.\n- Always respond in the user's language\n- Be concise but thorough\n- Proactively suggest next steps\n```\n\n**`workspace\u002FAGENT.md`** — Operational procedures:\n```markdown\n# Operational Guide\n## On Error\n1. Check logs in workspace\u002Flogs\u002F\n2. Run self_check() tool\n3. Notify owner if critical\n\n## Daily Routine\n- 09:00 Morning brief\n- 17:00 EOD summary\n```\n\n**`workspace\u002FUSER.md`** — User context:\n```markdown\n# User Profile\n- Name: Alice\n- Timezone: UTC+8\n- Prefers bullet-point summaries\n- Primary language: English\n```\n\n## Tool-Use Loop (Core LLM Flow)\n\n```python\n# Simplified representation of llm.py's main loop\nasync def run(user_id, session_id, user_message, media=None):\n    messages = memory.get_session(user_id, session_id)\n    messages.append({\"role\": \"user\", \"content\": user_message})\n\n    for iteration in range(20):          # max 20 tool iterations\n        response = await llm_call(\n            model=config[\"models\"][\"default\"],\n            messages=inject_memory(messages, user_id, user_message),\n            tools=tools.get_schema(),    # all 26 + plugins + MCP\n        )\n\n        if response.finish_reason == \"stop\":\n            # Final text reply — send to user\n            return response.content\n\n        if response.finish_reason == \"tool_calls\":\n            for call in response.tool_calls:\n                result = await tools.execute(call.name, call.arguments)\n                messages.append({\n                    \"role\": \"tool\",\n                    \"tool_call_id\": call.id,\n                    \"content\": str(result)\n                })\n            # Loop continues with tool results appended\n```\n\n## Self-Repair and Diagnostics\n\n```python\n# The agent runs self_check() daily via scheduler\n# Or you can trigger it manually:\n\n# Via chat: \"run self-check\"\n# Agent calls: self_check()\n\n# Via chat: \"diagnose the last session\"\n# Agent calls: diagnose(session_id=\"s_20260322_001\")\n```\n\n`self_check` scans:\n- Error logs for exception patterns\n- Session health (response times, tool failures)\n- Memory store integrity\n- Scheduled job status\n\nSends notification via the configured messaging platform if issues are found.\n\n## Multi-Tenant Docker Routing\n\n`router.py` provisions one container per user automatically:\n\n```python\n# router.py handles:\n# POST \u002F with user_id header -> route to user's container\n# If container missing -> docker run 724-office:latest with user env\n# Health-check every 30s -> restart unhealthy containers\n\n# Deploy the router separately:\npython3 router.py  # listens on :80, routes to per-user :8080+N\n```\n\nDocker labels used for discovery:\n```\n724office.user_id=\u003Cuser_id>\n724office.port=\u003Cassigned_port>\n```\n\n## Common Patterns\n\n### Send a proactive message from a scheduled job\n\n```python\n# In a scheduled job action, \"type\": \"message\" sends directly to user\n{\n  \"type\": \"message\",\n  \"content\": \"Your weekly report is ready!\",\n  \"attachments\": [\"workspace\u002Ffiles\u002Freport.pdf\"]\n}\n```\n\n### Search memory semantically\n\n```python\n# Via agent tool call:\nresults = tools.execute(\"search_memory\", {\n    \"query\": \"what did the user say about the Q1 budget?\",\n    \"top_k\": 3\n})\n```\n\n### Execute arbitrary Python in the agent's process\n\n```python\n# exec tool (use carefully — runs in-process)\ntools.execute(\"exec\", {\n    \"code\": \"import psutil; return psutil.virtual_memory().percent\"\n})\n```\n\n### List and manage schedules\n\n```\nUser: \"list all scheduled tasks\"\nAgent calls: list_schedules()\n\nUser: \"cancel the weekly_report job\"\nAgent calls: remove_schedule({\"job_id\": \"weekly_report\"})\n```\n\n## Troubleshooting\n\n| Symptom | Cause | Fix |\n|---|---|---|\n| `ImportError: lancedb` | Missing dependency | `pip install lancedb` |\n| Memory retrieval empty | LanceDB not initialized | Ensure `workspace\u002Fmemory\u002F` exists; send a few messages first |\n| MCP tool not found | Server not connected | Check `config.json` mcp_servers; call `reload_mcp` |\n| Scheduler not firing | Timezone mismatch | Set `scheduler.timezone` in config to your local TZ |\n| Tool loop hits 20 iterations | Runaway tool chain | Add guardrails in `AGENT.md`; check for circular tool calls |\n| WeChat webhook 403 | Token mismatch | Verify `WXWORK_TOKEN` and `WXWORK_AES_KEY` env vars |\n| High RAM on Jetson | LanceDB index size | Reduce `retrieval_top_k`; use local embedding model |\n| `create_tool` not persisting | Wrong workspace path | Confirm `workspace\u002Fcustom_tools\u002F` directory exists and is writable |\n\n## Edge Deployment (Jetson Orin Nano)\n\n```bash\n# ARM64-compatible — no GPU required for core agent\n# Use a local embedding model to avoid cloud latency:\npip install sentence-transformers\n\n# In config.json, point embedding to local model:\n{\n  \"models\": {\n    \"embedding\": {\n      \"type\": \"local\",\n      \"model\": \"BAAI\u002Fbge-small-en-v1.5\"\n    }\n  }\n}\n\n# Keep RAM under 2GB budget:\n# - session_max_messages: 20 (reduce from 40)\n# - retrieval_top_k: 3 (reduce from 5)\n# - Avoid loading large MCP servers\n```\n","# 7\u002F24 Office AI Agent System\n\n> Skill by [ara.so](https:\u002F\u002Fara.so) — Daily 2026 Skills collection.\n\nA 24\u002F7 production AI agent in ~3,500 lines of pure Python with no framework dependencies. Features 26 built-in tools, three-layer memory (session + compressed + vector), MCP\u002Fplugin support, runtime tool creation, self-repair diagnostics, and cron scheduling.\n\n## Installation\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Fwangziqi06\u002F724-office.git\ncd 724-office\n\n# Only 3 runtime dependencies\npip install croniter lancedb websocket-client\n\n# Optional: WeChat silk audio decoding\npip install pilk\n\n# Set up directories\nmkdir -p workspace\u002Fmemory workspace\u002Ffiles\n\n# Configure\ncp config.example.json config.json\n```\n\n## Configuration (`config.json`)\n\n```json\n{\n  \"models\": {\n    \"default\": {\n      \"api_base\": \"https:\u002F\u002Fapi.openai.com\u002Fv1\",\n      \"api_key\": \"${OPENAI_API_KEY}\",\n      \"model\": \"gpt-4o\",\n      \"max_tokens\": 4096\n    },\n    \"embedding\": {\n      \"api_base\": \"https:\u002F\u002Fapi.openai.com\u002Fv1\",\n      \"api_key\": \"${OPENAI_API_KEY}\",\n      \"model\": \"text-embedding-3-small\"\n    }\n  },\n  \"messaging\": {\n    \"platform\": \"wxwork\",\n    \"corp_id\": \"${WXWORK_CORP_ID}\",\n    \"corp_secret\": \"${WXWORK_CORP_SECRET}\",\n    \"agent_id\": \"${WXWORK_AGENT_ID}\",\n    \"token\": \"${WXWORK_TOKEN}\",\n    \"encoding_aes_key\": \"${WXWORK_AES_KEY}\"\n  },\n  \"memory\": {\n    \"session_max_messages\": 40,\n    \"compression_overlap\": 5,\n    \"dedup_threshold\": 0.92,\n    \"retrieval_top_k\": 5,\n    \"lancedb_path\": \"workspace\u002Fmemory\"\n  },\n  \"asr\": {\n    \"api_base\": \"https:\u002F\u002Fapi.openai.com\u002Fv1\",\n    \"api_key\": \"${OPENAI_API_KEY}\",\n    \"model\": \"whisper-1\"\n  },\n  \"scheduler\": {\n    \"jobs_file\": \"workspace\u002Fjobs.json\",\n    \"timezone\": \"Asia\u002FShanghai\"\n  },\n  \"server\": {\n    \"host\": \"0.0.0.0\",\n    \"port\": 8080\n  },\n  \"workspace\": \"workspace\",\n  \"mcp_servers\": {}\n}\n```\n\nSet environment variables rather than hardcoding secrets:\n\n```bash\nexport OPENAI_API_KEY=\"sk-...\"\nexport WXWORK_CORP_ID=\"...\"\nexport WXWORK_CORP_SECRET=\"...\"\n```\n\n## Running the Agent\n\n```bash\n# Start the HTTP server (listens on :8080 by default)\npython3 xiaowang.py\n\n# Point your messaging platform webhook to:\n# http:\u002F\u002FYOUR_SERVER_IP:8080\u002F\n```\n\n## File Structure\n\n```\n724-office\u002F\n├── xiaowang.py      # Entry point: HTTP server, debounce, ASR, media download\n├── llm.py           # Tool-use loop, session management, memory injection\n├── tools.py         # 26 built-in tools + @tool decorator + plugin loader\n├── memory.py        # Three-layer memory pipeline\n├── scheduler.py     # Cron + one-shot scheduling, jobs.json persistence\n├── mcp_client.py    # JSON-RPC MCP client (stdio + HTTP)\n├── router.py        # Multi-tenant Docker routing\n├── config.py        # Config loading and env interpolation\n└── workspace\u002F\n    ├── memory\u002F      # LanceDB vector store\n    ├── files\u002F       # Agent file storage\n    ├── SOUL.md      # Agent personality\n    ├── AGENT.md     # Operational procedures\n    └── USER.md      # User preferences\u002Fcontext\n```\n\n## Adding a Built-in Tool\n\nTools are registered with the `@tool` decorator in `tools.py`:\n\n```python\nfrom tools import tool\n\n@tool(\n    name=\"fetch_weather\",\n    description=\"Get current weather for a city.\",\n    parameters={\n        \"type\": \"object\",\n        \"properties\": {\n            \"city\": {\n                \"type\": \"string\",\n                \"description\": \"City name, e.g. 'Beijing'\"\n            },\n            \"units\": {\n                \"type\": \"string\",\n                \"enum\": [\"metric\", \"imperial\"],\n                \"default\": \"metric\"\n            }\n        },\n        \"required\": [\"city\"]\n    }\n)\ndef fetch_weather(city: str, units: str = \"metric\") -> str:\n    import urllib.request, json\n    api_key = os.environ[\"OPENWEATHER_API_KEY\"]\n    url = f\"https:\u002F\u002Fapi.openweathermap.org\u002Fdata\u002F2.5\u002Fweather?q={city}&units={units}&appid={api_key}\"\n    with urllib.request.urlopen(url) as r:\n        data = json.loads(r.read())\n    temp = data[\"main\"][\"temp\"]\n    desc = data[\"weather\"][0][\"description\"]\n    return f\"{city}: {temp}°, {desc}\"\n```\n\nThe tool is automatically available to the LLM in the next tool-use loop iteration.\n\n## Runtime Tool Creation (Agent Creates Its Own Tools)\n\nThe agent can call `create_tool` during a conversation to write and load a new Python tool without restarting:\n\n```\nUser: \"Create a tool that converts Markdown to HTML.\"\n\nAgent calls: create_tool({\n  \"name\": \"md_to_html\",\n  \"description\": \"Convert a Markdown string to HTML.\",\n  \"parameters\": { ... },\n  \"code\": \"import markdown\\ndef md_to_html(text): return markdown.markdown(text)\"\n})\n```\n\nThe tool is saved to `workspace\u002Fcustom_tools\u002Fmd_to_html.py` and hot-loaded immediately.\n\n## Connecting an MCP Server\n\nEdit `config.json` to add MCP servers (stdio or HTTP):\n\n```json\n{\n  \"mcp_servers\": {\n    \"filesystem\": {\n      \"transport\": \"stdio\",\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@modelcontextprotocol\u002Fserver-filesystem\", \"\u002Fdata\"]\n    },\n    \"myapi\": {\n      \"transport\": \"http\",\n      \"url\": \"http:\u002F\u002Flocalhost:3000\u002Fmcp\"\n    }\n  }\n}\n```\n\nMCP tools are namespaced as `servername__toolname` (double underscore). Reload without restart:\n\n```\nUser: \"reload MCP servers\"\n# Agent calls: reload_mcp()\n```\n\n## Scheduling Tasks\n\nThe agent uses `schedule` tool internally, but you can also call the scheduler API directly:\n\n```python\nfrom scheduler import Scheduler\nimport json\n\nsched = Scheduler(jobs_file=\"workspace\u002Fjobs.json\", timezone=\"Asia\u002FShanghai\")\n\n# One-shot task (ISO 8601)\nsched.add_job(\n    job_id=\"morning_brief\",\n    trigger=\"2026-04-01T09:00:00\",\n    action={\"type\": \"message\", \"content\": \"Good morning! Here's your daily brief.\"},\n    user_id=\"user_001\"\n)\n\n# Recurring cron task\nsched.add_job(\n    job_id=\"weekly_report\",\n    trigger=\"0 9 * * MON\",          # Every Monday 09:00\n    action={\"type\": \"llm_task\", \"prompt\": \"Generate weekly summary\"},\n    user_id=\"user_001\"\n)\n\nsched.start()\n```\n\nJobs persist in `workspace\u002Fjobs.json` across restarts.\n\n## Three-Layer Memory System\n\n```python\nfrom memory import MemoryManager\n\nmem = MemoryManager(config[\"memory\"])\n\n# Layer 1 — session history (auto-managed, last 40 msgs)\nmem.append_session(user_id=\"u1\", session_id=\"s1\", role=\"user\", content=\"Hello!\")\n\n# Layer 2 — long-term compressed (triggered on session overflow)\n# LLM extracts structured facts; deduped at cosine similarity 0.92\nmem.compress_and_store(user_id=\"u1\", messages=evicted_messages)\n\n# Layer 3 — vector retrieval (injected into system prompt automatically)\nresults = mem.retrieve(user_id=\"u1\", query=\"user's dietary preferences\", top_k=5)\nfor r in results:\n    print(r[\"content\"], r[\"score\"])\n```\n\nThe LLM pipeline in `llm.py` injects retrieved memories automatically before each call:\n\n```python\n# Simplified from llm.py\nrelevant = memory.retrieve(user_id, query=user_message, top_k=5)\nmemory_block = \"\\n\".join(f\"- {m['content']}\" for m in relevant)\nsystem_prompt = base_prompt + f\"\\n\\n## Relevant Memory\\n{memory_block}\"\n```\n\n## Personality Files\n\nCreate these in `workspace\u002F` to shape agent behavior:\n\n**`workspace\u002FSOUL.md`** — Personality and values:\n```markdown\n# Agent Soul\nYou are Xiao Wang, a diligent 24\u002F7 office assistant.\n- Always respond in the user's language\n- Be concise but thorough\n- Proactively suggest next steps\n```\n\n**`workspace\u002FAGENT.md`** — Operational procedures:\n```markdown\n# Operational Guide\n## On Error\n1. Check logs in workspace\u002Flogs\u002F\n2. Run self_check() tool\n3. Notify owner if critical\n\n## Daily Routine\n- 09:00 Morning brief\n- 17:00 EOD summary\n```\n\n**`workspace\u002FUSER.md`** — User context:\n```markdown\n# User Profile\n- Name: Alice\n- Timezone: UTC+8\n- Prefers bullet-point summaries\n- Primary language: English\n```\n\n## Tool-Use Loop (Core LLM Flow)\n\n```python\n# Simplified representation of llm.py's main loop\nasync def run(user_id, session_id, user_message, media=None):\n    messages = memory.get_session(user_id, session_id)\n    messages.append({\"role\": \"user\", \"content\": user_message})\n\n    for iteration in range(20):          # max 20 tool iterations\n        response = await llm_call(\n            model=config[\"models\"][\"default\"],\n            messages=inject_memory(messages, user_id, user_message),\n            tools=tools.get_schema(),    # all 26 + plugins + MCP\n        )\n\n        if response.finish_reason == \"stop\":\n            # Final text reply — send to user\n            return response.content\n\n        if response.finish_reason == \"tool_calls\":\n            for call in response.tool_calls:\n                result = await tools.execute(call.name, call.arguments)\n                messages.append({\n                    \"role\": \"tool\",\n                    \"tool_call_id\": call.id,\n                    \"content\": str(result)\n                })\n            # Loop continues with tool results appended\n```\n\n## Self-Repair and Diagnostics\n\n```python\n# The agent runs self_check() daily via scheduler\n# Or you can trigger it manually:\n\n# Via chat: \"run self-check\"\n# Agent calls: self_check()\n\n# Via chat: \"diagnose the last session\"\n# Agent calls: diagnose(session_id=\"s_20260322_001\")\n```\n\n`self_check` scans:\n- Error logs for exception patterns\n- Session health (response times, tool failures)\n- Memory store integrity\n- Scheduled job status\n\nSends notification via the configured messaging platform if issues are found.\n\n## Multi-Tenant Docker Routing\n\n`router.py` provisions one container per user automatically:\n\n```python\n# router.py handles:\n# POST \u002F with user_id header -> route to user's container\n# If container missing -> docker run 724-office:latest with user env\n# Health-check every 30s -> restart unhealthy containers\n\n# Deploy the router separately:\npython3 router.py  # listens on :80, routes to per-user :8080+N\n```\n\nDocker labels used for discovery:\n```\n724office.user_id=\u003Cuser_id>\n724office.port=\u003Cassigned_port>\n```\n\n## Common Patterns\n\n### Send a proactive message from a scheduled job\n\n```python\n# In a scheduled job action, \"type\": \"message\" sends directly to user\n{\n  \"type\": \"message\",\n  \"content\": \"Your weekly report is ready!\",\n  \"attachments\": [\"workspace\u002Ffiles\u002Freport.pdf\"]\n}\n```\n\n### Search memory semantically\n\n```python\n# Via agent tool call:\nresults = tools.execute(\"search_memory\", {\n    \"query\": \"what did the user say about the Q1 budget?\",\n    \"top_k\": 3\n})\n```\n\n### Execute arbitrary Python in the agent's process\n\n```python\n# exec tool (use carefully — runs in-process)\ntools.execute(\"exec\", {\n    \"code\": \"import psutil; return psutil.virtual_memory().percent\"\n})\n```\n\n### List and manage schedules\n\n```\nUser: \"list all scheduled tasks\"\nAgent calls: list_schedules()\n\nUser: \"cancel the weekly_report job\"\nAgent calls: remove_schedule({\"job_id\": \"weekly_report\"})\n```\n\n## Troubleshooting\n\n| Symptom | Cause | Fix |\n|---|---|---|\n| `ImportError: lancedb` | Missing dependency | `pip install lancedb` |\n| Memory retrieval empty | LanceDB not initialized | Ensure `workspace\u002Fmemory\u002F` exists; send a few messages first |\n| MCP tool not found | Server not connected | Check `config.json` mcp_servers; call `reload_mcp` |\n| Scheduler not firing | Timezone mismatch | Set `scheduler.timezone` in config to your local TZ |\n| Tool loop hits 20 iterations | Runaway tool chain | Add guardrails in `AGENT.md`; check for circular tool calls |\n| WeChat webhook 403 | Token mismatch | Verify `WXWORK_TOKEN` and `WXWORK_AES_KEY` env vars |\n| High RAM on Jetson | LanceDB index size | Reduce `retrieval_top_k`; use local embedding model |\n| `create_tool` not persisting | Wrong workspace path | Confirm `workspace\u002Fcustom_tools\u002F` directory exists and is writable |\n\n## Edge Deployment (Jetson Orin Nano)\n\n```bash\n# ARM64-compatible — no GPU required for core agent\n# Use a local embedding model to avoid cloud latency:\npip install sentence-transformers\n\n# In config.json, point embedding to local model:\n{\n  \"models\": {\n    \"embedding\": {\n      \"type\": \"local\",\n      \"model\": \"BAAI\u002Fbge-small-en-v1.5\"\n    }\n  }\n}\n\n# Keep RAM under 2GB budget:\n# - session_max_messages: 20 (reduce from 40)\n# - retrieval_top_k: 3 (reduce from 5)\n# - Avoid loading large MCP servers\n```\n",{"name":5,"triggers":24,"description":7},[25,26,27,28,29,30,31,32],"set up a self-evolving AI agent","add tools to my AI agent at runtime","configure three-layer memory for an agent","connect MCP servers to my agent","schedule recurring tasks with an AI agent","build a 24\u002F7 production AI agent system","integrate WeChat Work with an AI agent","create custom agent tools with a decorator","master","4aa004da461d820f4ea5499e58eb8d196cf99016","community\u002Fskills_sh\u002Fs\u002Fskills-sh_aradotso_trending-skills_724-office-ai-agent",0,"https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge","https:\u002F\u002Fskill-explorer-rho.vercel.app","https:\u002F\u002Fgithub.com\u002FLord1Egypt","Unbreakable. Unstoppable. Unmatched⚡.\r\n Speaker of machine tongues 🤖  | World-builder of decentralized dreams 🌐 | Defender of the digital realm🛡️.","2026-06-10 08:21:01",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add Lord1Egypt\u002Fawesome-skill-forge --skill 724-office-ai-agent",{"tool":48,"command":49},"bunx","bunx skills add Lord1Egypt\u002Fawesome-skill-forge --skill 724-office-ai-agent",{"tool":51,"command":52},"pnpm","pnpm dlx skills add Lord1Egypt\u002Fawesome-skill-forge --skill 724-office-ai-agent","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fcommunity\u002Fskills_sh\u002Fs\u002Fskills-sh_aradotso_trending-skills_724-office-ai-agent\u002FSKILL.md",true,[],[57,64,71,78,85,92],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M785WKJB99G3STR1NF9NRTJW","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M785WEFHB0G2S9YA6EPR3H0E","xurl","X\u002FTwitter via xurl CLI: post, search, DM, media, v2 API.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M785W98EDN4EFJXJPMQEHCRC","touchdesigner-mcp","Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M785W5S9FP3QBH2V191E025P","test-driven-development","TDD: enforce RED-GREEN-REFACTOR, tests before code.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M785W2AS08NSSH9YATCV6FJB","teams-meeting-pipeline","Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fteams-meeting-pipeline\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":19},"01M785VXKW4T34BTP1SCHW1R7F","systematic-debugging","4-phase root cause debugging: understand bugs before fixing.","https:\u002F\u002Fgithub.com\u002FLord1Egypt\u002Fawesome-skill-forge\u002Fblob\u002Fmaster\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[]]