### 问题现象 同一 agent 开多个并发会话时(如 A1=查南京天气、A2=查北京天气),A2 在多轮 ReAct 执行中会"突然去查南京天气",表现为 A1 会话的上下文泄漏到 A2 会话。 ### 根因4:Agent 实例共享 + state 覆盖(确认,仅状态显示问题) 确认点: - AgentService.java:83-90 agentInstances 按 (agentId, modelKey) 缓存,不含 conversationId - AgentService.java:598-624 getOrBuildAgentForConversation 只按 (agentId, provider, model) 解析,不按 conversationId - AgentService.java:530-545 withLifecycleFlux 无锁 ,A/B/C 完全并发 影响: A 完成设 IDLE → B 仍在运行但显示 IDLE → 状态显示错乱。 不会直接导致记忆串台 ,但对用户可见。 ## 二、根因与症状匹配度总结 根因 匹配度 触发条件 串台通道 1. SessionSearchTool ★★★★★ LLM 多轮遇到困难时主动调用 session_search 返回并发兄弟会话消息 2. 审批重放无过滤 ★★★☆☆ Plan-Execute + 审批 + 并发 awaiting_approval 误取兄弟会话计划 3. 结构化记忆共享 ★★★☆☆ A 会话 LLM 主动 remember_structured 写入 prefetch 注入到 B 会话 4. Agent 实例共享 ★★☆☆☆ 任意并发 state 显示错乱(非记忆串台) 用户描述的"B突然去查南京天气"最可能是根因1 ——因为 system prompt 明确引导 LLM 在遇到困难时用 session_search 回忆历史,而 SQL 会返回并发兄弟会话的"南京天气"内容。 ## 三、修复方案(按优先级排序) ### 方案1:修复 SessionSearchTool(最优先,直接命中症状) 改动点 A — SessionSearchTool 增加 ToolContext 参数,强制读取真实 conversationId: SessionSearchTool.java:37-44 改动点 B — SessionSearchService 增加运行状态过滤,排除并发兄弟会话: SessionSearchService.java:60-73 SQL 增加: 或更保守:只返回 status = 'completed' 的会话,排除 running / awaiting_approval 的并发会话。 风险评估: 改动 SQL 查询条件,不影响写入逻辑。 completed 会话才是真正的"历史对话", running 会话是"正在进行"不应被搜索。功能上合理。 ### 方案2:修复审批重放跨会话取计划(确凿 bug,必须修) 改动点 A — PlanningService.findAwaitingApprovalContext 增加 conversationId 参数: PlanningService.java:228-232 改动点 B — 调用方传入 conversationId: StateGraphPlanExecuteAgent.java:100 风险评估: 需确认 PlanEntity 有 conversationId 字段(从之前排查看应存在)。改动最小,仅加查询过滤,不影响其他逻辑。 ### 方案3:结构化记忆引入会话级隔离(改动较大,需评估) 问题: 当前 ownerKey = user:<requesterId> ,3 会话共享。如果改为 conversation:<conversationId> ,会破坏"用户长期记忆跨会话共享"的设计意图(用户画像、偏好等应跨会话)。 建议方案: 不改 ownerKey 机制,而是在 StructuredMemoryTool.remember_structured 的 system prompt 说明中 明确限制 只记住"长期有效的事实",临时任务结果(如天气查询)不应写入。或在 type 枚举中新增 transient 类型,该类型按 conversationId 隔离,会话结束自动清除。 风险评估: 改动较大,涉及记忆分层设计。建议作为中长期优化,本次先修方案1和2。 ### 方案4:Agent 实例 state 按 conversationId 隔离(可选) 改动点: BaseAgent.java:33 AtomicReference<AgentState> state 改为 Map<String, AtomicReference<AgentState>> (按 conversationId)。 风险评估: 影响所有 getState() / setState() 调用点,改动面广。且这只是状态显示问题,不影响记忆串台。建议暂不修,或在前端按 conversationId 单独查询状态。 -------------------------------------------- 本次完成bug1、2修复;3、4未动 |
||
|---|---|---|
| .github/ISSUE_TEMPLATE | ||
| assets | ||
| docker/searxng | ||
| docs | ||
| mateclaw-desktop | ||
| mateclaw-plugin-api | ||
| mateclaw-plugin-sample | ||
| mateclaw-server | ||
| mateclaw-ui | ||
| mateclaw-webchat | ||
| rfcs | ||
| .dockerignore | ||
| .env.example | ||
| .gitignore | ||
| docker-compose.yml | ||
| LICENSE | ||
| pom.xml | ||
| README_zh.md | ||
| README.md | ||
MateClaw
Your second brain
Agent Harness · Spring Boot inside · One JAR to ship
[Website] [Live Demo] [Documentation] [中文]
Other personal AI agents are built for one person. MateClaw is the one your IT department can actually sign off on.
Multi-user workspaces. Approval-gated sensitive actions. Full audit trail. Spring Boot Actuator health monitoring. Per-channel error isolation so one chat platform's outage doesn't take down the rest. One JAR on your own machine, zero data egress.
And underneath, a real agent harness. ReAct + Plan-and-Execute on a StateGraph runtime — not a one-shot RAG call dressed up. Tools, Skills, MCP, and ACP converge on one registry with per-employee binding. Sensitive tool calls flow through an approval gate you can actually inspect. Multi-vendor failover keeps the loop running when a provider doesn't.
Most AI tools die when their vendor has a bad day. Most forget you the moment the tab closes. Most give you a chatbox and call it a product.
MateClaw is the whole widget. One deployment. Reasoning, knowledge, memory, tools, channels — built together, not bolted on. And when your primary model goes down, the next one picks up mid-sentence.
Three things that make it different
1 · Your AI doesn't die when a model does
Primary key expired. Vendor returns 401. Network blip. Quota drained.
Other tools hand you a red error card. MateClaw routes to the next healthy provider — DashScope, OpenAI, Anthropic, Gemini, DeepSeek, Kimi, Ollama, LM Studio, MLX, 14+ in total — and the user sees the reply finish. A provider health tracker parks bad vendors in a cooldown window so they don't waste seconds on every turn.
You don't write a retry script. You drag providers into priority order in Settings → Models and watch the health dashboard fill with green dots as requests route around failures in real time.
2 · Knowledge that links itself
Upload a PDF, a batch of markdown, a scraped page — raw material in.
MateClaw's LLM Wiki digests it into structured pages, builds [[links]] between them, and remembers where every sentence came from. Click a citation, see the exact source chunk. Ask a question, the page you get is stitched from the right chunks — with references you can verify.
This is the difference between a warehouse and a library.
3 · One product, five surfaces
| Surface | What it is |
|---|---|
| Web Console | Full admin — digital employees, models, skills, knowledge, security, cron, runtime console (see what every employee is doing, force-recycle in one click) |
| Desktop | Electron app with a bundled JRE 21. Double-click, run. No Java install |
| Webchat Widget | One <script> tag embed. Drop it on any site |
| IM Channels | DingTalk · Feishu · WeChat Work · WeChat · Telegram · Discord · QQ · Slack |
| Plugin SDK | Java module for third-party capability packs |
Same brain. Same memory. Same tools. Different doors.
$0 · No tokens metered. No seats billed. Your server. Your data. Your keys.
What's in the box
Digital employees, not chatbots
You hire coworkers, not chat boxes. Each one has a Role, a Goal, a Backstory, a pixel-art avatar, and a color of their own — five career templates ship ready (Product Researcher · Customer Support · Knowledge Curator · Data Analyst · Executive Assistant). ReAct drives iterative reasoning, Plan-and-Execute decomposes complex multi-step work, employees can delegate to one another in parallel. Dynamic context pruning, smart truncation, stale-stream cleanup — the boring stuff that makes long conversations actually work.
Knowledge & memory
- LLM Wiki — raw materials digest into linked pages with citations; the hot cache auto-injects into every employee's system prompt. Transformations engine (1.3.0+) turns the Wiki from a search index into a processing pipeline
- Workspace memory —
AGENTS.md,SOUL.md,PROFILE.md,MEMORY.md, daily notes - Memory lifecycle — post-conversation extraction, scheduled consolidation, Dreaming workflows. Workflows can also write directly into an employee's
MEMORY.mdvia thewrite_memorystep
Skills · MCP · ACP — three ways to extend capability
- SKILL.md packages — manifest + prompt + tool list + LESSONS.md (gets smarter the more you use it). Eight starter templates plus a five-step creation wizard, with Pre-flight checks that tell you what's missing before install
- MCP — stdio / SSE / Streamable HTTP, plug into any external tool server. Per-employee binding (1.3.0+) means a tool you install for one employee doesn't bleed into another's toolbox
- ACP — bring top-tier coding agents like Claude Code and Codex in as employees, auto-bridged to skill cards with wrapper tools
- Tool Guard — RBAC + approval flow + path protection. Capability needs boundaries
Business orchestration (1.3.0+)
- Workflow — compose multiple employees plus system actions (approval / channel dispatch / write-memory) into a publishable, triggerable, replayable linear DSL. Seven step modes (
sequential/fan_out/collect/conditional/await_approval/dispatch_channel/write_memory). JSON-first authoring with Monaco + schema validation, or natural-language → draft generation - Triggers — wire system events to workflows or to employee conversations. Six pattern types (
cron/webhook/channel_message/agent_lifecycle/content_match/workflow_completion). Default-on event governance: dedup, per-trigger rate limit, bot-self filter, recursion guard, fail-closed unknown patterns - Wiki Transformations — Wiki stops being retrieval-only. User-authored templates run against raw materials or existing pages, with cross-material map-reduce aggregation, reverse-citation extraction, JSON output mode, and per-template model picker
You see what every employee is doing
Admin Runtime Console (Settings → System → Runtime) — who's running, what step they're on, how many tokens, one-click force-recycle when stuck. Streaming is staged honestly (thinking / tool / answer), per-event SSE IDs make reconnects safe, multi-employee delegation no longer fights itself, long tasks demand evidence-grounded answers.
Multimodal creation
Text-to-speech · Speech-to-text · Image · Music · Video · 3D. First-class, not add-ons. Sidecar routing (1.3.0+) means a text-only main model + an image attachment no longer dead-ends — a configured vision model describes the image, and the main model answers. Image edit lands too: refer to an earlier conversation attachment by msg:<id>:<idx> and ask the model to recolor or restyle it. Four document-generation tools (DocxRenderTool / XlsxRenderTool / PptxRenderTool / PdfRenderTool) render Markdown straight to Office files inside the JVM — no subprocess, no Office install.
Enterprise-ready
RBAC + JWT. Personal Access Tokens for headless scripts and CI. HMAC-SHA-256 outbound webhook signing. Distributed Cron lock so multi-instance deployments don't double-fire. Full audit trail. Flyway-managed schema that auto-heals on upgrade. One JAR to ship. MySQL in production, H2 for dev — nothing to change in your code.
AI is becoming infrastructure
On March 2, 2026, Claude went dark for 4 hours across API, web, and mobile. Three weeks later, another 5 hours. Every company that bet their AI strategy on a single vendor spent those outages staring at red error cards.
This is the same shift databases went through around 2010 and cloud went through around 2018: the winning layer stops being tied to one supplier. 57% of companies now run AI agents in production. None of them want one vendor's bad day to become their bad day.
MateClaw is that layer — built the Spring Boot way.
Why MateClaw
| MateClaw | OpenClaw | Hermes Agent | Claude Code | Cursor | |
|---|---|---|---|---|---|
| Multi-vendor failover | Chain + health tracker + cooldown | Swap providers via config | Orchestration w/ retry | Anthropic only | One model |
| Knowledge digestion | LLM Wiki + page-level citations | Canvas + memory | Skills Hub + memory | — | Code index |
| Multi-user admin | RBAC + approval + audit + runtime console | Config-file first | Single-user CLI | Enterprise tier | Teams plan |
| Capability extension | Skills (LESSONS) + MCP + ACP | — | — | MCP | MCP |
| Surfaces | Web admin + Desktop + Widget + SDK + 8 IM | 25+ chat channels | 15+ channels (CLI-led) | 3 IM preview | IDE only |
| Stack | Java (Spring Boot) | TypeScript | Python | TypeScript | Electron/TS |
| License / Price | Apache 2.0 · Free | MIT · Free | MIT · Free | Proprietary · $20–200/mo | Proprietary · $0–200/mo |
OpenClaw and Hermes Agent are excellent personal AI platforms — pick either if you're running one user on one laptop, building your own agent from CLI, and treating everything as config files to hand-tune. Both have bigger communities than MateClaw today.
MateClaw is the version built for teams. RBAC per digital employee, per model, per tool. An approval flow that pauses risky actions for review. Full audit trail. The Admin Runtime Console gives one operator real-time visibility into 50 employees running across 14 vendors — stuck? force-recycle in one click. Spring Boot inside — drop-in for any Java shop already running production services.
Same "whole widget" philosophy. Different center of gravity.
Quick start
# Backend
cd mateclaw-server
mvn spring-boot:run # http://localhost:18088
# Frontend
cd mateclaw-ui
pnpm install && pnpm dev # http://localhost:5173
Login: admin / admin123
Docker
cp .env.example .env
docker compose up -d # http://localhost:18080
Desktop
Download from GitHub Releases. Bundles JRE 21. No Java install needed.
Architecture
Project structure
mateclaw/
├── mateclaw-server/ Spring Boot 3.5 backend (Spring AI Alibaba, StateGraph runtime)
├── mateclaw-ui/ Vue 3 + TypeScript admin SPA (built into the server JAR)
├── mateclaw-webchat/ Embeddable chat widget (UMD / ES bundles)
├── mateclaw-plugin-api/ Java SDK for third-party capability plugins
├── mateclaw-plugin-sample/ Reference plugin implementation
├── docker-compose.yml
└── .env.example
Desktop binaries ship via GitHub Releases with a bundled JRE 21 — no Java install needed.
Tech stack
| Layer | Technology |
|---|---|
| Backend | Spring Boot 3.5 · Spring AI Alibaba 1.1 · MyBatis Plus · Flyway |
| Digital Employee Runtime | StateGraph · ReAct + Plan-Execute · Role / Goal / Backstory · LESSONS self-evolution |
| Orchestration | Workflow (7 step modes · Pebble DSL) · Triggers (6 pattern types · event governance) · Wiki Transformations (1.3.0+) |
| Capability Extension | SKILL.md packages · MCP (stdio / SSE / HTTP · per-agent binding) · ACP bridge (Claude Code / Codex) |
| Database | H2 (dev) · MySQL 8.0+ (prod) |
| Auth | Spring Security + JWT |
| Frontend | Vue 3 · TypeScript · Vite · Element Plus · TailwindCSS 4 |
| Desktop | Electron · electron-updater · JRE 21 (bundled) |
| Widget | Vite library mode · UMD + ES bundles |
Documentation
Full docs at claw.mate.vip/docs — setup, architecture, each subsystem, API reference.
Roadmap
v1.6.0 (shipped 2026-06-22) — make the autonomous employee fast, sharp-eyed, and embeddable:
- Faster first token — two-stage skill loading (base skills resident, scenario skills retrieved on demand by a relevance scorer) plus prefix compression, cutting the cold-start payload that used to blow past a million characters
- Native code execution —
execute_codelets an employee write and run sandboxed code to compute, transform data, and assemble multi-format reports, all JVM-side - Vision that persists — images stay in context across turns;
image_analyzere-reads an attachment on demand, so "zoom into that chart" follow-ups work without re-uploading - Embeddable & headless — the webchat widget becomes a Web/API surface with multi-session support and per-end-user identity (
endUserId), isolating memory per end user - A Wiki you actually read — reading split from management, a unified Sources tab with per-KB auto-sync, and clickable cross-KB
[[wikilinks]] - Steadier under load — self-healing MCP connections · tool-call recovery on interleaved-thinking models · evidence-gated plan execution
Full story in the v1.6.0 release notes.
v1.5.0 (shipped 2026-06-04) — Goal checklists (fuzzy score → ticked boxes) · self-maintaining Wiki ([[wikilinks]] · fact/experience layers · pageType profiles & permissions · KB pipelines · local-directory ingest) · per-owner memory isolation (owner_key + visibility scope + endUserId passthrough) · per-agent primary knowledge base · provider-preference model routing. Full story in the v1.5.0 release notes.
v1.4.0 (shipped 2026-05-23) — Persistent Goals (lock a goal, self-evaluate every turn) · subagent delegation tree (3 levels deep · sync / parallel / async · one-sentence team builder) · progressive tool/skill disclosure · Workspace RBAC (Owner / Admin / Member / Viewer) · Feishu first-class (interactive / approval / streaming cards · channel-native tools). See the v1.4.0 release notes.
v1.3.0 (shipped 2026-05-13) — Workflow engine · 6-pattern trigger system · Wiki transformations · per-agent MCP binding · multimodal sidecar routing · four JVM-native document-generation tools · image edit. See the v1.3.0 release notes.
Contributing
git clone https://github.com/mateaix/mateclaw.git
cd mateclaw
cd mateclaw-server && mvn clean compile
cd ../mateclaw-ui && pnpm install && pnpm dev
Why the name
Mate is companion. Claw is capability.
Something that stays with you — and grabs work and moves it.
License
Apache License 2.0. No asterisks.

